mirror of
https://github.com/python/cpython.git
synced 2025-11-17 17:46:45 +00:00
Advertise nesting directives for class/method and class/data combos.
Also fix a typo and a misleading example (method used to describe function).
This commit is contained in:
parent
691840f218
commit
a0b3c32c7a
1 changed files with 21 additions and 4 deletions
|
|
@ -152,7 +152,7 @@ The directives are:
|
||||||
|
|
||||||
Describes global data in a module, including both variables and values used
|
Describes global data in a module, including both variables and values used
|
||||||
as "defined constants." Class and object attributes are not documented
|
as "defined constants." Class and object attributes are not documented
|
||||||
using this environment.
|
using this directive.
|
||||||
|
|
||||||
.. describe:: exception
|
.. describe:: exception
|
||||||
|
|
||||||
|
|
@ -165,7 +165,7 @@ The directives are:
|
||||||
parameters, enclosing optional parameters in brackets. Default values can be
|
parameters, enclosing optional parameters in brackets. Default values can be
|
||||||
given if it enhances clarity. For example::
|
given if it enhances clarity. For example::
|
||||||
|
|
||||||
.. function:: Timer.repeat([repeat=3[, number=1000000]])
|
.. function:: repeat([repeat=3[, number=1000000]])
|
||||||
|
|
||||||
Object methods are not documented using this directive. Bound object methods
|
Object methods are not documented using this directive. Bound object methods
|
||||||
placed in the module namespace as part of the public interface of the module
|
placed in the module namespace as part of the public interface of the module
|
||||||
|
|
@ -186,13 +186,30 @@ The directives are:
|
||||||
|
|
||||||
Describes an object data attribute. The description should include
|
Describes an object data attribute. The description should include
|
||||||
information about the type of the data to be expected and whether it may be
|
information about the type of the data to be expected and whether it may be
|
||||||
changed directly.
|
changed directly. This directive should be nested in a class directive,
|
||||||
|
like in this example::
|
||||||
|
|
||||||
|
.. class:: Spam
|
||||||
|
|
||||||
|
Description of the class.
|
||||||
|
|
||||||
|
.. data:: ham
|
||||||
|
|
||||||
|
Description of the attribute.
|
||||||
|
|
||||||
|
If is also possible to document an attribute outside of a class directive,
|
||||||
|
for example if the documentation for different attributes and methods is
|
||||||
|
split in multiple sections. The class name should then be included
|
||||||
|
explicitly::
|
||||||
|
|
||||||
|
.. data:: Spam.eggs
|
||||||
|
|
||||||
.. describe:: method
|
.. describe:: method
|
||||||
|
|
||||||
Describes an object method. The parameters should not include the ``self``
|
Describes an object method. The parameters should not include the ``self``
|
||||||
parameter. The description should include similar information to that
|
parameter. The description should include similar information to that
|
||||||
described for ``function``.
|
described for ``function``. This method should be nested in a class
|
||||||
|
method, like in the example above.
|
||||||
|
|
||||||
.. describe:: opcode
|
.. describe:: opcode
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue