refactor: special rubric for footnotes

This commit is contained in:
Takeshi KOMIYA 2018-12-09 00:35:46 +09:00
parent 385d6a6572
commit 389f756f88
7 changed files with 11 additions and 12 deletions

View File

@ -330,8 +330,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
fn = fns[-1]
return fn.parent, fn.parent.index(fn) + 1
for node in tree.traverse(nodes.rubric):
if len(node.children) == 1 and \
node.children[0].astext() == FOOTNOTES_RUBRIC_NAME:
if len(node) == 1 and node.astext() == FOOTNOTES_RUBRIC_NAME:
return node.parent, node.parent.index(node) + 1
doc = tree.traverse(nodes.document)[0]
rub = nodes.rubric()

View File

@ -1230,8 +1230,7 @@ class LaTeXTranslator(SphinxTranslator):
def visit_rubric(self, node):
# type: (nodes.rubric) -> None
if len(node.children) == 1 and node.children[0].astext() in \
('Footnotes', _('Footnotes')):
if len(node) == 1 and node.astext() in ('Footnotes', _('Footnotes')):
raise nodes.SkipNode
self.body.append('\\subsubsection*{')
self.context.append('}\n')

View File

@ -268,12 +268,9 @@ class ManualPageTranslator(SphinxTranslator, BaseTranslator):
def visit_rubric(self, node):
# type: (nodes.rubric) -> None
self.ensure_eol()
if len(node.children) == 1:
rubtitle = node.children[0].astext()
if rubtitle in ('Footnotes', _('Footnotes')):
self.body.append('.SH ' + self.deunicode(rubtitle).upper() +
'\n')
raise nodes.SkipNode
if len(node) == 1 and node.astext() in ('Footnotes', _('Footnotes')):
self.body.append('.SH ' + self.deunicode(node.astext()).upper() + '\n')
raise nodes.SkipNode
else:
self.body.append('.sp\n')

View File

@ -669,8 +669,7 @@ class TexinfoTranslator(SphinxTranslator):
def visit_rubric(self, node):
# type: (nodes.rubric) -> None
if len(node.children) == 1 and node.children[0].astext() in \
('Footnotes', _('Footnotes')):
if len(node) == 1 and node.astext() in ('Footnotes', _('Footnotes')):
raise nodes.SkipNode
try:
rubric = self.rubrics[self.section_level]

View File

@ -146,6 +146,8 @@ def test_writer(app, status, warning):
'\\label{\\detokenize{markup:id11}}'
'\\end{wrapfigure}' in result)
assert 'Footnotes' not in result
@pytest.mark.sphinx('latex', testroot='warnings', freshenv=True)
def test_latex_warnings(app, status, warning):

View File

@ -29,6 +29,8 @@ def test_all(app, status, warning):
assert '\n.B term1\n' in content
assert '\nterm2 (\\fBstronged partially\\fP)\n' in content
assert 'Footnotes' not in content
def test_default_man_pages():
config = Config({'master_doc': 'index',

View File

@ -52,6 +52,7 @@ def test_texinfo(app, status, warning):
assert ('@anchor{markup doc}@anchor{11}'
'@anchor{markup id1}@anchor{12}'
'@anchor{markup testing-various-markup}@anchor{13}' in result)
assert 'Footnotes' not in result
# now, try to run makeinfo over it
cwd = os.getcwd()
os.chdir(app.outdir)