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

georg.brandl python-checkins at python.org
Tue Mar 25 21:59:02 CET 2008


Author: georg.brandl
Date: Tue Mar 25 21:59:01 2008
New Revision: 61911

Modified:
   doctools/trunk/sphinx/directives.py
Log:
Strip parentheses for C function pointer type names.


Modified: doctools/trunk/sphinx/directives.py
==============================================================================
--- doctools/trunk/sphinx/directives.py	(original)
+++ doctools/trunk/sphinx/directives.py	Tue Mar 25 21:59:01 2008
@@ -191,6 +191,7 @@
         (\( [^()]+ \)) \s* # name in parentheses
         \( (.*) \) $       # arguments
     ''', re.VERBOSE)
+c_funcptr_name_re = re.compile(r'^\(\s*\*\s*(.*?)\s*\)$')
 
 # RE to split at word boundaries
 wsplit_re = re.compile(r'(\W+)')
@@ -224,6 +225,10 @@
     signode += addnodes.desc_type("", "")
     parse_c_type(signode[-1], rettype)
     signode += addnodes.desc_name(name, name)
+    # clean up parentheses from canonical name
+    m = c_funcptr_name_re.match(name)
+    if m:
+        name = m.group(1)
     if not arglist:
         if desctype == 'cfunction':
             # for functions, add an empty parameter list


More information about the Python-checkins mailing list