.. _javascript-domain: JavaScript域 --------------------- The JavaScript domain (name **js**) provides the following directives: .. rst:directive:: .. js:function:: name(signature) Describes a JavaScript function or method. If you want to describe arguments as optional use square brackets as :ref:`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: Something This is rendered as: .. 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: Something .. rst:directive:: .. 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: .. js:class:: MyAnimal(name[, age]) :param string name: The name of the animal :param number age: an optional age for the animal .. rst:directive:: .. js:data:: name Describes a global variable or constant. .. rst:directive:: .. js:attribute:: object.name Describes the attribute *name* of *object*. .. _js-roles: These roles are provided to refer to the described objects: .. rst:role:: js:func js:class js:data js:attr