mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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:
@@ -8,3 +8,4 @@ test-domain-py
|
||||
module_option
|
||||
abbr
|
||||
canonical
|
||||
type_alias
|
||||
|
||||
@@ -64,3 +64,6 @@ module
|
||||
|
||||
.. py:data:: test2
|
||||
:type: typing.Literal[-2]
|
||||
|
||||
.. py:type:: MyType1
|
||||
:canonical: list[int | str]
|
||||
|
||||
@@ -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`
|
||||
|
||||
15
tests/roots/test-domain-py/type_alias.rst
Normal file
15
tests/roots/test-domain-py/type_alias.rst
Normal 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]
|
||||
Reference in New Issue
Block a user