summaryrefslogtreecommitdiff
path: root/sphinx/builders/_epub_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/builders/_epub_base.py')
-rw-r--r--sphinx/builders/_epub_base.py33
1 files changed, 26 insertions, 7 deletions
diff --git a/sphinx/builders/_epub_base.py b/sphinx/builders/_epub_base.py
index f86715fcf..0f440dc9b 100644
--- a/sphinx/builders/_epub_base.py
+++ b/sphinx/builders/_epub_base.py
@@ -12,9 +12,8 @@ import html
import os
import re
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 zipfile import ZIP_DEFLATED, ZIP_STORED, ZipFile
from docutils import nodes
@@ -85,10 +84,30 @@ VECTOR_GRAPHICS_EXTENSIONS = ('.svg',)
REFURI_RE = re.compile("([^#:]*#)(.*)")
-ManifestItem = namedtuple('ManifestItem', ['href', 'id', 'media_type'])
-Spine = namedtuple('Spine', ['idref', 'linear'])
-Guide = namedtuple('Guide', ['type', 'title', 'uri'])
-NavPoint = namedtuple('NavPoint', ['navpoint', 'playorder', 'text', 'refuri', 'children'])
+class ManifestItem(NamedTuple):
+ href: str
+ id: str
+ media_type: str
+
+
+class Spine(NamedTuple):
+ idref: str
+ linear: bool
+
+
+class Guide(NamedTuple):
+ type: str
+ title: str
+ uri: str
+
+
+class NavPoint(NamedTuple):
+ navpoint: str
+ playorder: int
+ text: str
+ refuri: str
+ children: List[Any] # mypy does not support recursive types
+ # https://github.com/python/mypy/issues/7069
def sphinx_smarty_pants(t: str, language: str = 'en') -> str:
@@ -635,7 +654,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
the parent node is reinserted in the subnav.
"""
navstack = [] # type: List[NavPoint]
- navstack.append(NavPoint('dummy', '', '', '', []))
+ navstack.append(NavPoint('dummy', 0, '', '', []))
level = 0
lastnode = None
for node in nodes: