Commits

Jon Waltman committed 38b1022

Remove unused imports and clean up

  • Participants
  • Parent commits e820b79

Comments (0)

Files changed (3)

                                           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)))))

File sphinx/quickstart.py

 # (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.

File sphinx/writers/texinfo.py

     :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 = """\
 @c %%** end of user preamble
 
 @ifnottex
-@node Top,,(DIR),(DIR)
+@node Top
 @top %(title)s
 @end ifnottex
 
         )
 
     settings_defaults = {}
+    settings_default_overrides = {'docinfo_xform': 0}
 
     output = None
 
         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)
                 # 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
             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'
         # 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:]
     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):
                        '@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')
-    visit_danger = _make_visit_admonition('Danger')
-    visit_error = _make_visit_admonition('Error')
+    visit_caution   = _make_visit_admonition('Caution')
+    visit_danger    = _make_visit_admonition('Danger')
+    visit_error     = _make_visit_admonition('Error')
     visit_important = _make_visit_admonition('Important')
-    visit_note = _make_visit_admonition('Note')
-    visit_tip = _make_visit_admonition('Tip')
-    visit_hint = _make_visit_admonition('Hint')
-    visit_warning = _make_visit_admonition('Warning')
+    visit_note      = _make_visit_admonition('Note')
+    visit_tip       = _make_visit_admonition('Tip')
+    visit_hint      = _make_visit_admonition('Hint')
+    visit_warning   = _make_visit_admonition('Warning')
 
     depart_attention = depart_admonition
-    depart_caution = depart_admonition
-    depart_danger = depart_admonition
-    depart_error = depart_admonition
+    depart_caution   = depart_admonition
+    depart_danger    = depart_admonition
+    depart_error     = depart_admonition
     depart_important = depart_admonition
-    depart_note = depart_admonition
-    depart_tip = depart_admonition
-    depart_hint = depart_admonition
-    depart_warning = depart_admonition
+    depart_note      = depart_admonition
+    depart_tip       = depart_admonition
+    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
                        '---------- 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('<')