mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
#6522: add a "decorator" directive to explicitly document decorators, and use it in a few places.
This commit is contained in:
parent
b0a4e3c1a7
commit
8a1caa2361
7 changed files with 75 additions and 16 deletions
|
@ -177,6 +177,34 @@ The directives are:
|
|||
are modified), side effects, and possible exceptions. A small example may be
|
||||
provided.
|
||||
|
||||
.. describe:: decorator
|
||||
|
||||
Describes a decorator function. The signature should *not* represent the
|
||||
signature of the actual function, but the usage as a decorator. For example,
|
||||
given the functions
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def removename(func):
|
||||
func.__name__ = ''
|
||||
return func
|
||||
|
||||
def setnewname(name):
|
||||
def decorator(func):
|
||||
func.__name__ = name
|
||||
return func
|
||||
return decorator
|
||||
|
||||
the descriptions should look like this::
|
||||
|
||||
.. decorator:: removename
|
||||
|
||||
Remove name of the decorated function.
|
||||
|
||||
.. decorator:: setnewname(name)
|
||||
|
||||
Set name of the decorated function to *name*.
|
||||
|
||||
.. describe:: class
|
||||
|
||||
Describes a class. The signature can include parentheses with parameters
|
||||
|
@ -194,6 +222,10 @@ The directives are:
|
|||
parameter. The description should include similar information to that
|
||||
described for ``function``.
|
||||
|
||||
.. describe:: decoratormethod
|
||||
|
||||
Same as ``decorator``, but for decorators that are methods.
|
||||
|
||||
.. describe:: opcode
|
||||
|
||||
Describes a Python :term:`bytecode` instruction.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue