Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix signature when alias #281

Merged
merged 3 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion quartodoc/renderers/md_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def signature(self, el: layout.Doc):
@dispatch
def signature(self, el: dc.Alias, source: Optional[dc.Alias] = None):
"""Return a string representation of an object's signature."""
return self.signature(el.target, el)
return self.signature(el.final_target, el)

@dispatch
def signature(
Expand Down
9 changes: 9 additions & 0 deletions quartodoc/tests/__snapshots__/test_renderers.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,15 @@
A function
'''
# ---
# name: test_render_doc_signature_name_alias_of_alias
'''
# example.a_nested_alias { #quartodoc.tests.example.a_nested_alias }

`tests.example.a_nested_alias()`

A nested alias target
'''
# ---
# name: test_render_docstring_numpy_linebreaks
'''
# f_numpy_with_linebreaks { #quartodoc.tests.example_docstring_styles.f_numpy_with_linebreaks }
Expand Down
5 changes: 4 additions & 1 deletion quartodoc/tests/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

# flake8: noqa

from quartodoc.tests.example_alias_target import alias_target as a_alias
from quartodoc.tests.example_alias_target import (
alias_target as a_alias,
nested_alias_target as a_nested_alias,
)


def a_func():
Expand Down
5 changes: 5 additions & 0 deletions quartodoc/tests/example_alias_target.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
from quartodoc.tests.example_alias_target__nested import ( # noqa: F401
nested_alias_target,
)


def alias_target():
"""An alias target"""
7 changes: 7 additions & 0 deletions quartodoc/tests/example_alias_target__nested.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
This function gets imported in example_alias_target, and from there imported into example.
"""


def nested_alias_target():
"""A nested alias target"""
4 changes: 2 additions & 2 deletions quartodoc/tests/test_builder_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ def test_blueprint_auto_package(bp):
assert sections[0].title == "quartodoc.tests.example"
assert sections[0].desc == "A module"

# 4 objects documented
assert len(sections[0].contents) == 4
# 5 objects documented
assert len(sections[0].contents) == 5


def test_blueprint_layout_options():
Expand Down
9 changes: 9 additions & 0 deletions quartodoc/tests/test_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,12 @@ def test_render_doc_signature_name(snapshot, renderer):
res = renderer.render(bp)

assert res == snapshot


def test_render_doc_signature_name_alias_of_alias(snapshot, renderer):
auto = Auto(name="example.a_nested_alias", package="quartodoc.tests")
bp = blueprint(auto)

res = renderer.render(bp)

assert res == snapshot