mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Added a js:data directive/role to describe/refer to global variables/constants.
This commit is contained in:
@@ -557,6 +557,11 @@ The JavaScript domain (name **js**) provides the following directives:
|
|||||||
arguments use square brackets as :ref:`documented <signatures>` for Python
|
arguments use square brackets as :ref:`documented <signatures>` for Python
|
||||||
signatures.
|
signatures.
|
||||||
|
|
||||||
|
.. directive:: .. js:data:: name
|
||||||
|
|
||||||
|
Describe a global variable or constant.
|
||||||
|
|
||||||
These roles are provided to refer to the described objects:
|
These roles are provided to refer to the described objects:
|
||||||
|
|
||||||
.. role:: js:func
|
.. role:: js:func
|
||||||
|
js:data
|
||||||
|
|||||||
@@ -54,16 +54,24 @@ class JSFunction(ObjectDescription):
|
|||||||
raise ValueError()
|
raise ValueError()
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
class JSData(ObjectDescription):
|
||||||
|
"""Describes a global variable or constant."""
|
||||||
|
def handle_signature(self, sig, signode):
|
||||||
|
return sig.strip()
|
||||||
|
|
||||||
class JavaScriptDomain(Domain):
|
class JavaScriptDomain(Domain):
|
||||||
"""JavaScript language domain."""
|
"""JavaScript language domain."""
|
||||||
name = "js"
|
name = "js"
|
||||||
label= "JavaScript"
|
label= "JavaScript"
|
||||||
object_types = {
|
object_types = {
|
||||||
"function": ObjType(l_("js function"), "func"),
|
"function": ObjType(l_("js function"), "func"),
|
||||||
|
"data": ObjType(l_("js data"), "data"),
|
||||||
}
|
}
|
||||||
directives = {
|
directives = {
|
||||||
"function": JSFunction,
|
"function": JSFunction,
|
||||||
|
"data": JSData,
|
||||||
}
|
}
|
||||||
roles = {
|
roles = {
|
||||||
"func": XRefRole(fix_parens=True),
|
"func": XRefRole(fix_parens=True),
|
||||||
|
"data": XRefRole(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ Javascript items
|
|||||||
|
|
||||||
.. js:function:: foo()
|
.. js:function:: foo()
|
||||||
|
|
||||||
|
.. js:data:: bar
|
||||||
|
|
||||||
|
|
||||||
References
|
References
|
||||||
==========
|
==========
|
||||||
@@ -93,6 +95,8 @@ Without target: :c:func:`CFunction`. :c:func:`!malloc`.
|
|||||||
:js:func:`foo()`
|
:js:func:`foo()`
|
||||||
:js:func:`foo`
|
:js:func:`foo`
|
||||||
|
|
||||||
|
:js:data:`bar`
|
||||||
|
|
||||||
|
|
||||||
Others
|
Others
|
||||||
======
|
======
|
||||||
|
|||||||
Reference in New Issue
Block a user