summaryrefslogtreecommitdiff
path: root/sphinx/directives.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-10-20 13:36:14 +0000
committerGeorg Brandl <georg@python.org>2007-10-20 13:36:14 +0000
commitdad5ee1eaa6502a8495a240081c9a068ea5661fa (patch)
treef1982ce7c114731f8dc25899cadd75767b24e8c0 /sphinx/directives.py
parent11a23a6a3aca5eab2c8e13ddd39bb73255345a74 (diff)
downloadsphinx-git-dad5ee1eaa6502a8495a240081c9a068ea5661fa.tar.gz
Add "cmdoption" directive for command-line options.
Diffstat (limited to 'sphinx/directives.py')
-rw-r--r--sphinx/directives.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/sphinx/directives.py b/sphinx/directives.py
index 890b3da14..8df7e9b6b 100644
--- a/sphinx/directives.py
+++ b/sphinx/directives.py
@@ -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',
]