Created
October 7, 2011 18:03
-
-
Save brantfaircloth/1270954 to your computer and use it in GitHub Desktop.
Wrapping option list in docutils/sphinx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Writer(writers.Writer): | |
setting_spec = ( | |
('Specify the maximum width (in characters) for options in option ' | |
'lists. Longer options will span an entire row of the table used ' | |
'to render the option list. Default is 14 characters. ' | |
'Use 0 for "no limit".', | |
['--option-limit'], | |
{'default': 4, 'metavar': '<level>', | |
'validator': frontend.validate_nonnegative_int}) | |
) | |
class HTMLTranslator(nodes.NodeVisitor): | |
def visit_option_group(self, node): | |
atts = {} | |
if ( self.settings.option_limit | |
and len(node.astext()) >= self.settings.option_limit): | |
atts['colspan'] = 2 | |
self.context.append('</tr>\n<tr><td> </td>') | |
else: | |
self.context.append('') | |
self.body.append( | |
self.starttag(node, 'td', CLASS='option-group', **atts)) | |
self.body.append('<kbd>') | |
self.context.append(0) # count number of options |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment