Update docs & examples

This commit is contained in:
Roman Mogylatov 2017-12-21 22:54:44 +02:00
parent 832518582a
commit c5d8032e95
5 changed files with 8 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

View File

@ -1,9 +1,9 @@
External dependency providers Dependency providers
----------------------------- --------------------
.. currentmodule:: dependency_injector.providers .. currentmodule:: dependency_injector.providers
:py:class:`ExternalDependency` provider can be useful for development of :py:class:`Dependency` provider can be useful for development of
self-sufficient libraries / modules / applications that have required external self-sufficient libraries / modules / applications that have required external
dependencies. dependencies.
@ -35,11 +35,10 @@ Example:
Instead of this, ``UsersService`` has external dependency, that has to Instead of this, ``UsersService`` has external dependency, that has to
be satisfied by cleint's code, out of library's scope. be satisfied by cleint's code, out of library's scope.
.. image:: /images/providers/external_dependency.png .. image:: /images/providers/dependency.png
.. literalinclude:: ../../examples/providers/external_dependency.py .. literalinclude:: ../../examples/providers/dependency.py
:language: python :language: python
:linenos: :linenos:
.. disqus:: .. disqus::

View File

@ -21,6 +21,6 @@ Providers package API docs - :py:mod:`dependency_injector.providers`
singleton singleton
callable callable
object object
external_dependency dependency
overriding overriding
custom custom

View File

@ -1,4 +1,4 @@
"""`ExternalDependency` providers example.""" """`Dependency` providers example."""
import sqlite3 import sqlite3
import contextlib import contextlib
@ -45,7 +45,7 @@ class UsersService(object):
# Database and UsersService providers: # Database and UsersService providers:
database = providers.ExternalDependency(instance_of=sqlite3.dbapi2.Connection) database = providers.Dependency(instance_of=sqlite3.dbapi2.Connection)
users_service_factory = providers.Factory(UsersService, users_service_factory = providers.Factory(UsersService,
database=database) database=database)