summaryrefslogtreecommitdiff
path: root/sphinx/domains/javascript.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-09-19 12:59:18 +0200
committerGeorg Brandl <georg@python.org>2014-09-19 12:59:18 +0200
commitc3eb669f8aa67afff8aaf6f069b186869bd31158 (patch)
tree232ce929b08fdf98d9d5d229c27238fe67091a47 /sphinx/domains/javascript.py
parent430be0496ad68af31c052cf2367c0c8197a19cd6 (diff)
downloadsphinx-git-c3eb669f8aa67afff8aaf6f069b186869bd31158.tar.gz
Added the `any` role that can be used to find a cross-reference of
*any* type in *any* domain. Custom domains should implement the new `~Domain.resolve_any_xref` method to make this work properly.
Diffstat (limited to 'sphinx/domains/javascript.py')
-rw-r--r--sphinx/domains/javascript.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/sphinx/domains/javascript.py b/sphinx/domains/javascript.py
index 2718b8727..dc65b2a39 100644
--- a/sphinx/domains/javascript.py
+++ b/sphinx/domains/javascript.py
@@ -179,7 +179,7 @@ class JavaScriptDomain(Domain):
'attr': JSXRefRole(),
}
initial_data = {
- 'objects': {}, # fullname -> docname, objtype
+ 'objects': {}, # fullname -> docname, objtype
}
def clear_doc(self, docname):
@@ -214,6 +214,16 @@ class JavaScriptDomain(Domain):
return make_refnode(builder, fromdocname, obj[0],
name.replace('$', '_S_'), contnode, name)
+ def resolve_any_xref(self, env, fromdocname, builder, target, node,
+ contnode):
+ objectname = node.get('js:object') # not likely
+ name, obj = self.find_obj(env, objectname, target, None, 1)
+ if not obj:
+ return []
+ return [('js:' + self.role_for_objtype(obj[1]),
+ make_refnode(builder, fromdocname, obj[0],
+ name.replace('$', '_S_'), contnode, name))]
+
def get_objects(self):
for refname, (docname, type) in list(self.data['objects'].items()):
yield refname, refname, type, docname, \