mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-01-31 11:51:39 +03:00
Add line numbers for all code samples in the documentation
This commit is contained in:
parent
c23803dedb
commit
9fc1502ae6
|
@ -42,11 +42,13 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/advanced_usage/inject_simple.py
|
.. literalinclude:: ../../examples/advanced_usage/inject_simple.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Example of usage :py:func:`inject` decorator with Flask:
|
Example of usage :py:func:`inject` decorator with Flask:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/advanced_usage/inject_flask.py
|
.. literalinclude:: ../../examples/advanced_usage/inject_flask.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
|
|
||||||
@inject decorator with classes
|
@inject decorator with classes
|
||||||
|
@ -61,3 +63,4 @@ Example of usage :py:func:`inject` with Flask class-based view:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/advanced_usage/inject_flask_class_based.py
|
.. literalinclude:: ../../examples/advanced_usage/inject_flask_class_based.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
|
@ -48,13 +48,16 @@ Listing of `services.py`:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/catalogs/bundles/services.py
|
.. literalinclude:: ../../examples/catalogs/bundles/services.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Listing of `views.py`:
|
Listing of `views.py`:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/catalogs/bundles/views.py
|
.. literalinclude:: ../../examples/catalogs/bundles/views.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Listing of `catalogs.py`:
|
Listing of `catalogs.py`:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/catalogs/bundles/catalogs.py
|
.. literalinclude:: ../../examples/catalogs/bundles/catalogs.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
|
@ -41,6 +41,7 @@ factories:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/catalogs/declarative.py
|
.. literalinclude:: ../../examples/catalogs/declarative.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Example of declarative catalogs inheritance:
|
Example of declarative catalogs inheritance:
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ Example of declarative catalogs inheritance:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/catalogs/declarative_inheritance.py
|
.. literalinclude:: ../../examples/catalogs/declarative_inheritance.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Example of declarative catalog's provider injections:
|
Example of declarative catalog's provider injections:
|
||||||
|
|
||||||
|
@ -59,3 +61,4 @@ Example of declarative catalog's provider injections:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/catalogs/declarative_injections.py
|
.. literalinclude:: ../../examples/catalogs/declarative_injections.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
|
@ -22,8 +22,10 @@ Here is an simple example of defining dynamic catalog with several factories:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/catalogs/dynamic.py
|
.. literalinclude:: ../../examples/catalogs/dynamic.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Next one example demonstrates creation and runtime filling of dynamic catalog:
|
Next one example demonstrates creation and runtime filling of dynamic catalog:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/catalogs/dynamic_runtime_creation.py
|
.. literalinclude:: ../../examples/catalogs/dynamic_runtime_creation.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
|
@ -18,11 +18,13 @@ method:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/catalogs/override_declarative.py
|
.. literalinclude:: ../../examples/catalogs/override_declarative.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Example of overriding catalog using :py:func:`override` decorator:
|
Example of overriding catalog using :py:func:`override` decorator:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/catalogs/override_declarative_decorator.py
|
.. literalinclude:: ../../examples/catalogs/override_declarative_decorator.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Also there are several useful :py:class:`DeclarativeCatalog` methods and
|
Also there are several useful :py:class:`DeclarativeCatalog` methods and
|
||||||
properties that help to work with catalog overridings:
|
properties that help to work with catalog overridings:
|
||||||
|
@ -47,3 +49,4 @@ Example of overriding :py:class:`DeclarativeCatalog` by
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/catalogs/override_declarative_by_dynamic.py
|
.. literalinclude:: ../../examples/catalogs/override_declarative_by_dynamic.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
|
@ -18,11 +18,13 @@ Listing of `services.py`:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/catalogs/declarative_provider_type/services.py
|
.. literalinclude:: ../../examples/catalogs/declarative_provider_type/services.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Listing of `catalog.py`:
|
Listing of `catalog.py`:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/catalogs/declarative_provider_type/catalog.py
|
.. literalinclude:: ../../examples/catalogs/declarative_provider_type/catalog.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Limitation to provider type could be used with :py:class:`DynamicCatalog`
|
Limitation to provider type could be used with :py:class:`DynamicCatalog`
|
||||||
as well.
|
as well.
|
||||||
|
@ -34,8 +36,10 @@ Listing of `services.py`:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/catalogs/dynamic_provider_type/services.py
|
.. literalinclude:: ../../examples/catalogs/dynamic_provider_type/services.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Listing of `catalog.py`:
|
Listing of `catalog.py`:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/catalogs/dynamic_provider_type/catalog.py
|
.. literalinclude:: ../../examples/catalogs/dynamic_provider_type/catalog.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
|
@ -88,6 +88,7 @@ Let's go through next example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/ioc_di_demos/car_engine_1.py
|
.. literalinclude:: ../../examples/ioc_di_demos/car_engine_1.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
``Car`` **creates** an ``Engine`` during its creation. Really? Does it make
|
``Car`` **creates** an ``Engine`` during its creation. Really? Does it make
|
||||||
more sense then creating an ``Engine`` separatelly and then
|
more sense then creating an ``Engine`` separatelly and then
|
||||||
|
@ -95,3 +96,4 @@ more sense then creating an ``Engine`` separatelly and then
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/ioc_di_demos/car_engine_2.py
|
.. literalinclude:: ../../examples/ioc_di_demos/car_engine_2.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
|
@ -76,18 +76,21 @@ Let's go through the code of ``example.py``:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/ioc_di_demos/example.py
|
.. literalinclude:: ../../examples/ioc_di_demos/example.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
At some point, things defined above mean, that the code from ``example.py``,
|
At some point, things defined above mean, that the code from ``example.py``,
|
||||||
could look different, like in ``ioc_example.py``:
|
could look different, like in ``ioc_example.py``:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/ioc_di_demos/ioc_example.py
|
.. literalinclude:: ../../examples/ioc_di_demos/ioc_example.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Also the code from ``ioc_example.py`` could be upgraded with inversion of
|
Also the code from ``ioc_example.py`` could be upgraded with inversion of
|
||||||
control container, like in ``ioc_container_example.py``:
|
control container, like in ``ioc_container_example.py``:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/ioc_di_demos/ioc_container_example.py
|
.. literalinclude:: ../../examples/ioc_di_demos/ioc_container_example.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ follows `Semantic versioning`_
|
||||||
Development version
|
Development version
|
||||||
-------------------
|
-------------------
|
||||||
- Add ``@copy`` decorator for copying declarative catalog providers.
|
- Add ``@copy`` decorator for copying declarative catalog providers.
|
||||||
|
- Add line numbers for all code samples in documentation.
|
||||||
|
|
||||||
1.15.2
|
1.15.2
|
||||||
------
|
------
|
||||||
|
|
|
@ -41,6 +41,7 @@ injections:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/callable_args.py
|
.. literalinclude:: ../../examples/providers/callable_args.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Next one example shows usage of :py:class:`Callable` with keyword argument
|
Next one example shows usage of :py:class:`Callable` with keyword argument
|
||||||
injections:
|
injections:
|
||||||
|
@ -51,6 +52,7 @@ injections:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/callable_kwargs.py
|
.. literalinclude:: ../../examples/providers/callable_kwargs.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
.. _callable_delegation:
|
.. _callable_delegation:
|
||||||
|
|
||||||
|
@ -69,6 +71,7 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/callable_delegation.py
|
.. literalinclude:: ../../examples/providers/callable_delegation.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Alternative way of doing :py:class:`Callable` delegation is an usage of
|
Alternative way of doing :py:class:`Callable` delegation is an usage of
|
||||||
:py:class:`DelegatedCallable`. :py:class:`DelegatedCallable` is a
|
:py:class:`DelegatedCallable`. :py:class:`DelegatedCallable` is a
|
||||||
|
@ -78,3 +81,4 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/delegated_callable.py
|
.. literalinclude:: ../../examples/providers/delegated_callable.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
|
@ -32,3 +32,4 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/custom_factory.py
|
.. literalinclude:: ../../examples/providers/custom_factory.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
|
@ -39,3 +39,4 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/external_dependency.py
|
.. literalinclude:: ../../examples/providers/external_dependency.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
|
@ -14,6 +14,7 @@ Nothing could be better than brief example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/factory.py
|
.. literalinclude:: ../../examples/providers/factory.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Factory providers and __init__ injections
|
Factory providers and __init__ injections
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -58,11 +59,13 @@ Example of usage positional argument injections:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/factory_init_args.py
|
.. literalinclude:: ../../examples/providers/factory_init_args.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Example of usage keyword argument injections:
|
Example of usage keyword argument injections:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/factory_init_kwargs.py
|
.. literalinclude:: ../../examples/providers/factory_init_kwargs.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Factory providers and __init__ injections priority
|
Factory providers and __init__ injections priority
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -82,6 +85,7 @@ So, please, follow the example below:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/factory_init_injections_and_contexts.py
|
.. literalinclude:: ../../examples/providers/factory_init_injections_and_contexts.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
|
|
||||||
Factory providers and other types of injections
|
Factory providers and other types of injections
|
||||||
|
@ -132,6 +136,7 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/factory_attribute_injections.py
|
.. literalinclude:: ../../examples/providers/factory_attribute_injections.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Factory providers and method injections
|
Factory providers and method injections
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -151,6 +156,7 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/factory_method_injections.py
|
.. literalinclude:: ../../examples/providers/factory_method_injections.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Factory providers delegation
|
Factory providers delegation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -179,6 +185,7 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/factory_delegation.py
|
.. literalinclude:: ../../examples/providers/factory_delegation.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Alternative way of doing :py:class:`Factory` delegation is an usage of
|
Alternative way of doing :py:class:`Factory` delegation is an usage of
|
||||||
:py:class:`DelegatedFactory`. :py:class:`DelegatedFactory` is a
|
:py:class:`DelegatedFactory`. :py:class:`DelegatedFactory` is a
|
||||||
|
@ -188,6 +195,7 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/delegated_factory.py
|
.. literalinclude:: ../../examples/providers/delegated_factory.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Factory providers specialization
|
Factory providers specialization
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -200,3 +208,4 @@ type:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/factory_provided_type.py
|
.. literalinclude:: ../../examples/providers/factory_provided_type.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
|
@ -42,6 +42,7 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/overriding_simple.py
|
.. literalinclude:: ../../examples/providers/overriding_simple.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
@ -51,3 +52,4 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/overriding_users_model.py
|
.. literalinclude:: ../../examples/providers/overriding_users_model.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
|
@ -14,6 +14,7 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/singleton.py
|
.. literalinclude:: ../../examples/providers/singleton.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Singleton providers and injections
|
Singleton providers and injections
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -53,6 +54,7 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/singleton_reseting.py
|
.. literalinclude:: ../../examples/providers/singleton_reseting.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Singleton providers delegation
|
Singleton providers delegation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -70,6 +72,7 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/singleton_delegation.py
|
.. literalinclude:: ../../examples/providers/singleton_delegation.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Alternative way of doing :py:class:`Singleton` delegation is an usage of
|
Alternative way of doing :py:class:`Singleton` delegation is an usage of
|
||||||
:py:class:`DelegatedSingleton`. :py:class:`DelegatedSingleton` is a
|
:py:class:`DelegatedSingleton`. :py:class:`DelegatedSingleton` is a
|
||||||
|
@ -79,6 +82,7 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/delegated_singleton.py
|
.. literalinclude:: ../../examples/providers/delegated_singleton.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
Singleton providers specialization
|
Singleton providers specialization
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -91,3 +95,4 @@ provided type:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/singleton_provided_type.py
|
.. literalinclude:: ../../examples/providers/singleton_provided_type.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
|
@ -19,3 +19,4 @@ Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/providers/static.py
|
.. literalinclude:: ../../examples/providers/static.py
|
||||||
:language: python
|
:language: python
|
||||||
|
:linenos:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user