Change priority of sphinx-domains

This commit is contained in:
Takeshi KOMIYA 2018-04-15 02:34:26 +09:00
parent 765aec565d
commit 5e4da90ffa
4 changed files with 17 additions and 8 deletions

View File

@ -17,8 +17,8 @@ Incompatible changes
a ``conf.py`` file sphinx-build generates.
* The ``gettext_compact`` attribute is removed from ``document.settings``
object. Please use ``config.gettext_compact`` instead.
* The order of smart_quotes is changed. For more detail, please read a
description of :py:meth:`.Sphinx.add_transform()`
* The processing order of smart_quotes and sphinx domains are changed. For more
details, please read a description of :py:meth:`.Sphinx.add_transform()`
Deprecated
----------

View File

@ -21,7 +21,7 @@ from os import path
from docutils.frontend import OptionParser
from docutils.utils import Reporter, get_source_line
from six import BytesIO, itervalues, class_types, next
from six import BytesIO, class_types, next
from six.moves import cPickle as pickle
from sphinx import addnodes, versioning
@ -570,10 +570,6 @@ class BuildEnvironment(object):
with sphinx_domains(self), rst.default_role(docname, self.config.default_role):
doctree = read_doc(self.app, self, self.doc2path(docname))
# post-processing
for domain in itervalues(self.domains):
domain.process_doc(self, docname, doctree)
# allow extension-specific post-processing
if app:
app.emit('doctree-read', doctree)

View File

@ -31,6 +31,7 @@ from sphinx.transforms.compact_bullet_list import RefOnlyBulletListTransform
from sphinx.transforms.i18n import (
PreserveTranslatableMessages, Locale, RemoveTranslatableInline,
)
from sphinx.transforms.references import SphinxDomains
from sphinx.util import logging
from sphinx.util.docutils import LoggingReporter
@ -93,7 +94,8 @@ class SphinxStandaloneReader(SphinxBaseReader):
Locale, CitationReferences, DefaultSubstitutions, MoveModuleTargets,
HandleCodeBlocks, AutoNumbering, AutoIndexUpgrader, SortIds,
RemoveTranslatableInline, FilterSystemMessages, RefOnlyBulletListTransform,
UnreferencedFootnotesDetector, SphinxSmartQuotes, ManpageLink
UnreferencedFootnotesDetector, SphinxSmartQuotes, ManpageLink,
SphinxDomains,
] # type: List[Transform]
def __init__(self, app, *args, **kwargs):

View File

@ -11,6 +11,7 @@
from docutils import nodes
from docutils.transforms.references import Substitutions
from six import itervalues
from sphinx.transforms import SphinxTransform
@ -28,3 +29,13 @@ class SubstitutionDefinitionsRemover(SphinxTransform):
# type: () -> None
for node in self.document.traverse(nodes.substitution_definition):
node.parent.remove(node)
class SphinxDomains(SphinxTransform):
"""Collect objects to Sphinx domains for cross references."""
default_priority = 850
def apply(self):
# type: () -> None
for domain in itervalues(self.env.domains):
domain.process_doc(self, self.env.docname, self.document)