mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #4611: epub: Show warning for duplicated ToC entries
This commit is contained in:
@@ -35,7 +35,7 @@ except ImportError:
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Dict, List, Tuple # NOQA
|
||||
from typing import Any, Dict, List, Set, Tuple # NOQA
|
||||
from sphinx.application import Sphinx # NOQA
|
||||
|
||||
|
||||
@@ -213,6 +213,15 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
||||
result = self.get_refnodes(elem, result)
|
||||
return result
|
||||
|
||||
def check_refnodes(self, nodes):
|
||||
# type: (List[Dict[str, Any]]) -> None
|
||||
appeared = set() # type: Set[str]
|
||||
for node in nodes:
|
||||
if node['refuri'] in appeared:
|
||||
logger.warning(__('duplicated ToC entry found: %s'), node['refuri'])
|
||||
else:
|
||||
appeared.add(node['refuri'])
|
||||
|
||||
def get_toc(self):
|
||||
# type: () -> None
|
||||
"""Get the total table of contents, containing the master_doc
|
||||
@@ -726,6 +735,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
||||
else:
|
||||
# 'includehidden'
|
||||
refnodes = self.refnodes
|
||||
self.check_refnodes(refnodes)
|
||||
navpoints = self.build_navpoints(refnodes)
|
||||
level = max(item['level'] for item in self.refnodes)
|
||||
level = min(level, self.config.epub_tocdepth)
|
||||
|
||||
Reference in New Issue
Block a user