JavaScript域¶
Added in version 1.0.
JavaScript域(名称**js**)提供以下指令:
- .. js:module:: name¶
该指令设置后面的对象声明的模块名称。 模块名称用于全局模块索引和交叉引用中。 该指令不会创建如下的对象标题
py:class
。By default, this directive will create a linkable entity and will cause an entry in the global module index, unless the
no-index
option is specified. If this option is specified, the directive will only update the current module name.Added in version 1.6.
在 5.2 版本发生变更: Module directives support body content.
- .. js:function:: name(signature)¶
描述JavaScript函数或方法。如果要将参数描述为可选,请使用方括号 documented 用于Python签名。
您可以使用字段来提供有关参数及其预期类型的更多详细信息,函数可能抛出的错误以及返回的值:
.. js:function:: $.getJSON(href, callback[, errback]) :param string href: An URI to the location of the resource. :param callback: Gets called with the object. :param errback: Gets 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.
这表现为:
- $.getJSON(href, callback[, errback])¶
- 参数:
href (
string()
) – 资源位置的URI。callback – 使用对象调用。
errback – 在请求失败的情况下调用。还有很多其他文字,所以我们需要多行。
- 抛出:
SomeError()
– 无论出于何种原因。- 返回:
某物。
- :single-line-parameter-list: (no value)¶
Ensures that the function’s parameters will be emitted on a single logical line, overriding
javascript_maximum_signature_line_length
andmaximum_signature_line_length
.Added in version 7.1.
- .. js:method:: name(signature)¶
该指令是以下的别名
js:function
,但是它描述了一个作为类对象上的方法实现的函数。Added in version 1.6.
- :single-line-parameter-list: (no value)¶
Ensures that the function’s parameters will be emitted on a single logical line, overriding
javascript_maximum_signature_line_length
andmaximum_signature_line_length
.Added in version 7.1.
- .. js:class:: name¶
描述创建对象的构造函数。这基本上就像一个函数,但会出现一个 `class`前缀:
.. js:class:: MyAnimal(name[, age]) :param string name: The name of the animal :param number age: an optional age for the animal
这表现为:
- class MyAnimal(name[, age])¶
- 参数:
name (
string()
) – 动物的名字age (
number()
) – 动物的选择年龄
- :single-line-parameter-list: (no value)¶
Ensures that the function’s parameters will be emitted on a single logical line, overriding
javascript_maximum_signature_line_length
andmaximum_signature_line_length
.Added in version 7.1.
- .. js:data:: name¶
描述全局变量或常量。
- .. js:attribute:: object.name¶
描述 物体*的属性*名称 。
提供这些角色是为了引用所描述的对象: