Georg Brandl avatar Georg Brandl committed fcc58a0

Fix role class to not take a domain name anymore.

Comments (0)

Files changed (2)

sphinx/domains.py

             return self._role_cache[name]
         if name not in self.roles:
             return None
+        fullname = '%s:%s' % (self.name, name)
         def role_adapter(typ, rawtext, text, lineno, inliner,
                          options={}, content=[]):
-            return self.roles[name](name, rawtext, text, lineno,
+            return self.roles[name](fullname, rawtext, text, lineno,
                                     inliner, options, content)
         self._role_cache[name] = role_adapter
         return role_adapter
             return self._directive_cache[name]
         if name not in self.directives:
             return None
+        fullname = '%s:%s' % (self.name, name)
         BaseDirective = self.directives[name]
         class DirectiveAdapter(BaseDirective):
             def run(self):
-                self.name = name
+                self.name = fullname
                 return BaseDirective.run(self)
         self._directive_cache[name] = DirectiveAdapter
         return DirectiveAdapter
         'attribute': ClassmemberDesc,
     }
     roles = {
-        'data': PyXRefRole('py'),
-        'exc': PyXRefRole('py'),
-        'func': PyXRefRole('py', True),
-        'class': PyXRefRole('py'),
-        'const': PyXRefRole('py'),
-        'attr': PyXRefRole('py'),
-        'meth': PyXRefRole('py', True),
-        'mod': PyXRefRole('py'),
-        'obj': PyXRefRole('py'),
+        'data': PyXRefRole(),
+        'exc': PyXRefRole(),
+        'func': PyXRefRole(fix_parens=True),
+        'class': PyXRefRole(),
+        'const': PyXRefRole(),
+        'attr': PyXRefRole(),
+        'meth': PyXRefRole(fix_parens=True),
+        'mod': PyXRefRole(),
+        'obj': PyXRefRole(),
     }
 
 
         'var': CDesc,
     }
     roles = {
-        'member': XRefRole('c'),
-        'macro': XRefRole('c'),
-        'func' : XRefRole('c', True),
-        'data': XRefRole('c'),
-        'type': XRefRole('c'),
+        'member': XRefRole(),
+        'macro': XRefRole(),
+        'func' : XRefRole(fix_parens=True),
+        'data': XRefRole(),
+        'type': XRefRole(),
     }
 
 
     nodeclass = addnodes.pending_xref
     innernodeclass = nodes.literal
 
-    def __init__(self, domain_name, fix_parens=False, lowercase=False,
+    def __init__(self, fix_parens=False, lowercase=False,
                  nodeclass=None, innernodeclass=None):
-        self.domain_name = domain_name
         self.fix_parens = fix_parens
         if nodeclass is not None:
             self.nodeclass = nodeclass
             typ = env.config.default_role
         else:
             typ = typ.lower()
-        if ":" in typ:
-            domain, role = typ.split(":", 1)
+        if ':' not in typ:
+            domain, role = '', typ
         else:
-            domain, role = self.domain_name, typ
+            domain, role = typ.split(':', 1)
         text = utils.unescape(text)
         # if the first character is a bang, don't cross-reference at all
         if text[0:1] == '!':
 
 
 specific_docroles = {
-    'keyword': XRefRole(''),
-    'ref': XRefRole('', lowercase=True, innernodeclass=nodes.emphasis),
-    'token': XRefRole(''),
-    'term': XRefRole('', lowercase=True, innernodeclass=nodes.emphasis),
-    'option': OptionXRefRole('', innernodeclass=addnodes.literal_emphasis),
-    'doc': XRefRole(''),
-    'download': XRefRole('', nodeclass=addnodes.download_reference),
+    'keyword': XRefRole(),
+    'ref': XRefRole(lowercase=True, innernodeclass=nodes.emphasis),
+    'token': XRefRole(),
+    'term': XRefRole(lowercase=True, innernodeclass=nodes.emphasis),
+    'option': OptionXRefRole(innernodeclass=addnodes.literal_emphasis),
+    'doc': XRefRole(),
+    'download': XRefRole(nodeclass=addnodes.download_reference),
 
     'menuselection': menusel_role,
     'file': emph_literal_role,
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.