mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #4379: toctree shows confusible warning when document is excluded
This commit is contained in:
parent
c6e0d92d10
commit
86a43b0119
1
CHANGES
1
CHANGES
@ -30,6 +30,7 @@ Bugs fixed
|
|||||||
* #5348: download reference to remote file is not displayed
|
* #5348: download reference to remote file is not displayed
|
||||||
* #5282: html theme: ``pygments_style`` of theme was overrided by ``conf.py``
|
* #5282: html theme: ``pygments_style`` of theme was overrided by ``conf.py``
|
||||||
by default
|
by default
|
||||||
|
* #4379: toctree shows confusible warning when document is excluded
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -22,7 +22,7 @@ from sphinx.domains.changeset import VersionChange # NOQA # for compatibility
|
|||||||
from sphinx.locale import _
|
from sphinx.locale import _
|
||||||
from sphinx.util import url_re, docname_join
|
from sphinx.util import url_re, docname_join
|
||||||
from sphinx.util.docutils import SphinxDirective
|
from sphinx.util.docutils import SphinxDirective
|
||||||
from sphinx.util.matching import patfilter
|
from sphinx.util.matching import Matcher, patfilter
|
||||||
from sphinx.util.nodes import explicit_title_re, set_source_info, \
|
from sphinx.util.nodes import explicit_title_re, set_source_info, \
|
||||||
process_index_entry
|
process_index_entry
|
||||||
|
|
||||||
@ -96,6 +96,7 @@ class TocTree(SphinxDirective):
|
|||||||
all_docnames.remove(self.env.docname) # remove current document
|
all_docnames.remove(self.env.docname) # remove current document
|
||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
|
excluded = Matcher(self.config.exclude_patterns)
|
||||||
for entry in self.content:
|
for entry in self.content:
|
||||||
if not entry:
|
if not entry:
|
||||||
continue
|
continue
|
||||||
@ -131,9 +132,13 @@ class TocTree(SphinxDirective):
|
|||||||
if url_re.match(ref) or ref == 'self':
|
if url_re.match(ref) or ref == 'self':
|
||||||
toctree['entries'].append((title, ref))
|
toctree['entries'].append((title, ref))
|
||||||
elif docname not in self.env.found_docs:
|
elif docname not in self.env.found_docs:
|
||||||
ret.append(self.state.document.reporter.warning(
|
if excluded(self.env.doc2path(docname, None)):
|
||||||
'toctree contains reference to nonexisting '
|
message = 'toctree contains reference to excluded document %r'
|
||||||
'document %r' % docname, line=self.lineno))
|
else:
|
||||||
|
message = 'toctree contains reference to nonexisting document %r'
|
||||||
|
|
||||||
|
ret.append(self.state.document.reporter.warning(message % docname,
|
||||||
|
line=self.lineno))
|
||||||
self.env.note_reread()
|
self.env.note_reread()
|
||||||
else:
|
else:
|
||||||
all_docnames.discard(docname)
|
all_docnames.discard(docname)
|
||||||
|
@ -15,6 +15,7 @@ from six import iteritems
|
|||||||
from sphinx import addnodes
|
from sphinx import addnodes
|
||||||
from sphinx.locale import __
|
from sphinx.locale import __
|
||||||
from sphinx.util import url_re, logging
|
from sphinx.util import url_re, logging
|
||||||
|
from sphinx.util.matching import Matcher
|
||||||
from sphinx.util.nodes import clean_astext, process_only_nodes
|
from sphinx.util.nodes import clean_astext, process_only_nodes
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
@ -83,6 +84,7 @@ class TocTree(object):
|
|||||||
# interactions between marking and pruning the tree (see bug #1046).
|
# interactions between marking and pruning the tree (see bug #1046).
|
||||||
|
|
||||||
toctree_ancestors = self.get_toctree_ancestors(docname)
|
toctree_ancestors = self.get_toctree_ancestors(docname)
|
||||||
|
excluded = Matcher(self.env.config.exclude_patterns)
|
||||||
|
|
||||||
def _toctree_add_classes(node, depth):
|
def _toctree_add_classes(node, depth):
|
||||||
# type: (nodes.Node, int) -> None
|
# type: (nodes.Node, int) -> None
|
||||||
@ -172,8 +174,12 @@ class TocTree(object):
|
|||||||
ref, location=toctreenode)
|
ref, location=toctreenode)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# this is raised if the included file does not exist
|
# this is raised if the included file does not exist
|
||||||
logger.warning(__('toctree contains reference to nonexisting document %r'),
|
if excluded(self.env.doc2path(ref, None)):
|
||||||
ref, location=toctreenode)
|
message = __('toctree contains reference to excluded document %r')
|
||||||
|
else:
|
||||||
|
message = __('toctree contains reference to nonexisting document %r')
|
||||||
|
|
||||||
|
logger.warning(message, ref, location=toctreenode)
|
||||||
else:
|
else:
|
||||||
# if titles_only is given, only keep the main title and
|
# if titles_only is given, only keep the main title and
|
||||||
# sub-toctrees
|
# sub-toctrees
|
||||||
|
@ -81,6 +81,7 @@ from sphinx.util import import_object, rst, logging
|
|||||||
from sphinx.util.docutils import (
|
from sphinx.util.docutils import (
|
||||||
NullReporter, SphinxDirective, new_document, switch_source_input
|
NullReporter, SphinxDirective, new_document, switch_source_input
|
||||||
)
|
)
|
||||||
|
from sphinx.util.matching import Matcher
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
# For type annotation
|
# For type annotation
|
||||||
@ -261,10 +262,15 @@ class Autosummary(SphinxDirective):
|
|||||||
|
|
||||||
tree_prefix = self.options['toctree'].strip()
|
tree_prefix = self.options['toctree'].strip()
|
||||||
docnames = []
|
docnames = []
|
||||||
|
excluded = Matcher(self.config.exclude_patterns)
|
||||||
for name, sig, summary, real_name in items:
|
for name, sig, summary, real_name in items:
|
||||||
docname = posixpath.join(tree_prefix, real_name)
|
docname = posixpath.join(tree_prefix, real_name)
|
||||||
docname = posixpath.normpath(posixpath.join(dirname, docname))
|
docname = posixpath.normpath(posixpath.join(dirname, docname))
|
||||||
if docname not in self.env.found_docs:
|
if docname not in self.env.found_docs:
|
||||||
|
if excluded(self.env.doc2path(docname, None)):
|
||||||
|
self.warn('toctree references excluded document %r'
|
||||||
|
% docname)
|
||||||
|
else:
|
||||||
self.warn('toctree references unknown document %r'
|
self.warn('toctree references unknown document %r'
|
||||||
% docname)
|
% docname)
|
||||||
docnames.append(docname)
|
docnames.append(docname)
|
||||||
|
Loading…
Reference in New Issue
Block a user