Update injections API docs

This commit is contained in:
Roman Mogilatov 2015-12-14 10:22:15 +02:00
parent 790860f426
commit 1ca17fdeff

View File

@ -25,6 +25,18 @@ class Injection(object):
"""Base injection class. """Base injection class.
All injections extend this class. All injections extend this class.
.. py:attribute:: injectable
Injectable value, could be provider or any other object.
:type: object | :py:class:`dependency_injector.providers.Provider`
.. py:attribute:: injectable_is_provider
Flag that is set to ``True`` if injectable value is provider.
:type: bool
""" """
__IS_INJECTION__ = True __IS_INJECTION__ = True
@ -39,17 +51,7 @@ class Injection(object):
:py:class:`dependency_injector.providers.Provider` :py:class:`dependency_injector.providers.Provider`
""" """
self.injectable = injectable self.injectable = injectable
"""Injectable value, could be provider or any other object.
:type: object | :py:class:`dependency_injector.providers.Provider`
"""
self.injectable_is_provider = is_provider(injectable) self.injectable_is_provider = is_provider(injectable)
"""Flag that is set to ``True`` if injectable value is provider.
:type: bool
"""
super(Injection, self).__init__() super(Injection, self).__init__()
@property @property
@ -88,7 +90,14 @@ class Arg(Injection):
@six.python_2_unicode_compatible @six.python_2_unicode_compatible
class _NamedInjection(Injection): class _NamedInjection(Injection):
"""Base class of named injections.""" """Base class of named injections.
.. py:attribute:: name
Injection target's name (keyword argument, attribute, method).
:type: str
"""
__slots__ = ('name',) __slots__ = ('name',)
@ -104,11 +113,6 @@ class _NamedInjection(Injection):
:py:class:`dependency_injector.providers.Provider` :py:class:`dependency_injector.providers.Provider`
""" """
self.name = name self.name = name
"""Injection target's name (keyword argument, attribute, method).
:type: str
"""
super(_NamedInjection, self).__init__(injectable) super(_NamedInjection, self).__init__(injectable)
def __str__(self): def __str__(self):
@ -127,10 +131,11 @@ class _NamedInjection(Injection):
class KwArg(_NamedInjection): class KwArg(_NamedInjection):
"""Keyword argument injection.""" """Keyword argument injection.
name = None .. py:attribute:: name
"""Keyword argument's name.
Keyword argument's name.
:type: str :type: str
""" """
@ -139,10 +144,11 @@ class KwArg(_NamedInjection):
class Attribute(_NamedInjection): class Attribute(_NamedInjection):
"""Attribute injection.""" """Attribute injection.
name = None .. py:attribute:: name
"""Attribute's name.
Attribute's name.
:type: str :type: str
""" """
@ -151,10 +157,11 @@ class Attribute(_NamedInjection):
class Method(_NamedInjection): class Method(_NamedInjection):
"""Method injection.""" """Method injection.
name = None .. py:attribute:: name
"""Method's name.
Method's name.
:type: str :type: str
""" """