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