diff options
Diffstat (limited to 'sphinx/builders/epub3.py')
-rw-r--r-- | sphinx/builders/epub3.py | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/sphinx/builders/epub3.py b/sphinx/builders/epub3.py index cf795f3ba..1bef3c5bb 100644 --- a/sphinx/builders/epub3.py +++ b/sphinx/builders/epub3.py @@ -10,16 +10,13 @@ """ import html -import warnings -from collections import namedtuple from os import path -from typing import Any, Dict, List, Set, Tuple +from typing import Any, Dict, List, NamedTuple, Set, Tuple from sphinx import package_dir from sphinx.application import Sphinx from sphinx.builders import _epub_base from sphinx.config import Config, ENUM -from sphinx.deprecation import RemovedInSphinx40Warning from sphinx.locale import __ from sphinx.util import logging, xmlname_checker from sphinx.util.fileutil import copy_asset_file @@ -29,7 +26,12 @@ from sphinx.util.osutil import make_filename logger = logging.getLogger(__name__) -NavPoint = namedtuple('NavPoint', ['text', 'refuri', 'children']) +class NavPoint(NamedTuple): + text: str + refuri: str + children: List[Any] # mypy does not support recursive types + # https://github.com/python/mypy/issues/7069 + # writing modes PAGE_PROGRESSION_DIRECTIONS = { @@ -81,10 +83,6 @@ class Epub3Builder(_epub_base.EpubBuilder): self.build_toc() self.build_epub() - def validate_config_value(self) -> None: - warnings.warn('Epub3Builder.validate_config_value() is deprecated.', - RemovedInSphinx40Warning, stacklevel=2) - def content_metadata(self) -> Dict: """Create a dictionary with all metadata for the content.opf file properly escaped. @@ -162,15 +160,9 @@ class Epub3Builder(_epub_base.EpubBuilder): metadata['navlist'] = navlist return metadata - def build_navigation_doc(self, outdir: str = None, outname: str = 'nav.xhtml') -> None: + def build_navigation_doc(self) -> None: """Write the metainfo file nav.xhtml.""" - if outdir: - warnings.warn('The arguments of Epub3Builder.build_navigation_doc() ' - 'is deprecated.', RemovedInSphinx40Warning, stacklevel=2) - else: - outdir = self.outdir - - logger.info(__('writing %s file...'), outname) + logger.info(__('writing nav.xhtml file...')) if self.config.epub_tocscope == 'default': doctree = self.env.get_and_resolve_doctree( @@ -182,13 +174,12 @@ class Epub3Builder(_epub_base.EpubBuilder): # 'includehidden' refnodes = self.refnodes navlist = self.build_navlist(refnodes) - copy_asset_file(path.join(self.template_dir, 'nav.xhtml_t'), - path.join(outdir, outname), + copy_asset_file(path.join(self.template_dir, 'nav.xhtml_t'), self.outdir, self.navigation_doc_metadata(navlist)) # Add nav.xhtml to epub file - if outname not in self.files: - self.files.append(outname) + if 'nav.xhtml' not in self.files: + self.files.append('nav.xhtml') def validate_config_values(app: Sphinx) -> None: |