Commits

Georg Brandl  committed 8e63273

#29: fix some option list issues, in HTML, LaTeX and text writers.

  • Participants
  • Parent commits bad1897

Comments (0)

Files changed (7)

 Bugs fixed
 ----------
 
+* Support option lists in the text writer.  Make sure that dashes
+  introducing long option names are not contracted to en-dashes.
+
 * Support the "scale" option for images in HTML output.
 
 * Properly escape quotes in HTML help attribute values.

File sphinx/htmlwriter.py

         finally:
             self.no_smarty -= 1
 
+    def visit_option(self, node):
+        self.no_smarty += 1
+        HTMLTranslator.visit_option(self, node)
+    def depart_option(self, node):
+        self.no_smarty -= 1
+        HTMLTranslator.depart_option(self, node)
+
     def bulk_text_processor(self, text):
         if self.no_smarty <= 0:
             return sphinx_smarty_pants(text)

File sphinx/latexwriter.py

         pass
 
     def visit_option_string(self, node):
-        pass
-    def depart_option_string(self, node):
-        pass
+        ostring = node.astext()
+        self.body.append(self.encode(ostring.replace('--', u'--')))
+        raise nodes.SkipNode
 
     def visit_description(self, node):
         self.body.append( ' ' )

File sphinx/textwriter.py

     def visit_label(self, node):
         raise nodes.SkipNode
 
+    # XXX: option list could use some better styling
+
+    def visit_option_list(self, node):
+        pass
+    def depart_option_list(self, node):
+        pass
+
+    def visit_option_list_item(self, node):
+        self.new_state(0)
+    def depart_option_list_item(self, node):
+        self.end_state()
+
+    def visit_option_group(self, node):
+        self._firstoption = True
+    def depart_option_group(self, node):
+        self.add_text('     ')
+
+    def visit_option(self, node):
+        if self._firstoption:
+            self._firstoption = False
+        else:
+            self.add_text(', ')
+    def depart_option(self, node):
+        pass
+
+    def visit_option_string(self, node):
+        pass
+    def depart_option_string(self, node):
+        pass
+
+    def visit_option_argument(self, node):
+        self.add_text(node['delimiter'])
+    def depart_option_argument(self, node):
+        pass
+
+    def visit_description(self, node):
+        pass
+    def depart_description(self, node):
+        pass
+
     def visit_tabular_col_spec(self, node):
         raise nodes.SkipNode
 

File sphinx/util/texescape.py

     (u'±', ur'\(\pm\)'),
     (u'→', ur'\(\rightarrow\)'),
     (u'‣', ur'\(\rightarrow\)'),
+    # used to separate -- in options
+    (u'', ur'{}'),
     # map some special Unicode characters to similar ASCII ones
     (u'─', ur'-'),
     (u'⎽', ur'\_'),

File tests/root/markup.txt

 
 This tests :CLASS:`role names in uppercase`.
 
+Option list:
+
+-h              help
+--help          also help
+
 .. centered:: LICENSE AGREEMENT
 
 .. acks::

File tests/test_build.py

         ".//meta[@name='keywords'][@content='docs, sphinx']": '',
         ".//a[@href='contents.html#ref1']": '',
         ".//div[@id='label']": '',
+        ".//span[@class='option']": '--help',
     },
     'desc.html': {
         ".//dt[@id='mod.Cls.meth1']": '',