--- a/Doc/conf.py +++ b/Doc/conf.py @@ -13,7 +13,7 @@ # --------------------- extensions = ['sphinx.ext.refcounting', 'sphinx.ext.coverage', - 'sphinx.ext.doctest', 'pyspecific'] + 'sphinx.ext.doctest'] templates_path = ['tools/sphinxext'] # General substitutions. --- a/Doc/tools/sphinxext/pyspecific.py +++ b/Doc/tools/sphinxext/pyspecific.py @@ -84,32 +84,6 @@ return [pnode] -# Support for documenting decorators - -from sphinx import addnodes -from sphinx.domains.python import PyModulelevel, PyClassmember - -class PyDecoratorMixin(object): - def handle_signature(self, sig, signode): - ret = super(PyDecoratorMixin, self).handle_signature(sig, signode) - signode.insert(0, addnodes.desc_addname('@', '@')) - return ret - - def needs_arglist(self): - return False - -class PyDecoratorFunction(PyDecoratorMixin, PyModulelevel): - def run(self): - # a decorator function is a function after all - self.name = 'py:function' - return PyModulelevel.run(self) - -class PyDecoratorMethod(PyDecoratorMixin, PyClassmember): - def run(self): - self.name = 'py:method' - return PyClassmember.run(self) - - # Support for documenting version of removal in deprecations from sphinx.locale import versionlabels @@ -227,6 +201,7 @@ # Support for documenting Opcodes import re +from sphinx import addnodes opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)(?:\s*\((.*)\))?') @@ -280,5 +255,3 @@ app.add_description_unit('pdbcommand', 'pdbcmd', '%s (pdb command)', parse_pdb_command) app.add_description_unit('2to3fixer', '2to3fixer', '%s (2to3 fixer)') - app.add_directive_to_domain('py', 'decorator', PyDecoratorFunction) - app.add_directive_to_domain('py', 'decoratormethod', PyDecoratorMethod) --- a/Doc/library/contextlib.rst +++ b/Doc/library/contextlib.rst @@ -17,7 +17,7 @@ Functions provided: -.. decorator:: contextmanager +.. function:: contextmanager(func) This function is a :term:`decorator` that can be used to define a factory function for :keyword:`with` statement context managers, without needing to --- a/Doc/library/abc.rst +++ b/Doc/library/abc.rst @@ -122,7 +122,7 @@ It also provides the following decorators: -.. decorator:: abstractmethod(function) +.. function:: abstractmethod(function) A decorator indicating abstract methods. --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -647,20 +647,20 @@ The following decorators implement test skipping and expected failures: -.. decorator:: skip(reason) +.. function:: skip(reason) Unconditionally skip the decorated test. *reason* should describe why the test is being skipped. -.. decorator:: skipIf(condition, reason) +.. function:: skipIf(condition, reason) Skip the decorated test if *condition* is true. -.. decorator:: skipUnless(condition, reason) +.. function:: skipUnless(condition, reason) Skip the decorated test unless *condition* is true. -.. decorator:: expectedFailure +.. function:: expectedFailure Mark the test as an expected failure. If the test fails when run, the test is not counted as a failure. @@ -948,11 +948,11 @@ :attr:`exception` attribute. This can be useful if the intention is to perform additional checks on the exception raised:: - with self.assertRaises(SomeException) as cm: - do_something() + with self.assertRaises(SomeException) as cm: + do_something() - the_exception = cm.exception - self.assertEqual(the_exception.error_code, 3) + the_exception = cm.exception + self.assertEqual(the_exception.error_code, 3) .. versionchanged:: 3.1 Added the ability to use :meth:`assertRaises` as a context manager. --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -469,7 +469,7 @@ This module contains the various objects that help in the construction of an :term:`importer`. -.. decorator:: module_for_loader +.. function:: module_for_loader(method) A :term:`decorator` for a :term:`loader` method, to handle selecting the proper @@ -494,7 +494,7 @@ Use of this decorator handles all the details of which module object a loader should initialize as specified by :pep:`302`. -.. decorator:: set_loader +.. function:: set_loader(fxn) A :term:`decorator` for a :term:`loader` method, to set the :attr:`__loader__` @@ -502,7 +502,7 @@ does nothing. It is assumed that the first positional argument to the wrapped method is what :attr:`__loader__` should be set to. -.. decorator:: set_package +.. function:: set_package(fxn) A :term:`decorator` for a :term:`loader` to set the :attr:`__package__` attribute on the module returned by the loader. If :attr:`__package__` is --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -74,7 +74,7 @@ .. versionadded:: 3.2 -.. decorator:: total_ordering +.. function:: total_ordering(cls) Given a class defining one or more rich comparison ordering methods, this class decorator supplies the rest. This simplifies the effort involved @@ -180,7 +180,7 @@ Missing attributes no longer trigger an :exc:`AttributeError`. -.. decorator:: wraps(wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES) +.. function:: wraps(wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES) This is a convenience function for invoking ``partial(update_wrapper, wrapped=wrapped, assigned=assigned, updated=updated)`` as a function decorator --- a/Doc/documenting/markup.rst +++ b/Doc/documenting/markup.rst @@ -177,37 +177,6 @@ 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*. - - There is no ``deco`` role to link to a decorator that is marked up with - this directive; rather, use the ``:func:`` role. - .. describe:: class Describes a class. The signature can include parentheses with parameters @@ -225,12 +194,6 @@ parameter. The description should include similar information to that described for ``function``. -.. describe:: decoratormethod - - Same as ``decorator``, but for decorators that are methods. - - Refer to a decorator method using the ``:meth:`` role. - .. describe:: opcode Describes a Python :term:`bytecode` instruction.