Debian Codegraph @

doc/usage/domains/javascript.rst

raw
1 .. highlight:: rst
2
3 =====================
4 The JavaScript Domain
5 =====================
6
7 .. versionadded:: 1.0
8
9 The JavaScript domain (name **js**) provides the following directives:
10
11 .. rst:directive:: .. js:module:: name
12
13 This directive sets the module name for object declarations that follow
14 after. The module name is used in the global module index and in cross
15 references. This directive does not create an object heading like
16 :rst:dir:`py:class` would, for example.
17
18 By default, this directive will create a linkable entity and will cause an
19 entry in the global module index, unless the ``no-index`` option is
20 specified. If this option is specified, the directive will only update the
21 current module name.
22
23 .. versionadded:: 1.6
24 .. versionchanged:: 5.2
25
26 Module directives support body content.
27
28 .. rst:directive:: .. js:function:: name(signature)
29
30 Describes a JavaScript function or method. If you want to describe
31 arguments as optional use square brackets as :ref:`documented <signatures>`
32 for Python signatures.
33
34 You can use fields to give more details about arguments and their expected
35 types, errors which may be thrown by the function, and the value being
36 returned::
37
38 .. js:function:: $.getJSON(href, callback[, errback])
39
40 :param string href: An URI to the location of the resource.
41 :param callback: Gets called with the object.
42 :param errback:
43 Gets called in case the request fails. And a lot of other
44 text so we need multiple lines.
45 :throws SomeError: For whatever reason in that case.
46 :returns: Something.
47
48 This is rendered as:
49
50 .. js:function:: $.getJSON(href, callback[, errback])
51 :no-contents-entry:
52 :no-index-entry:
53
54 :param string href: An URI to the location of the resource.
55 :param callback: Gets called with the object.
56 :param errback:
57 Gets called in case the request fails. And a lot of other
58 text so we need multiple lines.
59 :throws SomeError: For whatever reason in that case.
60 :returns: Something.
61
62 .. rst:directive:option:: single-line-parameter-list
63 :type: no value
64
65 Ensures that the function's parameters will be emitted on a single logical
66 line, overriding :confval:`javascript_maximum_signature_line_length` and
67 :confval:`maximum_signature_line_length`.
68
69 .. versionadded:: 7.1
70
71 .. rst:directive:: .. js:method:: name(signature)
72
73 This directive is an alias for :rst:dir:`js:function`, however it describes
74 a function that is implemented as a method on a class object.
75
76 .. versionadded:: 1.6
77
78 .. rst:directive:option:: single-line-parameter-list
79 :type: no value
80
81 Ensures that the function's parameters will be emitted on a single logical
82 line, overriding :confval:`javascript_maximum_signature_line_length` and
83 :confval:`maximum_signature_line_length`.
84
85 .. versionadded:: 7.1
86
87 .. rst:directive:: .. js:class:: name
88
89 Describes a constructor that creates an object. This is basically like a
90 function but will show up with a `class` prefix::
91
92 .. js:class:: MyAnimal(name[, age])
93
94 :param string name: The name of the animal
95 :param number age: an optional age for the animal
96
97 This is rendered as:
98
99 .. js:class:: MyAnimal(name[, age])
100 :no-contents-entry:
101 :no-index-entry:
102
103 :param string name: The name of the animal
104 :param number age: an optional age for the animal
105
106 .. rst:directive:option:: single-line-parameter-list
107 :type: no value
108
109 Ensures that the function's parameters will be emitted on a single logical
110 line, overriding :confval:`javascript_maximum_signature_line_length` and
111 :confval:`maximum_signature_line_length`.
112
113 .. versionadded:: 7.1
114
115 .. rst:directive:: .. js:data:: name
116
117 Describes a global variable or constant.
118
119 .. rst:directive:: .. js:attribute:: object.name
120
121 Describes the attribute *name* of *object*.
122
123 .. _js-xref-roles:
124
125 These roles are provided to refer to the described objects:
126
127 .. rst:role:: js:mod
128 js:func
129 js:meth
130 js:class
131 js:data
132 js:attr