Skip to content

Commit

Permalink
update Python domain doc
Browse files Browse the repository at this point in the history
  • Loading branch information
picnixz committed Jun 6, 2023
1 parent 160b5cc commit a924d4a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions doc/usage/restructuredtext/domains.rst
Expand Up @@ -289,7 +289,8 @@ The following directives are provided for module and class contents:
.. py:exception:: name[type parmeters](parameters)
Describes an exception class. The signature can, but need not include
parentheses with constructor arguments.
parentheses with constructor arguments, or may optionally include type
parameters (see :pep:`695`).

.. rubric:: options

Expand Down Expand Up @@ -379,9 +380,9 @@ The following directives are provided for module and class contents:
.. rst:directive:option:: single-line-type-parameter-list
:type: no value
Ensure that the class constructor's type parameters are emitted on a
single logical line, overriding :confval:`python_maximum_signature_line_length`
and :confval:`maximum_signature_line_length`.
Ensure that the class type parameters are emitted on a single logical
line, overriding :confval:`python_maximum_signature_line_length` and
:confval:`maximum_signature_line_length`.
.. rst:directive:: .. py:attribute:: name
Expand Down Expand Up @@ -620,7 +621,19 @@ argument support), you can use brackets to specify the optional parts:
It is customary to put the opening bracket before the comma.

Since Python 3.12, it is possible to indicate type parameters directly at the
function or class definition site::
function or class definition site:

.. code-block:: python
class MyDict[T](dict[str, T]):
...
def add[T](x: T, y: T) -> T:
return x + y
The corresponding documentation would look like::

.. py:class:: MyDict[T]

.. py:function:: add[T](x: T, y: T) -> T

Expand Down

0 comments on commit a924d4a

Please sign in to comment.