mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#29: fix some option list issues, in HTML, LaTeX and text writers.
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -130,6 +130,9 @@ New features added
|
||||
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.
|
||||
|
||||
@@ -447,6 +447,13 @@ class SmartyPantsHTMLTranslator(HTMLTranslator):
|
||||
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)
|
||||
|
||||
@@ -1069,9 +1069,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
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( ' ' )
|
||||
|
||||
@@ -284,6 +284,46 @@ class TextTranslator(nodes.NodeVisitor):
|
||||
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
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ tex_replacements = [
|
||||
(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'\_'),
|
||||
|
||||
@@ -110,6 +110,11 @@ This is a side note.
|
||||
|
||||
This tests :CLASS:`role names in uppercase`.
|
||||
|
||||
Option list:
|
||||
|
||||
-h help
|
||||
--help also help
|
||||
|
||||
.. centered:: LICENSE AGREEMENT
|
||||
|
||||
.. acks::
|
||||
|
||||
@@ -59,6 +59,7 @@ HTML_XPATH = {
|
||||
".//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']": '',
|
||||
|
||||
Reference in New Issue
Block a user