mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Remove unused imports and clean up
This commit is contained in:
parent
1a5f00d83c
commit
464fee8523
@ -205,14 +205,14 @@ your start-up file, ``~/.emacs.d/init.el``.
|
||||
activate)
|
||||
"Hack to make `Info-hide-note-references' buffer-local and
|
||||
automatically set to `hide' iff it can be determined that this file
|
||||
was created from a Texinfo file generated by Sphinx."
|
||||
was created from a Texinfo file generated by Docutils or Sphinx."
|
||||
(set (make-local-variable 'Info-hide-note-references)
|
||||
(default-value 'Info-hide-note-references))
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen) (goto-char (point-min))
|
||||
(when (re-search-forward
|
||||
"^Generated by Sphinx"
|
||||
"^Generated by \\(Sphinx\\|Docutils\\)"
|
||||
(save-excursion (search-forward "" nil t)) t)
|
||||
(set (make-local-variable 'Info-hide-note-references)
|
||||
'hide)))))
|
||||
|
@ -261,9 +261,8 @@ man_pages = [
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('%(master_str)s', '%(project_fn)s', u'%(project_doc)s',
|
||||
u'%(author_str)s', '%(project_fn)s',
|
||||
'One line description of project.', 'Miscellaneous'),
|
||||
('%(master_str)s', '%(project_fn)s', u'%(project_doc)s', u'%(author_str)s',
|
||||
'%(project_fn)s', 'One line description of project.', 'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
|
@ -9,17 +9,11 @@
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import re
|
||||
import os.path
|
||||
|
||||
import docutils
|
||||
import docutils.utils
|
||||
|
||||
from docutils import nodes, writers, transforms
|
||||
from docutils.transforms import writer_aux
|
||||
from docutils import nodes, writers
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.locale import admonitionlabels, versionlabels
|
||||
from sphinx.locale import versionlabels
|
||||
|
||||
|
||||
TEMPLATE = """\
|
||||
@ -48,7 +42,7 @@ Generated by Sphinx
|
||||
@c %%** end of user preamble
|
||||
|
||||
@ifnottex
|
||||
@node Top,,(DIR),(DIR)
|
||||
@node Top
|
||||
@top %(title)s
|
||||
@end ifnottex
|
||||
|
||||
@ -134,6 +128,7 @@ class TexinfoWriter(writers.Writer):
|
||||
)
|
||||
|
||||
settings_defaults = {}
|
||||
settings_default_overrides = {'docinfo_xform': 0}
|
||||
|
||||
output = None
|
||||
|
||||
@ -143,10 +138,6 @@ class TexinfoWriter(writers.Writer):
|
||||
writers.Writer.__init__(self)
|
||||
self.builder = builder
|
||||
|
||||
def get_transforms(self):
|
||||
trans = writers.Writer.get_transforms(self)
|
||||
return trans + [writer_aux.Admonitions]
|
||||
|
||||
def translate(self):
|
||||
self.visitor = visitor = TexinfoTranslator(self.document, self.builder)
|
||||
self.document.walkabout(visitor)
|
||||
@ -214,6 +205,7 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
||||
# if empty, the title is set to the first section title
|
||||
'title': settings.title,
|
||||
'author': escape_arg(settings.author),
|
||||
# if empty, use basename of input file
|
||||
'filename': settings.texinfo_filename,
|
||||
})
|
||||
# Title
|
||||
@ -222,6 +214,12 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
||||
title = self.document.next_node(nodes.title)
|
||||
title = (title and title.astext()) or '<untitled>'
|
||||
elements['title'] = escape_id(title) or '<untitled>'
|
||||
# Filename
|
||||
if not elements['filename']:
|
||||
elements['filename'] = self.document.get('source') or 'untitled'
|
||||
if elements['filename'][-4:] in ('.txt', '.rst'):
|
||||
elements['filename'] = elements['filename'][:-4]
|
||||
elements['filename'] += '.info'
|
||||
# Direntry
|
||||
if settings.texinfo_dir_entry:
|
||||
elements['direntry'] = ('@dircategory %s\n'
|
||||
@ -272,7 +270,8 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
||||
# Try to find a suitable "Top" node
|
||||
title = self.document.next_node(nodes.title)
|
||||
top = (title and title.parent) or self.document
|
||||
assert isinstance(top, (nodes.document, nodes.section))
|
||||
if not isinstance(top, (nodes.document, nodes.section)):
|
||||
top = self.document
|
||||
if top is not self.document:
|
||||
entries = node_menus[top['node_name']]
|
||||
entries += node_menus['Top'][1:]
|
||||
@ -831,46 +830,6 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
||||
def depart_field_body(self, node):
|
||||
pass
|
||||
|
||||
## Docinfo
|
||||
|
||||
def visit_docinfo(self, node):
|
||||
pass
|
||||
def depart_docinfo(self, node):
|
||||
self.add_text('\n\n')
|
||||
|
||||
def visit_authors(self, node):
|
||||
self.author_level = 0
|
||||
self.add_text('@*Authors: ', fresh=1)
|
||||
def depart_authors(self, node):
|
||||
self.add_text('@*\n')
|
||||
|
||||
def visit_author(self, node):
|
||||
if isinstance(node.parent, nodes.authors):
|
||||
if self.author_level > 0:
|
||||
self.add_text(', ')
|
||||
self.author_level += 1
|
||||
else:
|
||||
self.add_text('@*Author: ', fresh=1)
|
||||
def depart_author(self, node):
|
||||
if not isinstance(node.parent, nodes.authors):
|
||||
self.add_text('\n')
|
||||
|
||||
def _make_visit_docinfo_field(typ):
|
||||
def visit_docinfo_field(self, node):
|
||||
self.add_text('@*%s: ' % typ.capitalize(), fresh=1)
|
||||
return visit_docinfo_field
|
||||
|
||||
visit_organization = _make_visit_docinfo_field('organization')
|
||||
visit_address = _make_visit_docinfo_field('address')
|
||||
visit_contact = _make_visit_docinfo_field('contact')
|
||||
visit_version = _make_visit_docinfo_field('version')
|
||||
visit_revision = _make_visit_docinfo_field('revision')
|
||||
visit_status = _make_visit_docinfo_field('status')
|
||||
visit_date = _make_visit_docinfo_field('date')
|
||||
|
||||
visit_copyright = visit_block_quote
|
||||
depart_copyright = depart_block_quote
|
||||
|
||||
## Admonitions
|
||||
|
||||
def visit_admonition(self, node):
|
||||
@ -883,10 +842,11 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
||||
'@end cartouche\n\n')
|
||||
|
||||
def _make_visit_admonition(typ):
|
||||
def visit_admonition(self, node):
|
||||
def visit(self, node):
|
||||
title = escape(typ)
|
||||
self.add_text('\n@cartouche\n'
|
||||
'@quotation %s\n' % escape(typ))
|
||||
return visit_admonition
|
||||
'@quotation %s\n' % title)
|
||||
return visit
|
||||
|
||||
visit_attention = _make_visit_admonition('Attention')
|
||||
visit_caution = _make_visit_admonition('Caution')
|
||||
@ -908,6 +868,12 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
||||
depart_hint = depart_admonition
|
||||
depart_warning = depart_admonition
|
||||
|
||||
## Misc
|
||||
|
||||
def visit_docinfo(self, node):
|
||||
# No 'docinfo_xform'
|
||||
raise nodes.SkipNode
|
||||
|
||||
def visit_topic(self, node):
|
||||
# Ignore TOC's since we have to have a "menu" anyway
|
||||
if 'contents' in node.get('classes', []):
|
||||
@ -1002,25 +968,15 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
||||
'---------- SYSTEM MESSAGE -----------\n')
|
||||
def depart_system_message(self, node):
|
||||
self.rstrip()
|
||||
if node.get('backrefs'):
|
||||
ref = escape_id(node['backrefs'][0])
|
||||
self.add_xref(ref, ref, node)
|
||||
self.add_text('\n------------------------------------\n'
|
||||
'@end format\n')
|
||||
|
||||
def visit_comment(self, node):
|
||||
for line in node.astext().splitlines():
|
||||
# Prevents unintended inclusion of `Local Variables:'
|
||||
# comment blocks used by editors. No harm in leaving it
|
||||
# but it can interfere with the ones we add.
|
||||
if line.strip().lower() == 'local variables:':
|
||||
line = '--IGNORED-- Local Variables'
|
||||
self.add_text('@c %s\n' % line, fresh=1)
|
||||
raise nodes.SkipNode
|
||||
|
||||
def visit_problematic(self, node):
|
||||
if node.get('ids'):
|
||||
self.add_anchor(node['ids'][0], node)
|
||||
self.add_text('>')
|
||||
def depart_problematic(self, node):
|
||||
self.add_text('<')
|
||||
|
Loading…
Reference in New Issue
Block a user