Added a js:data directive/role to describe/refer to global variables/constants.

This commit is contained in:
Daniel Neuhäuser
2010-03-30 19:39:18 +00:00
parent 25b8e87fee
commit 9d53f460ea
3 changed files with 17 additions and 0 deletions

View File

@@ -557,6 +557,11 @@ The JavaScript domain (name **js**) provides the following directives:
arguments use square brackets as :ref:`documented <signatures>` for Python
signatures.
.. directive:: .. js:data:: name
Describe a global variable or constant.
These roles are provided to refer to the described objects:
.. role:: js:func
js:data

View File

@@ -54,16 +54,24 @@ class JSFunction(ObjectDescription):
raise ValueError()
return name
class JSData(ObjectDescription):
"""Describes a global variable or constant."""
def handle_signature(self, sig, signode):
return sig.strip()
class JavaScriptDomain(Domain):
"""JavaScript language domain."""
name = "js"
label= "JavaScript"
object_types = {
"function": ObjType(l_("js function"), "func"),
"data": ObjType(l_("js data"), "data"),
}
directives = {
"function": JSFunction,
"data": JSData,
}
roles = {
"func": XRefRole(fix_parens=True),
"data": XRefRole(),
}

View File

@@ -78,6 +78,8 @@ Javascript items
.. js:function:: foo()
.. js:data:: bar
References
==========
@@ -93,6 +95,8 @@ Without target: :c:func:`CFunction`. :c:func:`!malloc`.
:js:func:`foo()`
:js:func:`foo`
:js:data:`bar`
Others
======