mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add document for utility classes
This commit is contained in:
@@ -94,6 +94,7 @@ APIs used for writing extensions
|
|||||||
nodes
|
nodes
|
||||||
logging
|
logging
|
||||||
i18n
|
i18n
|
||||||
|
utils
|
||||||
|
|
||||||
Deprecated APIs
|
Deprecated APIs
|
||||||
---------------
|
---------------
|
||||||
|
|||||||
19
doc/extdev/utils.rst
Normal file
19
doc/extdev/utils.rst
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
Utilities
|
||||||
|
=========
|
||||||
|
|
||||||
|
Sphinx provides utility classes and functions to develop extensions.
|
||||||
|
|
||||||
|
Base classes for components
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
These base classes are useful to allow your extensions to obtain Sphinx
|
||||||
|
components (e.g. :class:`.Config`, :class:`.BuildEnvironment` and so on) easily.
|
||||||
|
|
||||||
|
.. note:: The subclasses of them might not work with bare docutils because they
|
||||||
|
are strongly coupled with Sphinx.
|
||||||
|
|
||||||
|
.. autoclass:: sphinx.transforms.SphinxTransform
|
||||||
|
:members:
|
||||||
|
|
||||||
|
.. autoclass:: sphinx.util.docutils.SphinxDirective
|
||||||
|
:members:
|
||||||
@@ -44,35 +44,28 @@ default_substitutions = set([
|
|||||||
|
|
||||||
|
|
||||||
class SphinxTransform(Transform):
|
class SphinxTransform(Transform):
|
||||||
"""
|
"""A base class of Transforms.
|
||||||
A base class of Transforms.
|
|
||||||
|
|
||||||
Compared with ``docutils.transforms.Transform``, this class improves accessibility to
|
Compared with ``docutils.transforms.Transform``, this class improves accessibility to
|
||||||
Sphinx APIs.
|
Sphinx APIs.
|
||||||
|
|
||||||
The subclasses can access following objects and functions:
|
|
||||||
|
|
||||||
self.app
|
|
||||||
The application object (:class:`sphinx.application.Sphinx`)
|
|
||||||
self.config
|
|
||||||
The config object (:class:`sphinx.config.Config`)
|
|
||||||
self.env
|
|
||||||
The environment object (:class:`sphinx.environment.BuildEnvironment`)
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def app(self):
|
def app(self):
|
||||||
# type: () -> Sphinx
|
# type: () -> Sphinx
|
||||||
|
"""Reference to the :class:`.Sphinx` object."""
|
||||||
return self.document.settings.env.app
|
return self.document.settings.env.app
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def env(self):
|
def env(self):
|
||||||
# type: () -> BuildEnvironment
|
# type: () -> BuildEnvironment
|
||||||
|
"""Reference to the :class:`.BuildEnvironment` object."""
|
||||||
return self.document.settings.env
|
return self.document.settings.env
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def config(self):
|
def config(self):
|
||||||
# type: () -> Config
|
# type: () -> Config
|
||||||
|
"""Reference to the :class:`.Config` object."""
|
||||||
return self.document.settings.env.config
|
return self.document.settings.env.config
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user