Remove deprecated feature: sphinx.util.nodes.process_only_nodes()

This commit is contained in:
Takeshi KOMIYA 2017-04-27 21:49:19 +09:00
parent 4874ae2c1d
commit b4eadba3a1
2 changed files with 1 additions and 28 deletions

View File

@ -11,14 +11,12 @@
from __future__ import absolute_import
import re
import warnings
from six import text_type
from docutils import nodes
from sphinx import addnodes
from sphinx.deprecation import RemovedInSphinx17Warning
from sphinx.locale import pairindextypes
from sphinx.util import logging
@ -354,30 +352,6 @@ def set_role_source_info(inliner, lineno, node):
node.source, node.line = inliner.reporter.get_source_and_line(lineno)
def process_only_nodes(doctree, tags):
# type: (nodes.Node, Tags) -> None
# A comment on the comment() nodes being inserted: replacing by [] would
# result in a "Losing ids" exception if there is a target node before
# the only node, so we make sure docutils can transfer the id to
# something, even if it's just a comment and will lose the id anyway...
warnings.warn('process_only_nodes() is deprecated. '
'Use sphinx.environment.apply_post_transforms() instead.',
RemovedInSphinx17Warning)
for node in doctree.traverse(addnodes.only):
try:
ret = tags.eval_condition(node['expr'])
except Exception as err:
logger.warning('exception while evaluating only directive expression: %s', err,
location=node)
node.replace_self(node.children or nodes.comment())
else:
if ret:
node.replace_self(node.children or nodes.comment())
else:
node.replace_self(nodes.comment())
# monkey-patch Element.copy to copy the rawsource and line
def _new_copy(self):

View File

@ -12,7 +12,6 @@
import re
from docutils import nodes
from sphinx.util.nodes import process_only_nodes
import pytest
@ -46,7 +45,7 @@ def test_sectioning(app, status, warning):
app.builder.build(['only'])
doctree = app.env.get_doctree('only')
process_only_nodes(doctree, app.builder.tags)
app.env.apply_post_transforms(doctree, 'only')
parts = [getsects(n)
for n in [_n for _n in doctree.children if isinstance(_n, nodes.section)]]