Add "cmdoption" directive for command-line options.

This commit is contained in:
Georg Brandl 2007-10-20 13:36:14 +00:00
parent 11a23a6a3a
commit dad5ee1eaa
2 changed files with 17 additions and 3 deletions

View File

@ -299,8 +299,20 @@ def desc_directive(desctype, arguments, options, content, lineno,
name = parse_c_signature(signode, sig, desctype) name = parse_c_signature(signode, sig, desctype)
elif desctype == 'opcode': elif desctype == 'opcode':
name = parse_opcode_signature(signode, sig, desctype) name = parse_opcode_signature(signode, sig, desctype)
elif desctype == 'cmdoption':
# TODO: add custom parsing for <optional> parts?
signode.clear()
signode += addnodes.desc_name(sig, sig)
if not noindex:
targetname = 'cmdoption-%s' % env.index_num
env.index_num += 1
signode['ids'].append(targetname)
state.document.note_explicit_target(signode)
env.note_index_entry('pair', 'command line option; %s' % sig,
targetname, targetname)
continue
else: else:
# describe: use generic fallback # for "describe": use generic fallback
raise ValueError raise ValueError
except ValueError, err: except ValueError, err:
signode.clear() signode.clear()
@ -364,7 +376,8 @@ desctypes = [
'cvar', 'cvar',
# the odd one # the odd one
'opcode', 'opcode',
# the generic one # the generic ones
'cmdoption', # for command line options
'describe', 'describe',
] ]

View File

@ -22,7 +22,7 @@ try:
from pygments.filters import ErrorToken from pygments.filters import ErrorToken
from pygments.style import Style from pygments.style import Style
from pygments.styles.friendly import FriendlyStyle from pygments.styles.friendly import FriendlyStyle
from pygments.token import Generic, Comment from pygments.token import Generic, Comment, Number
except ImportError: except ImportError:
pygments = None pygments = None
else: else:
@ -38,6 +38,7 @@ else:
styles.update({ styles.update({
Generic.Output: 'italic #333', Generic.Output: 'italic #333',
Comment: 'italic #408090', Comment: 'italic #408090',
Number: '#208050',
}) })
lexers = defaultdict(TextLexer, lexers = defaultdict(TextLexer,