diff --git a/doc/extdev/appapi.rst b/doc/extdev/appapi.rst index e19e6f03c..1df85907a 100644 --- a/doc/extdev/appapi.rst +++ b/doc/extdev/appapi.rst @@ -288,6 +288,11 @@ package. Add the standard docutils :class:`Transform` subclass *transform* to the list of transforms that are applied after Sphinx parses a reST document. +.. method:: Sphinx.add_post_transform(transform) + + Add the standard docutils :class:`Transform` subclass *transform* to the list + of transforms that are applied before Sphinx writes a document. + .. method:: Sphinx.add_javascript(filename) Add *filename* to the list of JavaScript files that the default HTML template diff --git a/sphinx/application.py b/sphinx/application.py index bb1a9fc39..97339c62b 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -144,6 +144,7 @@ class Sphinx(object): self.builder = None # type: Builder self.env = None # type: BuildEnvironment self.enumerable_nodes = {} # type: Dict[nodes.Node, Tuple[unicode, Callable]] # NOQA + self.post_transforms = [] # type: List[Transform] self.srcdir = srcdir self.confdir = confdir @@ -785,10 +786,15 @@ class Sphinx(object): StandardDomain.roles[rolename] = XRefRole(innernodeclass=ref_nodeclass) def add_transform(self, transform): - # type: (Transform) -> None + # type: (Type[Transform]) -> None logger.debug('[app] adding transform: %r', transform) SphinxStandaloneReader.transforms.append(transform) + def add_post_transform(self, transform): + # type: (Type[Transform]) -> None + logger.debug('[app] adding post transform: %r', transform) + self.post_transforms.append(transform) + def add_javascript(self, filename): # type: (unicode) -> None logger.debug('[app] adding javascript: %r', filename)