mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
It is now possible to use the js:function:: directive for methods.
This commit is contained in:
parent
8bc0248a14
commit
8cbdf1ec34
@ -553,9 +553,9 @@ The JavaScript domain (name **js**) provides the following directives:
|
|||||||
|
|
||||||
.. directive:: .. js:function:: name(signature)
|
.. directive:: .. js:function:: name(signature)
|
||||||
|
|
||||||
Describe a JavaScript function. If you want to document optional
|
Describe a JavaScript function, method or constructor. If you want to
|
||||||
arguments use square brackets as :ref:`documented <signatures>` for Python
|
document optional arguments use square brackets as
|
||||||
signatures.
|
:ref:`documented <signatures>` for Python signatures.
|
||||||
|
|
||||||
.. directive:: .. js:data:: name
|
.. directive:: .. js:data:: name
|
||||||
|
|
||||||
|
@ -31,7 +31,25 @@ class JSCallable(ObjectDescription):
|
|||||||
match = js_sig_re.match(sig)
|
match = js_sig_re.match(sig)
|
||||||
if match is None:
|
if match is None:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
obj, name, arglist = match.groups()
|
nameprefix, name, arglist = match.groups()
|
||||||
|
|
||||||
|
objectname = self.env.temp_data.get('js:object')
|
||||||
|
if objectname and nameprefix:
|
||||||
|
# someone documenting the method of an attribute of the current
|
||||||
|
# object? shouldn't happen but who knows...
|
||||||
|
fullname = objectname + '.' + nameprefix + name
|
||||||
|
elif objectname:
|
||||||
|
fullname = objectname + '.' + name
|
||||||
|
elif nameprefix:
|
||||||
|
fullname = nameprefix + '.' + name
|
||||||
|
else:
|
||||||
|
# just a function or constructor
|
||||||
|
objectname = ''
|
||||||
|
fullname = ''
|
||||||
|
|
||||||
|
signode['object'] = objectname
|
||||||
|
signode['fullname'] = fullname
|
||||||
|
|
||||||
|
|
||||||
signode += addnodes.desc_name(name, name)
|
signode += addnodes.desc_name(name, name)
|
||||||
if not arglist:
|
if not arglist:
|
||||||
|
@ -80,6 +80,9 @@ Javascript items
|
|||||||
|
|
||||||
.. js:data:: bar
|
.. js:data:: bar
|
||||||
|
|
||||||
|
.. documenting the method of any object
|
||||||
|
.. js:function:: bar.baz()
|
||||||
|
|
||||||
|
|
||||||
References
|
References
|
||||||
==========
|
==========
|
||||||
@ -96,6 +99,8 @@ Without target: :c:func:`CFunction`. :c:func:`!malloc`.
|
|||||||
:js:func:`foo`
|
:js:func:`foo`
|
||||||
|
|
||||||
:js:data:`bar`
|
:js:data:`bar`
|
||||||
|
:js:func:`bar.baz()`
|
||||||
|
:js:func:`bar.baz`
|
||||||
|
|
||||||
|
|
||||||
Others
|
Others
|
||||||
|
Loading…
Reference in New Issue
Block a user