It is now possible to use the js:function:: directive for methods.

This commit is contained in:
Daniel Neuhäuser 2010-03-30 21:50:48 +00:00
parent 8bc0248a14
commit 8cbdf1ec34
3 changed files with 27 additions and 4 deletions

View File

@ -553,9 +553,9 @@ The JavaScript domain (name **js**) provides the following directives:
.. directive:: .. js:function:: name(signature)
Describe a JavaScript function. If you want to document optional
arguments use square brackets as :ref:`documented <signatures>` for Python
signatures.
Describe a JavaScript function, method or constructor. If you want to
document optional arguments use square brackets as
:ref:`documented <signatures>` for Python signatures.
.. directive:: .. js:data:: name

View File

@ -31,7 +31,25 @@ class JSCallable(ObjectDescription):
match = js_sig_re.match(sig)
if match is None:
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)
if not arglist:

View File

@ -80,6 +80,9 @@ Javascript items
.. js:data:: bar
.. documenting the method of any object
.. js:function:: bar.baz()
References
==========
@ -96,6 +99,8 @@ Without target: :c:func:`CFunction`. :c:func:`!malloc`.
:js:func:`foo`
:js:data:`bar`
:js:func:`bar.baz()`
:js:func:`bar.baz`
Others