Anonymous avatar Anonymous committed 0ef6502

Strip parentheses during conversion, add them during build.

Comments (0)

Files changed (4)


 # typographically correct entities.
 use_smartypants = True
-# If true, trailing '()' will be stripped from :func: etc. cross-references.
-strip_trailing_parentheses = False
+# If true, '()' will be appended to :func: etc. cross-reference text.
+add_function_parentheses = True


    If true, use SmartyPants to convert quotes and dashes to the typographically
    correct entities.
-strip_trailing_parentheses : bool
-   If true, trailing parentheses will be stripped from ``:func:`` etc.
-   crossreferences.
+add_function_parentheses : bool
+   If true, ``()`` will be appended to the content of ``:func:``, ``:meth:`` and
+   ``:cfunc:`` cross-references.


 wordchars_e = alphanum + u'+`(-'
 bad_markup_re = re.compile(r'(:[a-zA-Z0-9_-]+:)?(`{1,2})[ ]*(.+?)[ ]*(\2)')
 quoted_code_re = re.compile(r'\\`(``.+?``)\'')
+paren_re = re.compile(r':(func|meth|cfunc):`(.*?)\(\)`')
 def repair_bad_inline_markup(text):
     # remove quoting from `\code{x}'
     # special: literal backquotes
     xtext = xtext.replace('``````', '\x02')
+    # remove () from function markup
+    xtext = paren_re.sub(r':\1:`\2`', xtext)
     ntext = []
     lasti = 0
     l = len(xtext)
     # 'token' is the default role inside 'productionlist' directives
     if typ == '':
         typ = 'token'
-    if env.config.get('strip_trailing_parentheses', False):
-        if text[-2:] == '()':
-            text = text[:-2]
+    if typ in ('func', 'meth', 'cfunc') and \
+           env.config.get('add_function_parentheses', True):
+        text += '()'
     pnode = addnodes.pending_xref(rawtext)
     pnode['reftype'] = typ
     pnode['reftarget'] = ws_re.sub('', text)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.