Add `py:type` directive and role for documenting type aliases (#11989)

Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
This commit is contained in:
Ashley Whetter
2024-07-11 04:15:54 -07:00
committed by GitHub
parent 91c5cd3abd
commit e38a60d3f2
9 changed files with 221 additions and 15 deletions

View File

@@ -8,3 +8,4 @@ test-domain-py
module_option
abbr
canonical
type_alias

View File

@@ -64,3 +64,6 @@ module
.. py:data:: test2
:type: typing.Literal[-2]
.. py:type:: MyType1
:canonical: list[int | str]

View File

@@ -5,14 +5,19 @@ roles
.. py:method:: top_level
.. py:type:: TopLevelType
* :py:class:`TopLevel`
* :py:meth:`top_level`
* :py:type:`TopLevelType`
.. py:class:: NestedParentA
* Link to :py:meth:`child_1`
.. py:type:: NestedTypeA
.. py:method:: child_1()
* Link to :py:meth:`NestedChildA.subchild_2`
@@ -46,3 +51,4 @@ roles
* Link to :py:class:`NestedParentB`
* :py:class:`NestedParentA.NestedChildA`
* :py:type:`NestedParentA.NestedTypeA`

View File

@@ -0,0 +1,15 @@
Type Alias
==========
.. py:module:: module_two
.. py:class:: SomeClass
:py:type:`.MyAlias`
:any:`MyAlias`
:any:`module_one.MyAlias`
.. py:module:: module_one
.. py:type:: MyAlias
:canonical: list[int | module_two.SomeClass]