mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add "cmdoption" directive for command-line options.
This commit is contained in:
parent
11a23a6a3a
commit
dad5ee1eaa
@ -299,8 +299,20 @@ def desc_directive(desctype, arguments, options, content, lineno,
|
||||
name = parse_c_signature(signode, sig, desctype)
|
||||
elif desctype == 'opcode':
|
||||
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:
|
||||
# describe: use generic fallback
|
||||
# for "describe": use generic fallback
|
||||
raise ValueError
|
||||
except ValueError, err:
|
||||
signode.clear()
|
||||
@ -364,7 +376,8 @@ desctypes = [
|
||||
'cvar',
|
||||
# the odd one
|
||||
'opcode',
|
||||
# the generic one
|
||||
# the generic ones
|
||||
'cmdoption', # for command line options
|
||||
'describe',
|
||||
]
|
||||
|
||||
|
@ -22,7 +22,7 @@ try:
|
||||
from pygments.filters import ErrorToken
|
||||
from pygments.style import Style
|
||||
from pygments.styles.friendly import FriendlyStyle
|
||||
from pygments.token import Generic, Comment
|
||||
from pygments.token import Generic, Comment, Number
|
||||
except ImportError:
|
||||
pygments = None
|
||||
else:
|
||||
@ -38,6 +38,7 @@ else:
|
||||
styles.update({
|
||||
Generic.Output: 'italic #333',
|
||||
Comment: 'italic #408090',
|
||||
Number: '#208050',
|
||||
})
|
||||
|
||||
lexers = defaultdict(TextLexer,
|
||||
|
Loading…
Reference in New Issue
Block a user