Update catalogs API docs

This commit is contained in:
Roman Mogilatov 2015-12-14 10:59:17 +02:00
parent 1ca17fdeff
commit 99cd7bfda6

View File

@ -30,13 +30,21 @@ class CatalogBundle(object):
:py:class:`CatalogBundle` is considered to be dependable on catalogs :py:class:`CatalogBundle` is considered to be dependable on catalogs
(:py:class:`DeclarativeCatalog` or :py:class:`DynamicCatalog`) entity by (:py:class:`DeclarativeCatalog` or :py:class:`DynamicCatalog`) entity by
its design. its design.
.. py:attribute:: catalog
Bundle's catalog.
:type: :py:class:`DeclarativeCatalog` | :py:class:`DynamicCatalog`
.. py:attribute:: providers
Dictionary of all providers.
:type: dict[str, :py:class:`dependency_injector.providers.Provider`]
""" """
catalog = None catalog = None
"""Bundle's catalog.
:type: :py:class:`DeclarativeCatalog` | :py:class:`DynamicCatalog`
"""
__IS_CATALOG_BUNDLE__ = True __IS_CATALOG_BUNDLE__ = True
__slots__ = ('providers', '__dict__') __slots__ = ('providers', '__dict__')
@ -57,15 +65,9 @@ class CatalogBundle(object):
:type providers: tuple[ :type providers: tuple[
:py:class:`dependency_injector.providers.Provider`] :py:class:`dependency_injector.providers.Provider`]
""" """
self.providers = dict() self.providers = dict((self.catalog.get_provider_bind_name(provider),
"""Dictionary of all providers. provider)
for provider in providers)
:type: dict[str, :py:class:`dependency_injector.providers.Provider`]
"""
for provider in providers:
provider_name = self.catalog.get_provider_bind_name(provider)
self.providers[provider_name] = provider
self.__dict__.update(self.providers) self.__dict__.update(self.providers)
super(CatalogBundle, self).__init__() super(CatalogBundle, self).__init__()
@ -137,6 +139,33 @@ class DynamicCatalog(object):
users=providers.Factory(UsersService)) users=providers.Factory(UsersService))
users_service = services.users() users_service = services.users()
.. py:attribute:: Bundle
Catalog's bundle class.
:type: :py:class:`CatalogBundle`
.. py:attribute:: name
Catalog's name.
By default, it is catalog's module + catalog's class name.
:type: str
.. py:attribute:: providers
Dictionary of all providers.
:type: dict[str, :py:class:`dependency_injector.providers.Provider`]
.. py:attribute:: overridden_by
Tuple of overriding catalogs.
:type: tuple[
:py:class:`DeclarativeCatalog` | :py:class:`DynamicCatalog`]
""" """
__IS_CATALOG__ = True __IS_CATALOG__ = True
@ -151,35 +180,11 @@ class DynamicCatalog(object):
dict[str, :py:class:`dependency_injector.providers.Provider`] dict[str, :py:class:`dependency_injector.providers.Provider`]
""" """
self.Bundle = CatalogBundle.sub_cls_factory(self) self.Bundle = CatalogBundle.sub_cls_factory(self)
"""Catalog's bundle class.
:type: :py:class:`CatalogBundle`
"""
self.name = '.'.join((self.__class__.__module__, self.name = '.'.join((self.__class__.__module__,
self.__class__.__name__)) self.__class__.__name__))
"""Catalog's name.
By default, it is catalog's module + catalog's class name.
:type: str
"""
self.providers = dict() self.providers = dict()
"""Dictionary of all providers.
:type: dict[str, :py:class:`dependency_injector.providers.Provider`]
"""
self.provider_names = dict() self.provider_names = dict()
self.overridden_by = tuple() self.overridden_by = tuple()
"""Tuple of overriding catalogs.
:type: tuple[
:py:class:`DeclarativeCatalog` | :py:class:`DynamicCatalog`]
"""
self.bind_providers(providers) self.bind_providers(providers)
super(DynamicCatalog, self).__init__() super(DynamicCatalog, self).__init__()
@ -568,58 +573,71 @@ class DeclarativeCatalog(object):
users = providers.Factory(UsersService) users = providers.Factory(UsersService)
users_service = Services.users() users_service = Services.users()
"""
Bundle = CatalogBundle .. py:attribute:: Bundle
"""Catalog's bundle class.
Catalog's bundle class.
:type: :py:class:`CatalogBundle` :type: :py:class:`CatalogBundle`
"""
name = str() .. py:attribute:: name
"""Read-only property that represents catalog's name.
Read-only property that represents catalog's name.
Catalog's name is catalog's module + catalog's class name. Catalog's name is catalog's module + catalog's class name.
:type: str :type: str
"""
cls_providers = dict() .. py:attribute:: cls_providers
"""Read-only dictionary of current catalog providers.
Read-only dictionary of current catalog providers.
:type: dict[str, :py:class:`dependency_injector.providers.Provider`] :type: dict[str, :py:class:`dependency_injector.providers.Provider`]
"""
inherited_providers = dict() .. py:attribute:: inherited_providers
"""Read-only dictionary of inherited providers.
Read-only dictionary of inherited providers.
:type: dict[str, :py:class:`dependency_injector.providers.Provider`] :type: dict[str, :py:class:`dependency_injector.providers.Provider`]
"""
providers = dict() .. py:attribute:: providers
"""Read-only dictionary of all providers.
Read-only dictionary of all providers.
:type: dict[str, :py:class:`dependency_injector.providers.Provider`] :type: dict[str, :py:class:`dependency_injector.providers.Provider`]
"""
overridden_by = tuple() .. py:attribute:: overridden_by
"""Tuple of overriding catalogs.
Tuple of overriding catalogs.
:type: tuple[:py:class:`DeclarativeCatalog` | :type: tuple[:py:class:`DeclarativeCatalog` |
:py:class:`DynamicCatalog`] :py:class:`DynamicCatalog`]
"""
is_overridden = bool .. py:attribute:: is_overridden
"""Read-only property that is set to ``True`` if catalog is overridden.
Read-only property that is set to ``True`` if catalog is overridden.
:type: bool :type: bool
.. py:attribute:: is_overridden
Read-only reference to the last overriding catalog, if any.
:type: :py:class:`DeclarativeCatalog` | :py:class:`DynamicCatalog` |
None
""" """
Bundle = CatalogBundle
name = str()
cls_providers = dict()
inherited_providers = dict()
providers = dict()
overridden_by = tuple()
is_overridden = bool
last_overriding = None last_overriding = None
"""Read-only reference to the last overriding catalog, if any.
:type: :py:class:`DeclarativeCatalog` | :py:class:`DynamicCatalog` | None
"""
_catalog = DynamicCatalog _catalog = DynamicCatalog