mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-11-04 18:07:44 +03:00 
			
		
		
		
	Update docs & examples
This commit is contained in:
		
							parent
							
								
									832518582a
								
							
						
					
					
						commit
						c5d8032e95
					
				
							
								
								
									
										
											BIN
										
									
								
								docs/images/providers/dependency.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								docs/images/providers/dependency.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 42 KiB  | 
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 41 KiB  | 
| 
						 | 
					@ -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::
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user