Commits

Anonymous committed b0fe1c1

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

  • Participants
  • Parent commits 7895472

Comments (0)

Files changed (3)

File doc/domains.rst

    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

File sphinx/domains/javascript.py

             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(),
     }

File tests/root/objects.txt

 
 .. js:function:: foo()
 
+.. js:data:: bar
+
 
 References
 ==========
 :js:func:`foo()`
 :js:func:`foo`
 
+:js:data:`bar`
+
 
 Others
 ======