[Python-checkins] r58560 - doctools/trunk/sphinx/directives.py doctools/trunk/sphinx/highlighting.py

georg.brandl python-checkins at python.org
Sat Oct 20 15:36:14 CEST 2007


Author: georg.brandl
Date: Sat Oct 20 15:36:14 2007
New Revision: 58560

Modified:
   doctools/trunk/sphinx/directives.py
   doctools/trunk/sphinx/highlighting.py
Log:
Add "cmdoption" directive for command-line options.


Modified: doctools/trunk/sphinx/directives.py
==============================================================================
--- doctools/trunk/sphinx/directives.py	(original)
+++ doctools/trunk/sphinx/directives.py	Sat Oct 20 15:36:14 2007
@@ -299,8 +299,20 @@
                 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 @@
     'cvar',
     # the odd one
     'opcode',
-    # the generic one
+    # the generic ones
+    'cmdoption', # for command line options
     'describe',
 ]
 

Modified: doctools/trunk/sphinx/highlighting.py
==============================================================================
--- doctools/trunk/sphinx/highlighting.py	(original)
+++ doctools/trunk/sphinx/highlighting.py	Sat Oct 20 15:36:14 2007
@@ -22,7 +22,7 @@
     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 @@
         styles.update({
             Generic.Output: 'italic #333',
             Comment: 'italic #408090',
+            Number: '#208050',
         })
 
     lexers = defaultdict(TextLexer,


More information about the Python-checkins mailing list