diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index 5c444fb56..14bd09791 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -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): diff --git a/tests/test_directive_only.py b/tests/test_directive_only.py index 35d15b391..d8017f469 100644 --- a/tests/test_directive_only.py +++ b/tests/test_directive_only.py @@ -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)]]