mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Allow registration of other translators
This adds an add_translator method to the sphinx application class. It allows developers to register custom translators (writers) with sphinx, so other extensions that add new nodes can register support for the custom translators.
This commit is contained in:
@@ -82,16 +82,25 @@ package.
|
||||
|
||||
Register an event called *name*. This is needed to be able to emit it.
|
||||
|
||||
.. method:: Sphinx.add_translator(name, translator_class)
|
||||
|
||||
Register a Docutils translator class. This is used to register a
|
||||
custom output translator. This allows extensions to define custom
|
||||
nodes for the translator (see :meth:`add_node`). If the name
|
||||
clashes with an existing translator an
|
||||
:exc:`sphinx.errors.ExtensionError` will be raised.
|
||||
|
||||
.. method:: Sphinx.add_node(node, **kwds)
|
||||
|
||||
Register a Docutils node class. This is necessary for Docutils internals.
|
||||
It may also be used in the future to validate nodes in the parsed documents.
|
||||
|
||||
Node visitor functions for the Sphinx HTML, LaTeX, text and manpage writers
|
||||
can be given as keyword arguments: the keyword must be one or more of
|
||||
``'html'``, ``'latex'``, ``'text'``, ``'man'``, ``'texinfo'``, the value a
|
||||
2-tuple of ``(visit, depart)`` methods. ``depart`` can be ``None`` if the
|
||||
``visit`` function raises :exc:`docutils.nodes.SkipNode`. Example:
|
||||
can be given as keyword arguments: the keyword should be one or more of
|
||||
``'html'``, ``'latex'``, ``'text'``, ``'man'``, ``'texinfo'`` or any other
|
||||
supported translators, the value a 2-tuple of ``(visit, depart)`` methods.
|
||||
``depart`` can be ``None`` if the ``visit`` function raises
|
||||
:exc:`docutils.nodes.SkipNode`. Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
||||
Reference in New Issue
Block a user