[IMP] developer: use js domain for registry page

This commit update the registry documentation to use the js domain
directives instead of trying to format functions with code blocks.

I am not impressed with the way it looks, but in any cases, it is
certainly better to properly structure the documentation.

closes odoo/documentation#1245

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
This commit is contained in:
Géry Debongnie 2021-10-31 10:14:01 +00:00
parent a2a389688c
commit ce96d6c584

View File

@ -34,24 +34,21 @@ in such a way from one root registry, exported in `@web/core/registry`.
Registry API Registry API
============ ============
constructor() .. js:class:: Registry()
.. code-block::
@returns {Registry} Creates a new registry. Note that a registry is an event bus, so one can
listen to the `UPDATE` event if necessary. Registries are ordered: the
:js:meth:`getAll <Registry.getAll>` method returns a list of
values ordered according to their sequence number.
creates a new registry. Note that a registry is an event bus, so one can .. js:method:: add(key, value[, options])
listen to the `UPDATE` event if necessary.
Registries are ordered: the :ref:`getAll <javascript/registries/api/getAll>` method returns a list of values ordered :param string key: key for the new entry
according to their sequence number. :param any value: value for the new entry
:param Object options: options
add(key, value, options) :param boolean [options.force]: do not throw if key already exists
.. code-block:: :param number [options.sequence]: sequence number (useful to order entries)
:returns: Registry
@param {string} key
@param {any} value
@param {{force?: boolean, sequence?: number}} [options]
@returns {Registry}
Inserts a value at a specific key. If the key is already used, this method Inserts a value at a specific key. If the key is already used, this method
throws an error (unless the option `force` is set to true). The option throws an error (unless the option `force` is set to true). The option
@ -60,47 +57,40 @@ add(key, value, options)
Returns the same registry, so `add` method calls can be chained. Returns the same registry, so `add` method calls can be chained.
get(key, defaultValue) .. js:method:: get(key[, defaultValue])
.. code-block::
@param {string} key :param string key: key for the entry
@returns {any} :param defaultValue any: return value if no entry for key exists
Returns the value corresponding to the `key` argument. If the registry does Returns the value corresponding to the `key` argument. If the registry does
not contain that key, this method returns `defaultValue` if given, or throws not contain that key, this method returns `defaultValue` if given, or throws
an error otherwise. an error otherwise.
contains(key) .. js:method:: contains(key)
.. code-block::
@param {string} key :param string key: key for the entry
@returns {boolean} :returns: boolean
Returns `true` if the `key` is present in the registry Returns `true` if `key` is present in the registry
.. _javascript/registries/api/getAll: .. js:method:: getAll()
getAll() :returns: any[]
.. code-block::
@returns {any[]} Returns the list of all elements in the registry. It is ordered
Returns the list of all elements in the registry. Note that it is ordered
according to the sequence numbers. according to the sequence numbers.
remove(key) .. js:method:: remove(key)
.. code-block::
@param {string} key :param string key: the key for the entry that should be removed
Removes a key/value pair from the registry. This operation triggers an Removes a key/value pair from the registry. This operation triggers an
`UPDATE` event. `UPDATE` event.
category(subcategory) .. js:method:: category(subcategory)
.. code-block::
@param {string} subcategory :param string subcategory: the name for the sub category
@returns {Registry} :returns: Registry
Returns the sub registry associated with the `subcategory`. If it does not Returns the sub registry associated with the `subcategory`. If it does not
exist yet, the sub registry is created on the fly. exist yet, the sub registry is created on the fly.