diff --git a/docs/examples/bundles_miniapp.rst b/docs/examples-other/bundles_miniapp.rst similarity index 100% rename from docs/examples/bundles_miniapp.rst rename to docs/examples-other/bundles_miniapp.rst diff --git a/docs/examples/chained_factories.rst b/docs/examples-other/chained_factories.rst similarity index 100% rename from docs/examples/chained_factories.rst rename to docs/examples-other/chained_factories.rst diff --git a/docs/examples/factory_of_factories.rst b/docs/examples-other/factory_of_factories.rst similarity index 100% rename from docs/examples/factory_of_factories.rst rename to docs/examples-other/factory_of_factories.rst diff --git a/docs/examples-other/index.rst b/docs/examples-other/index.rst new file mode 100644 index 00000000..e99ec099 --- /dev/null +++ b/docs/examples-other/index.rst @@ -0,0 +1,22 @@ +Other examples +============== + +.. meta:: + :keywords: Python,DI,Dependency injection,IoC,Inversion of Control + :description: Current section of documentation is designed to provide + several example mini applications that are built on the top + of inversion of control principle and powered by + "Dependency Injector" framework. + +Current section of documentation is designed to provide several example mini +applications that are built according to the inversion of control principle +and powered by *Dependency Injector* framework. + +.. toctree:: + :maxdepth: 2 + + bundles_miniapp + use_cases_miniapp + password_hashing_miniapp + chained_factories + factory_of_factories diff --git a/docs/examples/password_hashing_miniapp.rst b/docs/examples-other/password_hashing_miniapp.rst similarity index 100% rename from docs/examples/password_hashing_miniapp.rst rename to docs/examples-other/password_hashing_miniapp.rst diff --git a/docs/examples/use_cases_miniapp.rst b/docs/examples-other/use_cases_miniapp.rst similarity index 100% rename from docs/examples/use_cases_miniapp.rst rename to docs/examples-other/use_cases_miniapp.rst diff --git a/docs/examples/images/services-miniapp.png b/docs/examples/images/services-miniapp.png new file mode 100644 index 00000000..1ef8f7be Binary files /dev/null and b/docs/examples/images/services-miniapp.png differ diff --git a/docs/examples/index.rst b/docs/examples/index.rst index 244569b2..f43203a5 100644 --- a/docs/examples/index.rst +++ b/docs/examples/index.rst @@ -2,23 +2,13 @@ Examples ======== .. meta:: - :keywords: Python,DI,Dependency injection,IoC,Inversion of Control - :description: Current section of documentation is designed to provide - several example mini applications that are built on the top - of inversion of control principle and powered by - "Dependency Injector" framework. + :keywords: Python,DI,Dependency injection,IoC,Inversion of Control,Example + :description: Python dependency injection examples. -Current section of documentation is designed to provide several example mini -applications that are built according to the inversion of control principle -and powered by *Dependency Injector* framework. +Explore the examples to see the ``Dependency Injector`` in action. .. toctree:: :maxdepth: 2 - services_miniapp_v1 - services_miniapp_v2 - bundles_miniapp - use_cases_miniapp - password_hashing_miniapp - chained_factories - factory_of_factories + services-single-container + services-multiple-containers diff --git a/docs/examples/services_miniapp_v2.rst b/docs/examples/services-multiple-containers.rst similarity index 93% rename from docs/examples/services_miniapp_v2.rst rename to docs/examples/services-multiple-containers.rst index 4c29fca7..1f9345bd 100644 --- a/docs/examples/services_miniapp_v2.rst +++ b/docs/examples/services-multiple-containers.rst @@ -1,5 +1,5 @@ -Services mini application example (v2 - single container) ---------------------------------------------------------- +Services mini application example (multiple containers) +======================================================= .. meta:: :description: "Services miniapp" is an example mini application that diff --git a/docs/examples/services-single-container.rst b/docs/examples/services-single-container.rst new file mode 100644 index 00000000..54955c28 --- /dev/null +++ b/docs/examples/services-single-container.rst @@ -0,0 +1,82 @@ +Services mini application example (single container) +==================================================== + +.. meta:: + :description: "Services miniapp" is an example mini application that + consists from several services that have dependencies on + some standard and 3rd-party libraries for logging, + interaction with database and remote service via API. + "Services miniapp" example demonstrates usage of + Dependency Injector for creating several inversion of control / + dependency injection containers. + +"Services" is an example mini application. It consists from several services that have +dependencies on database & AWS S3. + +.. image:: images/services-miniapp.png + :width: 100% + :align: center + +Start from the scratch or jump to the section: + +.. contents:: + :local: + :backlinks: none + +Application structure +--------------------- + +Application consists from ``example`` package, several configuration files and ``requirements.txt``. + +.. code-block:: bash + + ./ + ├── example/ + │ ├── __init__.py + │ ├── __main__.py + │ ├── containers.py + │ └── services.py + ├── config.ini + ├── logging.ini + └── requirements.txt + +Container +--------- + +Listing of ``example/containers.py``: + +.. literalinclude:: ../../examples/miniapps/services-single-container/example/containers.py + :language: python + +Listing of ``example/__main__.py``: + +.. literalinclude:: ../../examples/miniapps/services-single-container/example/__main__.py + :language: python + +Services +-------- + +Listing of ``example/services.py``: + +.. literalinclude:: ../../examples/miniapps/services-single-container/example/services.py + :language: python + +Configuration +------------- + +Listing of ``config.ini``: + +.. literalinclude:: ../../examples/miniapps/services-single-container/config.ini + :language: ini + +Listing of ``logging.ini``: + +.. literalinclude:: ../../examples/miniapps/services-single-container/logging.ini + :language: ini + +Sources on Github +----------------- + +To find the source code navigate to the `Github `_. + +.. disqus:: diff --git a/docs/examples/services_miniapp_v1.rst b/docs/examples/services_miniapp_v1.rst deleted file mode 100644 index 5277c56c..00000000 --- a/docs/examples/services_miniapp_v1.rst +++ /dev/null @@ -1,73 +0,0 @@ -Services mini application example (v1 - multiple containers) ------------------------------------------------------------- - -.. meta:: - :description: "Services miniapp" is an example mini application that - consists from several services that have dependencies on - some standard and 3rd-party libraries for logging, - interaction with database and remote service via API. - "Services miniapp" example demonstrates usage of - Dependency Injector for creating several inversion of control / - dependency injection containers. - -"Services miniapp" is an example mini application that consists from several -services that have dependencies on some standard and 3rd-party libraries for -logging, interaction with database and remote service calls via API. - -"Services miniapp" example demonstrates usage of -:doc:`Dependency Injector <../index>` for creating several IoC containers. - -Instructions for running: - -.. code-block:: bash - - python run.py 1 secret photo.jpg - -Example application -~~~~~~~~~~~~~~~~~~~ - -Classes diagram: - -.. image:: /images/miniapps/services/classes.png - :width: 100% - :align: center - - -Example application structure: - -.. code-block:: bash - - /example - /__init__.py - /main.py - /services.py - - -Listing of ``example/services.py``: - -.. literalinclude:: ../../examples/miniapps/services_v1/example/services.py - :language: python - -Listing of ``example/main.py``: - -.. literalinclude:: ../../examples/miniapps/services_v1/example/main.py - :language: python - -IoC containers -~~~~~~~~~~~~~~ - -Listing of ``containers.py``: - -.. literalinclude:: ../../examples/miniapps/services_v1/containers.py - :language: python - -Run application -~~~~~~~~~~~~~~~ - -Listing of ``run.py``: - -.. literalinclude:: ../../examples/miniapps/services_v1/run.py - :language: python - - -.. disqus:: diff --git a/docs/images/miniapps/services/classes.png b/docs/images/miniapps/services/classes.png deleted file mode 100644 index 8e9d29f7..00000000 Binary files a/docs/images/miniapps/services/classes.png and /dev/null differ diff --git a/docs/index.rst b/docs/index.rst index e1eb64c7..8dc90f8c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -131,9 +131,10 @@ Contents introduction/index main/installation tutorials/index + examples/index providers/index containers/index - examples/index + examples-other/index api/index main/feedback main/changelog