diff --git a/docs/advanced_usage/index.rst b/docs/advanced_usage/index.rst index 0d6e5e14..2f5f7176 100644 --- a/docs/advanced_usage/index.rst +++ b/docs/advanced_usage/index.rst @@ -42,11 +42,13 @@ Example: .. literalinclude:: ../../examples/advanced_usage/inject_simple.py :language: python + :linenos: Example of usage :py:func:`inject` decorator with Flask: .. literalinclude:: ../../examples/advanced_usage/inject_flask.py :language: python + :linenos: @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 :language: python + :linenos: diff --git a/docs/catalogs/bundles.rst b/docs/catalogs/bundles.rst index 4c72eefc..7ecaa3d3 100644 --- a/docs/catalogs/bundles.rst +++ b/docs/catalogs/bundles.rst @@ -48,13 +48,16 @@ Listing of `services.py`: .. literalinclude:: ../../examples/catalogs/bundles/services.py :language: python + :linenos: Listing of `views.py`: .. literalinclude:: ../../examples/catalogs/bundles/views.py :language: python + :linenos: Listing of `catalogs.py`: .. literalinclude:: ../../examples/catalogs/bundles/catalogs.py :language: python + :linenos: diff --git a/docs/catalogs/declarative.rst b/docs/catalogs/declarative.rst index 159b020d..fbe241ea 100644 --- a/docs/catalogs/declarative.rst +++ b/docs/catalogs/declarative.rst @@ -41,6 +41,7 @@ factories: .. literalinclude:: ../../examples/catalogs/declarative.py :language: python + :linenos: Example of declarative catalogs inheritance: @@ -50,6 +51,7 @@ Example of declarative catalogs inheritance: .. literalinclude:: ../../examples/catalogs/declarative_inheritance.py :language: python + :linenos: Example of declarative catalog's provider injections: @@ -59,3 +61,4 @@ Example of declarative catalog's provider injections: .. literalinclude:: ../../examples/catalogs/declarative_injections.py :language: python + :linenos: diff --git a/docs/catalogs/dynamic.rst b/docs/catalogs/dynamic.rst index 1273a9a4..8489b60f 100644 --- a/docs/catalogs/dynamic.rst +++ b/docs/catalogs/dynamic.rst @@ -22,8 +22,10 @@ Here is an simple example of defining dynamic catalog with several factories: .. literalinclude:: ../../examples/catalogs/dynamic.py :language: python + :linenos: Next one example demonstrates creation and runtime filling of dynamic catalog: .. literalinclude:: ../../examples/catalogs/dynamic_runtime_creation.py :language: python + :linenos: diff --git a/docs/catalogs/overriding.rst b/docs/catalogs/overriding.rst index 38ee9d31..b94ffa7e 100644 --- a/docs/catalogs/overriding.rst +++ b/docs/catalogs/overriding.rst @@ -18,11 +18,13 @@ method: .. literalinclude:: ../../examples/catalogs/override_declarative.py :language: python + :linenos: Example of overriding catalog using :py:func:`override` decorator: .. literalinclude:: ../../examples/catalogs/override_declarative_decorator.py :language: python + :linenos: Also there are several useful :py:class:`DeclarativeCatalog` methods and 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 :language: python + :linenos: diff --git a/docs/catalogs/specialization.rst b/docs/catalogs/specialization.rst index 9e52e4d9..0bd622e3 100644 --- a/docs/catalogs/specialization.rst +++ b/docs/catalogs/specialization.rst @@ -18,11 +18,13 @@ Listing of `services.py`: .. literalinclude:: ../../examples/catalogs/declarative_provider_type/services.py :language: python + :linenos: Listing of `catalog.py`: .. literalinclude:: ../../examples/catalogs/declarative_provider_type/catalog.py :language: python + :linenos: Limitation to provider type could be used with :py:class:`DynamicCatalog` as well. @@ -34,8 +36,10 @@ Listing of `services.py`: .. literalinclude:: ../../examples/catalogs/dynamic_provider_type/services.py :language: python + :linenos: Listing of `catalog.py`: .. literalinclude:: ../../examples/catalogs/dynamic_provider_type/catalog.py :language: python + :linenos: diff --git a/docs/introduction/di_in_python.rst b/docs/introduction/di_in_python.rst index 335cb398..c9674d50 100644 --- a/docs/introduction/di_in_python.rst +++ b/docs/introduction/di_in_python.rst @@ -88,6 +88,7 @@ Let's go through next example: .. literalinclude:: ../../examples/ioc_di_demos/car_engine_1.py :language: python + :linenos: ``Car`` **creates** an ``Engine`` during its creation. Really? Does it make 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 :language: python + :linenos: diff --git a/docs/introduction/what_is_di.rst b/docs/introduction/what_is_di.rst index 488c52bd..fbfa0b03 100644 --- a/docs/introduction/what_is_di.rst +++ b/docs/introduction/what_is_di.rst @@ -76,18 +76,21 @@ Let's go through the code of ``example.py``: .. literalinclude:: ../../examples/ioc_di_demos/example.py :language: python + :linenos: At some point, things defined above mean, that the code from ``example.py``, could look different, like in ``ioc_example.py``: .. literalinclude:: ../../examples/ioc_di_demos/ioc_example.py :language: python + :linenos: Also the code from ``ioc_example.py`` could be upgraded with inversion of control container, like in ``ioc_container_example.py``: .. literalinclude:: ../../examples/ioc_di_demos/ioc_container_example.py :language: python + :linenos: .. note:: diff --git a/docs/main/changelog.rst b/docs/main/changelog.rst index e30ce304..bf723565 100644 --- a/docs/main/changelog.rst +++ b/docs/main/changelog.rst @@ -10,6 +10,7 @@ follows `Semantic versioning`_ Development version ------------------- - Add ``@copy`` decorator for copying declarative catalog providers. +- Add line numbers for all code samples in documentation. 1.15.2 ------ diff --git a/docs/providers/callable.rst b/docs/providers/callable.rst index 0a813640..76bd5faa 100644 --- a/docs/providers/callable.rst +++ b/docs/providers/callable.rst @@ -41,6 +41,7 @@ injections: .. literalinclude:: ../../examples/providers/callable_args.py :language: python + :linenos: Next one example shows usage of :py:class:`Callable` with keyword argument injections: @@ -51,6 +52,7 @@ injections: .. literalinclude:: ../../examples/providers/callable_kwargs.py :language: python + :linenos: .. _callable_delegation: @@ -69,6 +71,7 @@ Example: .. literalinclude:: ../../examples/providers/callable_delegation.py :language: python + :linenos: Alternative way of doing :py:class:`Callable` delegation is an usage of :py:class:`DelegatedCallable`. :py:class:`DelegatedCallable` is a @@ -78,3 +81,4 @@ Example: .. literalinclude:: ../../examples/providers/delegated_callable.py :language: python + :linenos: diff --git a/docs/providers/custom.rst b/docs/providers/custom.rst index f12f7005..7eb319a3 100644 --- a/docs/providers/custom.rst +++ b/docs/providers/custom.rst @@ -32,3 +32,4 @@ Example: .. literalinclude:: ../../examples/providers/custom_factory.py :language: python + :linenos: diff --git a/docs/providers/external_dependency.rst b/docs/providers/external_dependency.rst index 9c11bcf4..8486dbe9 100644 --- a/docs/providers/external_dependency.rst +++ b/docs/providers/external_dependency.rst @@ -39,3 +39,4 @@ Example: .. literalinclude:: ../../examples/providers/external_dependency.py :language: python + :linenos: diff --git a/docs/providers/factory.rst b/docs/providers/factory.rst index 818cbf1b..a85cc68f 100644 --- a/docs/providers/factory.rst +++ b/docs/providers/factory.rst @@ -14,6 +14,7 @@ Nothing could be better than brief example: .. literalinclude:: ../../examples/providers/factory.py :language: python + :linenos: Factory providers and __init__ injections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -58,11 +59,13 @@ Example of usage positional argument injections: .. literalinclude:: ../../examples/providers/factory_init_args.py :language: python + :linenos: Example of usage keyword argument injections: .. literalinclude:: ../../examples/providers/factory_init_kwargs.py :language: python + :linenos: 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 :language: python + :linenos: Factory providers and other types of injections @@ -132,6 +136,7 @@ Example: .. literalinclude:: ../../examples/providers/factory_attribute_injections.py :language: python + :linenos: Factory providers and method injections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -151,6 +156,7 @@ Example: .. literalinclude:: ../../examples/providers/factory_method_injections.py :language: python + :linenos: Factory providers delegation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -179,6 +185,7 @@ Example: .. literalinclude:: ../../examples/providers/factory_delegation.py :language: python + :linenos: Alternative way of doing :py:class:`Factory` delegation is an usage of :py:class:`DelegatedFactory`. :py:class:`DelegatedFactory` is a @@ -188,6 +195,7 @@ Example: .. literalinclude:: ../../examples/providers/delegated_factory.py :language: python + :linenos: Factory providers specialization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -200,3 +208,4 @@ type: .. literalinclude:: ../../examples/providers/factory_provided_type.py :language: python + :linenos: diff --git a/docs/providers/overriding.rst b/docs/providers/overriding.rst index 81c2dc74..3168c930 100644 --- a/docs/providers/overriding.rst +++ b/docs/providers/overriding.rst @@ -42,6 +42,7 @@ Example: .. literalinclude:: ../../examples/providers/overriding_simple.py :language: python + :linenos: Example: @@ -51,3 +52,4 @@ Example: .. literalinclude:: ../../examples/providers/overriding_users_model.py :language: python + :linenos: diff --git a/docs/providers/singleton.rst b/docs/providers/singleton.rst index db24ccfd..bd00b79e 100644 --- a/docs/providers/singleton.rst +++ b/docs/providers/singleton.rst @@ -14,6 +14,7 @@ Example: .. literalinclude:: ../../examples/providers/singleton.py :language: python + :linenos: Singleton providers and injections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -53,6 +54,7 @@ Example: .. literalinclude:: ../../examples/providers/singleton_reseting.py :language: python + :linenos: Singleton providers delegation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -70,6 +72,7 @@ Example: .. literalinclude:: ../../examples/providers/singleton_delegation.py :language: python + :linenos: Alternative way of doing :py:class:`Singleton` delegation is an usage of :py:class:`DelegatedSingleton`. :py:class:`DelegatedSingleton` is a @@ -79,6 +82,7 @@ Example: .. literalinclude:: ../../examples/providers/delegated_singleton.py :language: python + :linenos: Singleton providers specialization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -91,3 +95,4 @@ provided type: .. literalinclude:: ../../examples/providers/singleton_provided_type.py :language: python + :linenos: diff --git a/docs/providers/static.rst b/docs/providers/static.rst index ec8f5605..508afdff 100644 --- a/docs/providers/static.rst +++ b/docs/providers/static.rst @@ -19,3 +19,4 @@ Example: .. literalinclude:: ../../examples/providers/static.py :language: python + :linenos: