diff options
author | Daniel Neuhäuser <ich@danielneuhaeuser.de> | 2010-03-30 19:14:01 +0000 |
---|---|---|
committer | Daniel Neuhäuser <ich@danielneuhaeuser.de> | 2010-03-30 19:14:01 +0000 |
commit | 25b8e87feea241a15f44b1529e03e271ef5bd38e (patch) | |
tree | a6b59a2b356b09686ada6c48dea5392582d6fa97 | |
parent | 9837a082947f2d308f6e65b893590f6f86687e07 (diff) | |
download | sphinx-git-25b8e87feea241a15f44b1529e03e271ef5bd38e.tar.gz |
Added a :js:func: role to refer to functions described with the js:function:: directive.
-rw-r--r-- | doc/domains.rst | 4 | ||||
-rw-r--r-- | sphinx/domains/javascript.py | 4 | ||||
-rw-r--r-- | tests/root/objects.txt | 3 |
3 files changed, 11 insertions, 0 deletions
diff --git a/doc/domains.rst b/doc/domains.rst index 95b603b8f..018a87596 100644 --- a/doc/domains.rst +++ b/doc/domains.rst @@ -556,3 +556,7 @@ The JavaScript domain (name **js**) provides the following directives: Describe a JavaScript function. If you want to document optional arguments use square brackets as :ref:`documented <signatures>` for Python signatures. + +These roles are provided to refer to the described objects: + +.. role:: js:func diff --git a/sphinx/domains/javascript.py b/sphinx/domains/javascript.py index 6da878838..4768a3d64 100644 --- a/sphinx/domains/javascript.py +++ b/sphinx/domains/javascript.py @@ -15,6 +15,7 @@ from sphinx.domains import Domain, ObjType from sphinx.locale import l_, _ from sphinx.directives import ObjectDescription from sphinx.domains.python import py_paramlist_re as js_paramlist_re +from sphinx.roles import XRefRole js_sig_re = re.compile(r'(\w+)\s*\((.*)\)') @@ -63,3 +64,6 @@ class JavaScriptDomain(Domain): directives = { "function": JSFunction, } + roles = { + "func": XRefRole(fix_parens=True), + } diff --git a/tests/root/objects.txt b/tests/root/objects.txt index 87db65e98..87d339529 100644 --- a/tests/root/objects.txt +++ b/tests/root/objects.txt @@ -90,6 +90,9 @@ With target: :c:func:`Sphinx_DoSomething()` (parentheses are handled), Without target: :c:func:`CFunction`. :c:func:`!malloc`. +:js:func:`foo()` +:js:func:`foo` + Others ====== |