mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Added a :js:func: role to refer to functions described with the js:function:: directive.
This commit is contained in:
parent
9837a08294
commit
25b8e87fee
@ -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
|
||||
|
@ -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),
|
||||
}
|
||||
|
@ -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
|
||||
======
|
||||
|
Loading…
Reference in New Issue
Block a user