JavaScript域¶
The JavaScript domain (name js) provides the following directives:
-
.. js:function::name(signature)¶ Describes a JavaScript function or method. If you want to describe arguments as optional use square brackets as documented 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]) :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: SomethingThis is rendered as:
-
$.getJSON(href, callback[, errback])¶ 参数: - href (string) – An URI to the location of the resource.
- callback – Get’s called with the object.
- errback – Get’s called in case the request fails. And a lot of other text so we need multiple lines.
抛出: SomeError – For whatever reason in that case.
返回: Something
-
-
.. js:class::name¶ Describes a constructor that creates an object. This is basically like a function but will show up with a class prefix:
.. js:class:: MyAnimal(name[, age]) :param string name: The name of the animal :param number age: an optional age for the animal
This is rendered as:
-
class
MyAnimal(name[, age])¶ 参数: - name (string) – The name of the animal
- age (number) – an optional age for the animal
-
class
-
.. js:data::name¶ Describes a global variable or constant.
-
.. js:attribute::object.name¶ Describes the attribute name of object.
These roles are provided to refer to the described objects: