Georg Brandl avatar Georg Brandl committed 8ce93b3

Review of JS domain. Adapt coding style a bit.

Comments (0)

Files changed (3)

   component of the target.  For example, ``:py:meth:`~Queue.Queue.get``` will
   refer to ``Queue.Queue.get`` but only display ``get`` as the link text.
 
+
 The Python Domain
 -----------------
 
 
          You can set this variable to select a paper size.
 
+
 The JavaScript Domain
 ---------------------
 
 
 .. directive:: .. js:function:: name(signature)
 
-   Describes a JavaScript function, method or constructor. If you want to
-   describe arguments as optional use square brackets as
-   :ref:`documented <signatures>` for Python signatures.
+   Describes a JavaScript function, method or constructor.  If you want to
+   describe arguments as optional use square brackets as :ref:`documented
+   <signatures>` for Python signatures.
 
    You can use fields to give more details about arguments and their expected
    types, errors which may be thrown by the function, and the value being
    returned::
 
-        .. js:function:: $.getJSON(href, callback[, errback])
+      .. js:function:: $.getJSON(href, callback[, errback])
 
-           :param string href: An URI to the location of the resource.
-           :param callback: Get's called with the object.
-           :param errback:
-                Get's called in case the request fails. And a lot of other
-                text so we need multiple lines
-           :throws SomeError: For whatever reason in that case.
-           :returns: Something
+         :param string href: An URI to the location of the resource.
+         :param callback: Get's called with the object.
+         :param errback:
+             Get's called in case the request fails. And a lot of other
+             text so we need multiple lines
+         :throws SomeError: For whatever reason in that case.
+         :returns: Something
 
    This is rendered as:
 
-         .. js:function:: $.getJSON(href, callback[, errback])
+      .. js:function:: $.getJSON(href, callback[, errback])
 
-           :param string href: An URI to the location of the resource.
-           :param callback: Get's called with the object.
-           :param errback:
-                 Get's called in case the request fails. And a lot of other
-                 text so we need multiple lines.
-           :throws SomeError: For whatever reason in that case.
-           :returns: Something
+        :param string href: An URI to the location of the resource.
+        :param callback: Get's called with the object.
+        :param errback:
+            Get's called in case the request fails. And a lot of other
+            text so we need multiple lines.
+        :throws SomeError: For whatever reason in that case.
+        :returns: Something
 
 .. directive:: .. js:data:: name
 
 
 .. directive:: .. js:attribute:: object.name
 
-   Describes the attribute `name` of `object`.
+   Describes the attribute *name* of *object*.
 
 These roles are provided to refer to the described objects:
 

sphinx/domains/__init__.py

     'py': PythonDomain,
     'c': CDomain,
     'cpp': CPPDomain,
-    "js": JavaScriptDomain,
+    'js': JavaScriptDomain,
 }

sphinx/domains/javascript.py

 from sphinx.util.nodes import make_refnode
 from sphinx.util.docfields import Field, GroupedField, TypedField
 
+
 js_sig_re = re.compile(
     r'''([^ .]+\.)? # object name
         ([^ .]+\s*) # name
         \((.*)\)$   # arguments
 ''', re.VERBOSE)
 
+
 class JSObject(ObjectDescription):
     """
     Description of a JavaScript object.
             return _('%s (%s attribute)') % (name, obj)
         return ''
 
+
 class JSCallable(JSObject):
     """Description of a JavaScript function, method or constructor."""
     has_arguments = True
 
     doc_field_types = [
-        TypedField("arguments", label=l_('Arguments'),
+        TypedField('arguments', label=l_('Arguments'),
                    names=('argument', 'arg', 'parameter', 'param'),
                    typerolename='func', typenames=('paramtype', 'type')),
         GroupedField('errors', label=l_('Throws'), rolename='err',
               names=('returns', 'return')),
     ]
 
+
 class JSXRefRole(XRefRole):
     def process_link(self, env, refnode, has_explicit_title, title, target):
         # basically what sphinx.domains.python.PyXRefRole does
             refnode['refspecific'] = True
         return title, target
 
+
 class JavaScriptDomain(Domain):
     """JavaScript language domain."""
     name = 'js'
-    label= 'JavaScript'
+    label = 'JavaScript'
     # if you add a new object type make sure to edit JSObject.get_index_string
     object_types = {
-        'function'  : ObjType(l_('js function'), 'func'),
-        'data'      : ObjType(l_('js data'), 'data'),
-        'attribute' : ObjType(l_('js attribute'), 'attr'),
+        'function':  ObjType(l_('JavaScript function'),  'func'),
+        'data':      ObjType(l_('JavaScript data'),      'data'),
+        'attribute': ObjType(l_('JavaScript attribute'), 'attr'),
     }
     directives = {
-        'function'  : JSCallable,
-        'data'      : JSObject,
-        'attribute' : JSObject,
+        'function':  JSCallable,
+        'data':      JSObject,
+        'attribute': JSObject,
     }
     roles = {
         'func': JSXRefRole(fix_parens=True),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.