Commits

Georg Brandl committed 13d5a61

#571: Implement ``~`` cross-reference prefix for the C domain.

Comments (0)

Files changed (2)

 Release 1.0.7 (in development)
 ==============================
 
+* #571: Implement ``~`` cross-reference prefix for the C domain.
+
 * Fix regression of LaTeX output with the fix of #556.
 
 * #568: Fix lookup of class attribute documentation on descriptors

sphinx/domains/c.py

             self.indexnode['entries'].append(('single', indextext, name, name))
 
 
+class CXRefRole(XRefRole):
+    def process_link(self, env, refnode, has_explicit_title, title, target):
+        if not has_explicit_title:
+            target = target.lstrip('~') # only has a meaning for the title
+            # if the first character is a tilde, don't display the module/class
+            # parts of the contents
+            if title[0:1] == '~':
+                title = title[1:]
+                dot = title.rfind('.')
+                if dot != -1:
+                    title = title[dot+1:]
+        return title, target
+
+
 class CDomain(Domain):
     """C language domain."""
     name = 'c'
         'var':      CObject,
     }
     roles = {
-        'func' :  XRefRole(fix_parens=True),
-        'member': XRefRole(),
-        'macro':  XRefRole(),
-        'data':   XRefRole(),
-        'type':   XRefRole(),
+        'func' :  CXRefRole(fix_parens=True),
+        'member': CXRefRole(),
+        'macro':  CXRefRole(),
+        'data':   CXRefRole(),
+        'type':   CXRefRole(),
     }
     initial_data = {
         'objects': {},  # fullname -> docname, objtype
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 ProjectModifiedEvent.java.
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.