-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apidoc/python: Fix xrefs to type parameters (#372)
Previously, if a function introduced a type parameter, any references to that type parameter in the signature itself were correctly resolved. However, when documenting function parameters, the type from the signature is duplicated next to the parameter name, and any references to type parameters in these duplicated types were not correctly resolved. This commit fixes that issue by applying the same resolution logic to the duplicated types.
- Loading branch information
Showing
4 changed files
with
95 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from typing import TypeVar | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
def foo(x: T) -> T: | ||
"""Foo function. | ||
:param x: Something or other. | ||
""" | ||
return x | ||
|
||
|
||
def bar(x: T) -> T: | ||
return x | ||
|
||
|
||
class C: | ||
def get(self, x: T, y: T) -> T: | ||
"""Get function. | ||
:param x: Something or other. | ||
:param y: Another param. | ||
:type y: T | ||
""" | ||
return x | ||
|
||
|
||
__all__ = ["foo", "bar", "C"] |