Skip to content

Commit

Permalink
Docs: better documentation of iPOPO decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
tcalmant committed Jan 19, 2017
1 parent fade72b commit 60c066c
Show file tree
Hide file tree
Showing 2 changed files with 411 additions and 96 deletions.
68 changes: 68 additions & 0 deletions docs/refcards/ipopo_decorators.rst
Expand Up @@ -7,30 +7,98 @@ iPOPO Decorators
Component definition
--------------------

Those decorators describe the component.
They must decorate the factory class itself.


Factory definition
^^^^^^^^^^^^^^^^^^

The factory definition decorator must be unique per class and must always be
the last one executed, *i.e.* the top one in the source code.

.. autoclass:: ComponentFactory
.. autoclass:: SingletonFactory


Component properties
^^^^^^^^^^^^^^^^^^^^

.. autoclass:: Property
.. autoclass:: HiddenProperty

Special properties
__________________

Note that some properties have a special meaning for iPOPO and Pelix.

=================== ======= ====================================================
Name Type Description
=================== ======= ====================================================
``instance.name`` ``str`` The name of the iPOPO component instance
``service.id`` ``int`` The registration number of a service
``service.ranking`` ``int`` The rank (priority) of the services provided by this component
=================== ======= ====================================================

.. code-block:: python
@ComponentFactory()
@Property('_name', 'instance.name') # Special property
@Property('_value', 'my.value') # Some property
@Property('_answer', 'the.answer', 42) # Some property, with a default value
class Foo(object):
def __init__(self):
self._name = None # This will overwritten by iPOPO
self._value = 12 # 12 will be used if this property is not configured
self._answer = None # 42 will be used by default
Provided Services
^^^^^^^^^^^^^^^^^

.. autoclass:: Provides


Requirements
^^^^^^^^^^^^

.. autoclass:: Requires
.. autoclass:: Temporal
.. autoclass:: RequiresBest
.. autoclass:: RequiresMap
.. autoclass:: RequiresVarFilter


Instance definition
^^^^^^^^^^^^^^^^^^^

.. autoclass:: Instantiate


Life-cycle events
-----------------

Those decorators store behavioral information on component methods.
They must decorate methods in the component class.

Component state
^^^^^^^^^^^^^^^

.. autofunction:: Validate
.. autofunction:: Invalidate

Injections
^^^^^^^^^^

.. autofunction:: Bind
.. autoclass:: BindField
.. autofunction:: Update
.. autoclass:: UpdateField
.. autofunction:: Unbind
.. autoclass:: UnbindField

Service state
^^^^^^^^^^^^^

.. autofunction:: PostRegistration
.. autofunction:: PostUnregistration

0 comments on commit 60c066c

Please sign in to comment.