Skip to content
Draft
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
10 changes: 7 additions & 3 deletions documentation/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,10 +1191,14 @@ def extract_annotation(state: State, referrer_path: List[str], annotation) -> Tu
elif isinstance(annotation, typing.TypeVar):
return annotation.__name__, annotation.__name__

# Ellipsis -- print a literal `...`
# TODO: any chance to link this to python official docs?
# Ellipsis -- print a literal `...`, link to Ellipsis in python docs
elif annotation is ...:
return '...', '...'
# TODO m.sphinx needs to have a special case to extract `...` from
# python.inv (which is a `std.term`, alongside generic stuff like
# "class", "py" etc. which we DON'T want to link to) and convert it to
# a link to Ellipsis, or alternatively pass Ellipsis here but make it
# display as a literal ...
return '...', make_name_link(state, referrer_path, 'Ellipsis')

# If the annotation is from the typing module, it ... gets complicated. It
# could be a "bracketed" type, in which case we want to recurse to its
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def type_string(a: 'Foo'):
def type_nested(a: Tuple[Foo, List[Enum], Any]):
"""A function with nested type annotation"""

def type_nested_ellipsis(a: Tuple[int, ...]):
"""A function with a variadic tuple annotation"""

def type_string_nested(a: 'Tuple[Foo, List[Enum], Any]'):
"""A function with string nested type annotation"""

Expand Down