summaryrefslogtreecommitdiff
path: root/sphinx/writers/text.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2018-12-03 00:43:39 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2018-12-03 01:11:06 +0900
commitfd73a169c7abe649aab2fcf12d192f44822bbef2 (patch)
tree5609270523a017b24181670103d5f23d4db2688c /sphinx/writers/text.py
parent8068cef267d771cd933316ba93b13665e8282c9d (diff)
downloadsphinx-git-fd73a169c7abe649aab2fcf12d192f44822bbef2.tar.gz
Fix annotations (minor fixes)
Diffstat (limited to 'sphinx/writers/text.py')
-rw-r--r--sphinx/writers/text.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/sphinx/writers/text.py b/sphinx/writers/text.py
index dc077e385..3e5961753 100644
--- a/sphinx/writers/text.py
+++ b/sphinx/writers/text.py
@@ -13,6 +13,7 @@ import os
import re
import textwrap
from itertools import groupby, chain
+from typing import Iterable, cast
from docutils import nodes, writers
from docutils.utils import column_width
@@ -387,7 +388,7 @@ class TextWriter(writers.Writer):
# type: () -> None
visitor = self.builder.create_translator(self.document, self.builder)
self.document.walkabout(visitor)
- self.output = visitor.body
+ self.output = cast(TextTranslator, visitor).body
class TextTranslator(nodes.NodeVisitor):
@@ -691,11 +692,12 @@ class TextTranslator(nodes.NodeVisitor):
# type: (addnodes.productionlist) -> None
self.new_state()
names = []
- for production in node:
+ productionlist = cast(Iterable[addnodes.production], node)
+ for production in productionlist:
names.append(production['tokenname'])
maxlen = max(len(name) for name in names)
lastname = None
- for production in node:
+ for production in productionlist:
if production['tokenname']:
self.add_text(production['tokenname'].ljust(maxlen) + ' ::=')
lastname = production['tokenname']
@@ -871,9 +873,10 @@ class TextTranslator(nodes.NodeVisitor):
def visit_acks(self, node):
# type: (addnodes.acks) -> None
+ bullet_list = cast(nodes.bullet_list, node[0])
+ list_items = cast(Iterable[nodes.list_item], bullet_list)
self.new_state(0)
- self.add_text(', '.join(n.astext() for n in node.children[0].children) +
- '.')
+ self.add_text(', '.join(n.astext() for n in list_items) + '.')
self.end_state()
raise nodes.SkipNode