mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-02-07 15:10:47 +03:00
Update @di.inject() documentation
This commit is contained in:
parent
0a4e8c6934
commit
c5c0fdbd05
|
@ -8,21 +8,21 @@ Current section of documentation describes advanced usage of
|
||||||
@inject decorator
|
@inject decorator
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
``@di.inject`` decorator can be used for making *inline* dependency injections.
|
``@di.inject()`` decorator can be used for making *inline* dependency
|
||||||
It *patches* decorated callable in such way that dependency injection will be
|
injections. It *patches* decorated callable in such way that dependency
|
||||||
done during every call of decorated callable.
|
injection will be done during every call of decorated callable.
|
||||||
|
|
||||||
``@di.inject`` decorator takes keyword argument, that will be injected during
|
``@di.inject()`` decorator takes keyword argument, that will be injected
|
||||||
every next call of decorated callback with the same name. Any Python object
|
during every next call of decorated callback with the same name. Any Python
|
||||||
will be injected *as is*, except ``di.Provider``'s, which will be called to
|
object will be injected *as is*, except ``di.Provider``'s, which will be
|
||||||
provide injectable values.
|
called to provide injectable values.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/advanced_usage/inject_decorator_simple.py
|
.. literalinclude:: ../../examples/advanced_usage/inject_decorator_simple.py
|
||||||
:language: python
|
:language: python
|
||||||
|
|
||||||
Example of usage ``@di.inject`` decorator with Flask:
|
Example of usage ``@di.inject()`` decorator with Flask:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/advanced_usage/inject_decorator_flask.py
|
.. literalinclude:: ../../examples/advanced_usage/inject_decorator_flask.py
|
||||||
:language: python
|
:language: python
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""`@di.inject` decorator and Flask view example."""
|
"""`@di.inject()` decorator and Flask view example."""
|
||||||
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import flask
|
import flask
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""`@di.inject` decorator simple example."""
|
"""`@di.inject()` decorator simple example."""
|
||||||
|
|
||||||
import dependency_injector as di
|
import dependency_injector as di
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user