Change priority of doctree-read event

This commit is contained in:
Takeshi KOMIYA 2018-04-16 00:16:18 +09:00
parent 5e4da90ffa
commit 538c061e7c
4 changed files with 13 additions and 7 deletions

View File

@ -17,7 +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 processing order of smart_quotes and sphinx domains are changed. For more
* The processing order on reading phase is changed. smart_quotes, sphinx
domains and :event:`doctree-read` event are invoked earlier. For more
details, please read a description of :py:meth:`.Sphinx.add_transform()`
Deprecated

View File

@ -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))
# allow extension-specific post-processing
if app:
app.emit('doctree-read', doctree)
# store time of reading, for outdated files detection
# (Some filesystems have coarse timestamp resolution;
# therefore time.time() can be older than filesystem's timestamp.

View File

@ -24,7 +24,7 @@ from sphinx.transforms import (
ApplySourceWorkaround, ExtraTranslatableNodes, CitationReferences,
DefaultSubstitutions, MoveModuleTargets, HandleCodeBlocks, SortIds,
AutoNumbering, AutoIndexUpgrader, FilterSystemMessages,
UnreferencedFootnotesDetector, SphinxSmartQuotes, ManpageLink
UnreferencedFootnotesDetector, SphinxSmartQuotes, DoctreeReadEvent, ManpageLink
)
from sphinx.transforms import SphinxTransformer
from sphinx.transforms.compact_bullet_list import RefOnlyBulletListTransform
@ -95,7 +95,7 @@ class SphinxStandaloneReader(SphinxBaseReader):
HandleCodeBlocks, AutoNumbering, AutoIndexUpgrader, SortIds,
RemoveTranslatableInline, FilterSystemMessages, RefOnlyBulletListTransform,
UnreferencedFootnotesDetector, SphinxSmartQuotes, ManpageLink,
SphinxDomains,
SphinxDomains, DoctreeReadEvent,
] # type: List[Transform]
def __init__(self, app, *args, **kwargs):

View File

@ -399,6 +399,15 @@ class SphinxSmartQuotes(SmartQuotes, SphinxTransform):
yield (texttype[notsmartquotable], txtnode.astext())
class DoctreeReadEvent(SphinxTransform):
"""Emit :event:`doctree-read` event."""
default_priority = 880
def apply(self):
# type: () -> None
self.app.emit('doctree-read', self.document)
class ManpageLink(SphinxTransform):
"""Find manpage section numbers and names"""
default_priority = 999