diff --git a/docs/advanced_usage.rst b/docs/advanced_usage.rst deleted file mode 100644 index 889d1468..00000000 --- a/docs/advanced_usage.rst +++ /dev/null @@ -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() diff --git a/docs/catalogs.rst b/docs/catalogs/index.rst similarity index 91% rename from docs/catalogs.rst rename to docs/catalogs/index.rst index 186ff1f0..8ecc7a22 100644 --- a/docs/catalogs.rst +++ b/docs/catalogs/index.rst @@ -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 diff --git a/docs/decorators.rst b/docs/decorators.rst deleted file mode 100644 index ea65f48e..00000000 --- a/docs/decorators.rst +++ /dev/null @@ -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() - diff --git a/docs/index.rst b/docs/index.rst index 08034a21..8dbab77e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -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 diff --git a/docs/changelog.rst b/docs/main/changelog.rst similarity index 100% rename from docs/changelog.rst rename to docs/main/changelog.rst diff --git a/docs/feedback.rst b/docs/main/feedback.rst similarity index 100% rename from docs/feedback.rst rename to docs/main/feedback.rst diff --git a/docs/installation.rst b/docs/main/installation.rst similarity index 100% rename from docs/installation.rst rename to docs/main/installation.rst diff --git a/docs/introduction.rst b/docs/main/introduction.rst similarity index 100% rename from docs/introduction.rst rename to docs/main/introduction.rst