mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-11-04 01:47:36 +03:00 
			
		
		
		
	Add docs
This commit is contained in:
		
							parent
							
								
									c77737d32e
								
							
						
					
					
						commit
						568cbf01a0
					
				| 
						 | 
				
			
			@ -22,6 +22,7 @@ Providers package API docs - :py:mod:`dependency_injector.providers`
 | 
			
		|||
    callable
 | 
			
		||||
    coroutine
 | 
			
		||||
    object
 | 
			
		||||
    list
 | 
			
		||||
    dependency
 | 
			
		||||
    overriding
 | 
			
		||||
    custom
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										34
									
								
								docs/providers/list.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								docs/providers/list.rst
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,34 @@
 | 
			
		|||
List providers
 | 
			
		||||
--------------
 | 
			
		||||
 | 
			
		||||
.. currentmodule:: dependency_injector.providers
 | 
			
		||||
 | 
			
		||||
:py:class:`List` provider provides a list of values.
 | 
			
		||||
 | 
			
		||||
.. literalinclude:: ../../examples/providers/list.py
 | 
			
		||||
   :language: python
 | 
			
		||||
   :lines: 23-29
 | 
			
		||||
   :linenos:
 | 
			
		||||
 | 
			
		||||
:py:class:`List` provider is needed for injecting a list of dependencies. It handles
 | 
			
		||||
positional argument injections the same way as :py:class:`Factory` provider:
 | 
			
		||||
 | 
			
		||||
+ All providers (instances of :py:class:`Provider`) are called every time
 | 
			
		||||
  when injection needs to be done.
 | 
			
		||||
+ Providers could be injected "as is" (delegated), if it is defined explicitly. Check out
 | 
			
		||||
  :ref:`factory_providers_delegation`.
 | 
			
		||||
+ All other values are injected *"as is"*.
 | 
			
		||||
 | 
			
		||||
Full example:
 | 
			
		||||
 | 
			
		||||
.. literalinclude:: ../../examples/providers/list.py
 | 
			
		||||
   :language: python
 | 
			
		||||
   :emphasize-lines: 23-29
 | 
			
		||||
   :linenos:
 | 
			
		||||
 | 
			
		||||
.. note::
 | 
			
		||||
 | 
			
		||||
    Positional context argument injections and keyword argument injections are not
 | 
			
		||||
    supported.
 | 
			
		||||
 | 
			
		||||
.. disqus::
 | 
			
		||||
| 
						 | 
				
			
			@ -34,3 +34,12 @@ if __name__ == '__main__':
 | 
			
		|||
    assert isinstance(dispatcher.modules, list)
 | 
			
		||||
    assert dispatcher.modules[0].name == 'm1'
 | 
			
		||||
    assert dispatcher.modules[1].name == 'm2'
 | 
			
		||||
 | 
			
		||||
    # Call of dispatcher_factory() is equivalent to:
 | 
			
		||||
 | 
			
		||||
    dispatcher = Dispatcher(
 | 
			
		||||
        modules=[
 | 
			
		||||
            Module(name='m1'),
 | 
			
		||||
            Module(name='m2'),
 | 
			
		||||
        ],
 | 
			
		||||
    )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -1970,8 +1970,11 @@ cdef class List(Provider):
 | 
			
		|||
    """List provider provides a list of values.
 | 
			
		||||
 | 
			
		||||
    :py:class:`List` provider is needed for injecting a list of dependencies. It handles
 | 
			
		||||
    positional argument injections the same way like :py:class:`Callable` and :py:class:`Factory`
 | 
			
		||||
    providers. Keyword argument injections are not supported.
 | 
			
		||||
    positional argument injections the same way as :py:class:`Callable` and :py:class:`Factory`
 | 
			
		||||
    providers.
 | 
			
		||||
 | 
			
		||||
    Positional context argument injections and keyword argument injections are not
 | 
			
		||||
    supported.
 | 
			
		||||
 | 
			
		||||
    .. code-block:: python
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user