mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-29 04:53:59 +03:00
Update installation and introduction docs
This commit is contained in:
parent
876081fac6
commit
119ba9dda0
|
@ -12,7 +12,7 @@ framework can be installed from PyPi_:
|
||||||
pip install dependency_injector
|
pip install dependency_injector
|
||||||
|
|
||||||
# Installing particular version:
|
# Installing particular version:
|
||||||
pip install dependency_injector==0.9.0
|
pip install dependency_injector==0.11.0
|
||||||
|
|
||||||
Sources can be cloned from GitHub_:
|
Sources can be cloned from GitHub_:
|
||||||
|
|
||||||
|
@ -23,14 +23,14 @@ Sources can be cloned from GitHub_:
|
||||||
Also all *Dependency Injector* releases can be downloaded from
|
Also all *Dependency Injector* releases can be downloaded from
|
||||||
`GitHub releases page`_.
|
`GitHub releases page`_.
|
||||||
|
|
||||||
Verification of currently installed version could be done using ``di.VERSION``
|
Verification of currently installed version could be done using
|
||||||
constant:
|
:py:obj:`dependency_injector.VERSION` constant:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
>>> import dependency_injector as di
|
>>> from dependency_injector import VERSION
|
||||||
>>> di.VERSION
|
>>> VERSION
|
||||||
'0.10.0'
|
'0.11.0'
|
||||||
|
|
||||||
.. _PyPi: https://pypi.python.org/pypi/dependency_injector
|
.. _PyPi: https://pypi.python.org/pypi/dependency_injector
|
||||||
.. _GitHub: https://github.com/rmk135/dependency_injector
|
.. _GitHub: https://github.com/rmk135/dependency_injector
|
||||||
|
|
|
@ -57,27 +57,6 @@ framework:
|
||||||
|
|
||||||
Main idea of *Dependency Injector* is to keep dependencies under control.
|
Main idea of *Dependency Injector* is to keep dependencies under control.
|
||||||
|
|
||||||
Shortcuts
|
|
||||||
---------
|
|
||||||
|
|
||||||
*Dependency Injector* recommends to use such kind of import shortcut:
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import dependency_injector as di
|
|
||||||
|
|
||||||
- All *Dependency Injector* entities could be used just from top-level package
|
|
||||||
(like ``di.Factory``, ``di.inject``, ``di.AbstractCatalog`` and so on).
|
|
||||||
- Another one way is to use second level packages (like
|
|
||||||
``di.providers.Factory``, ``di.injections.inject``,
|
|
||||||
``di.catalog.AbstractCatalog`` and so on). It might be useful for improving
|
|
||||||
of readability in some cases.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
``import dependency_injector as di`` shortcut is used among current
|
|
||||||
documentation, images and examples.
|
|
||||||
|
|
||||||
Main entities
|
Main entities
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
@ -91,18 +70,21 @@ interaction with each other.
|
||||||
There are 3 main entities:
|
There are 3 main entities:
|
||||||
|
|
||||||
- Providers. Providers are strategies of accesing objects. For example,
|
- Providers. Providers are strategies of accesing objects. For example,
|
||||||
``di.providers.Factory`` creates new instance of provided
|
:py:class:`dependency_injector.providers.Factory` creates new instance of
|
||||||
class every time it is called. ``di.providers.Singleton`` creates
|
provided class every time it is called.
|
||||||
provided instance once and returns it on every next call. Providers
|
:py:class:`dependency_injector.providers.Singleton` creates provided
|
||||||
could be overridden by another providers. Base class is -
|
instance once and returns it on every next call. Providers could be
|
||||||
``di.providers.Provider``.
|
overridden by another providers. Base class is -
|
||||||
|
:py:class:`dependency_injector.providers.Provider`.
|
||||||
- Injections. Injections are instructions for making dependency injections
|
- Injections. Injections are instructions for making dependency injections
|
||||||
(there are several ways how they could be done). Injections are used mostly
|
(there are several ways how they could be done). Injections are used mostly
|
||||||
by ``di.providers.Factory`` and ``di.providers.Singleton`` providers, but
|
by :py:class:`dependency_injector.providers.Factory` and
|
||||||
these are not only cases. Base class is - ``di.injections.Injection``.
|
:py:class:`dependency_injector.providers.Singleton` providers, but
|
||||||
|
these are not only cases. Base class is -
|
||||||
|
:py:class:`dependency_injector.injections.Injection`.
|
||||||
- Catalogs. Catalogs are collections of providers. They are used for grouping
|
- Catalogs. Catalogs are collections of providers. They are used for grouping
|
||||||
of providers by some principles. Base class is -
|
of providers by some principles. Base class is -
|
||||||
``di.catalog.AbstractCatalog``.
|
:py:class:`dependency_injector.catalogs.DeclarativeCatalog`.
|
||||||
|
|
||||||
|
|
||||||
.. _SLOC: http://en.wikipedia.org/wiki/Source_lines_of_code
|
.. _SLOC: http://en.wikipedia.org/wiki/Source_lines_of_code
|
||||||
|
|
Loading…
Reference in New Issue
Block a user