Changing docs structure, move .rst docs out from root

This commit is contained in:
Roman Mogilatov 2015-08-05 17:24:03 +03:00
parent d2ec7fbe45
commit 7f82c89d95
8 changed files with 10 additions and 94 deletions

View File

@ -1,38 +0,0 @@
Advanced usage
==============
Below you can find some variants of advanced usage of *Objects*.
@inject decorator
-----------------
``@inject`` decorator could be used for patching any callable with injection.
Any Python object will be injected *as is*, except *Objects* providers,
that will be called to provide injectable value.
.. code-block:: python
"""`@inject` decorator example."""
from objects.providers import NewInstance
from objects.injections import KwArg
from objects.injections import inject
new_object = NewInstance(object)
@inject(KwArg('object_a', new_object))
@inject(KwArg('some_setting', 1334))
def example_callback(object_a, some_setting):
"""This function has dependencies on object a and b.
Dependencies are injected using `@inject` decorator.
"""
assert isinstance(object_a, object)
assert some_setting == 1334
example_callback()
example_callback()

View File

@ -40,7 +40,7 @@ Example:
:width: 100%
:align: center
.. literalinclude:: ../examples/catalogs/simple.py
.. literalinclude:: ../../examples/catalogs/simple.py
:language: python
Operating with catalog providers
@ -59,7 +59,7 @@ providers:
Example:
.. literalinclude:: ../examples/catalogs/operating_with_providers.py
.. literalinclude:: ../../examples/catalogs/operating_with_providers.py
:language: python
Overriding of catalogs
@ -76,10 +76,10 @@ There are two ways to override catalog by another catalog:
Example of overriding catalog using ``Catalog.override()`` method:
.. literalinclude:: ../examples/catalogs/override.py
.. literalinclude:: ../../examples/catalogs/override.py
:language: python
Example of overriding catalog using ``@override()`` decorator:
.. literalinclude:: ../examples/catalogs/override_decorator.py
.. literalinclude:: ../../examples/catalogs/override_decorator.py
:language: python

View File

@ -1,46 +0,0 @@
Inline injections
=================
@inject decorator
-----------------
``@inject`` decorator can be used for making *inline* dependency injections.
It *patches* decorated callable in such way that dependency injection will be
done before every call of decorated callable.
``@inject`` decorator takes only argument that is supposed to be an
``objects.injections.Injection`` instance.
Any Python object will be injected *as is*, except *Objects* providers,
that will be called to provide injectable value.
Below is an example of how Flask's view could be patched using ``@inject``
decorator:
.. code-block:: python
"""`@inject` decorator example."""
from objects.providers import NewInstance
from objects.injections import KwArg
from objects.injections import inject
new_object = NewInstance(object)
@inject(KwArg('object_a', new_object))
@inject(KwArg('some_setting', 1334))
def example_callback(object_a, some_setting):
"""This function has dependencies on object a and b.
Dependencies are injected using `@inject` decorator.
"""
assert isinstance(object_a, object)
assert some_setting == 1334
example_callback()
example_callback()

View File

@ -35,10 +35,10 @@ Contents
.. toctree::
:maxdepth: 2
introduction
installation
main/introduction
main/installation
providers/index
catalogs
decorators
feedback
changelog
catalogs/index
advanced_usage/index
main/feedback
main/changelog