doc: Apply :params: to some APIs in app class

This commit is contained in:
Takeshi KOMIYA 2021-01-24 01:11:04 +09:00
parent f707cb30a1
commit a2d6ee6108

View File

@ -404,9 +404,10 @@ class Sphinx:
def require_sphinx(self, version: str) -> None: def require_sphinx(self, version: str) -> None:
"""Check the Sphinx version if requested. """Check the Sphinx version if requested.
Compare *version* (which must be a ``major.minor`` version string, e.g. Compare *version* with the version of the running Sphinx, and abort the
``'1.1'``) with the version of the running Sphinx, and abort the build build when it is too old.
when it is too old.
:param version: The required version that forms ``major.minor``.
.. versionadded:: 1.0 .. versionadded:: 1.0
""" """
@ -420,11 +421,11 @@ class Sphinx:
For details on available core events and the arguments of callback For details on available core events and the arguments of callback
functions, please see :ref:`events`. functions, please see :ref:`events`.
Registered callbacks will be invoked on event in the order of *priority* and :param event: The name of target event
registration. The priority is ascending order. :param callback: Callback function for the event
:param priority: The priority of the callback. The callbacks will be invoked
The method returns a "listener ID" that can be used as an argument to in the order of *priority* in asending.
:meth:`disconnect`. :return: A listener ID. It can be used for :meth:`disconnect`.
.. versionchanged:: 3.0 .. versionchanged:: 3.0
@ -436,7 +437,10 @@ class Sphinx:
return listener_id return listener_id
def disconnect(self, listener_id: int) -> None: def disconnect(self, listener_id: int) -> None:
"""Unregister callback by *listener_id*.""" """Unregister callback by *listener_id*.
:param listener_id: A listener_id that :meth:`connect` returns
"""
logger.debug('[app] disconnecting event: [id=%s]', listener_id) logger.debug('[app] disconnecting event: [id=%s]', listener_id)
self.events.disconnect(listener_id) self.events.disconnect(listener_id)
@ -447,6 +451,10 @@ class Sphinx:
Return the return values of all callbacks as a list. Do not emit core Return the return values of all callbacks as a list. Do not emit core
Sphinx events in extensions! Sphinx events in extensions!
:param event: The name of event that will be emitted
:param args: The arguments for the event
:param allowed_exceptions: The list of exceptions that are allowed in the callbacks
.. versionchanged:: 3.1 .. versionchanged:: 3.1
Added *allowed_exceptions* to specify path-through exceptions Added *allowed_exceptions* to specify path-through exceptions
@ -459,6 +467,10 @@ class Sphinx:
Return the result of the first callback that doesn't return ``None``. Return the result of the first callback that doesn't return ``None``.
:param event: The name of event that will be emitted
:param args: The arguments for the event
:param allowed_exceptions: The list of exceptions that are allowed in the callbacks
.. versionadded:: 0.5 .. versionadded:: 0.5
.. versionchanged:: 3.1 .. versionchanged:: 3.1
@ -472,10 +484,9 @@ class Sphinx:
def add_builder(self, builder: "Type[Builder]", override: bool = False) -> None: def add_builder(self, builder: "Type[Builder]", override: bool = False) -> None:
"""Register a new builder. """Register a new builder.
*builder* must be a class that inherits from :class:`~sphinx.builders.Builder`. :param builder: A builder class
:param override: If true, install the builder forcedly even if another builder
If *override* is True, the given *builder* is forcedly installed even if is already installed as the same name
a builder having the same name is already installed.
.. versionchanged:: 1.8 .. versionchanged:: 1.8
Add *override* keyword. Add *override* keyword.
@ -532,8 +543,10 @@ class Sphinx:
builtin translator. This allows extensions to use custom translator builtin translator. This allows extensions to use custom translator
and define custom nodes for the translator (see :meth:`add_node`). and define custom nodes for the translator (see :meth:`add_node`).
If *override* is True, the given *translator_class* is forcedly installed even if :param name: The name of builder for the translator
a translator for *name* is already installed. :param translator_class: A translator class
:param override: If true, install the translator forcedly even if another translator
is already installed as the same name
.. versionadded:: 1.3 .. versionadded:: 1.3
.. versionchanged:: 1.8 .. versionchanged:: 1.8
@ -618,10 +631,10 @@ class Sphinx:
def add_directive(self, name: str, cls: "Type[Directive]", override: bool = False) -> None: def add_directive(self, name: str, cls: "Type[Directive]", override: bool = False) -> None:
"""Register a Docutils directive. """Register a Docutils directive.
*name* must be the prospective directive name. *cls* is a directive :param name: The name of directive
class which inherits ``docutils.parsers.rst.Directive``. For more :param cls: A directive class
details, see `the Docutils docs :param override: If true, install the directive forcedly even if another directive
<http://docutils.sourceforge.net/docs/howto/rst-directives.html>`_ . is already installed as the same name
For example, a custom directive named ``my-directive`` would be added For example, a custom directive named ``my-directive`` would be added
like this: like this:
@ -646,8 +659,8 @@ class Sphinx:
def setup(app): def setup(app):
add_directive('my-directive', MyDirective) add_directive('my-directive', MyDirective)
If *override* is True, the given *cls* is forcedly installed even if For more details, see `the Docutils docs
a directive named as *name* is already installed. <http://docutils.sourceforge.net/docs/howto/rst-directives.html>`__ .
.. versionchanged:: 0.6 .. versionchanged:: 0.6
Docutils 0.5-style directive classes are now supported. Docutils 0.5-style directive classes are now supported.
@ -666,13 +679,13 @@ class Sphinx:
def add_role(self, name: str, role: Any, override: bool = False) -> None: def add_role(self, name: str, role: Any, override: bool = False) -> None:
"""Register a Docutils role. """Register a Docutils role.
*name* must be the role name that occurs in the source, *role* the role :param name: The name of role
function. Refer to the `Docutils documentation :param cls: A role function
<http://docutils.sourceforge.net/docs/howto/rst-roles.html>`_ for :param override: If true, install the role forcedly even if another role is already
more information. installed as the same name
If *override* is True, the given *role* is forcedly installed even if For more details about role functions, see `the Docutils docs
a role named as *name* is already installed. <http://docutils.sourceforge.net/docs/howto/rst-roles.html>`__ .
.. versionchanged:: 1.8 .. versionchanged:: 1.8
Add *override* keyword. Add *override* keyword.