Improved documentation for cpl.application
This commit is contained in:
@@ -8,20 +8,26 @@ from cpl.environment import ApplicationEnvironmentABC
|
||||
|
||||
|
||||
class ApplicationABC(ABC):
|
||||
r"""ABC for the Application class
|
||||
|
||||
Parameters
|
||||
----------
|
||||
config: :class:`cpl.configuration.configuration_abc.ConfigurationABC`
|
||||
Contains object loaded from appsettings
|
||||
services: :class:`cpl.dependency_injection.service_provider_abc.ServiceProviderABC`
|
||||
Contains instances of prepared objects
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
"""
|
||||
ABC of application
|
||||
"""
|
||||
self._configuration: Optional[ConfigurationABC] = config
|
||||
self._environment: Optional[ApplicationEnvironmentABC] = self._configuration.environment
|
||||
self._services: Optional[ServiceProviderABC] = services
|
||||
|
||||
def run(self):
|
||||
"""
|
||||
Entry point
|
||||
:return:
|
||||
r"""Entry point
|
||||
|
||||
Called by custom Application.main
|
||||
"""
|
||||
try:
|
||||
self.configure()
|
||||
@@ -31,16 +37,16 @@ class ApplicationABC(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def configure(self):
|
||||
"""
|
||||
Prepare the application
|
||||
:return:
|
||||
r"""Configure the application
|
||||
|
||||
Called by :class:`cpl.application.application_abc.ApplicationABC.run`
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def main(self):
|
||||
"""
|
||||
Custom entry point
|
||||
:return:
|
||||
r"""Custom entry point
|
||||
|
||||
Called by :class:`cpl.application.application_abc.ApplicationABC.run`
|
||||
"""
|
||||
pass
|
||||
|
@@ -8,11 +8,15 @@ from cpl.dependency_injection.service_collection import ServiceCollection
|
||||
|
||||
|
||||
class ApplicationBuilder(ApplicationBuilderABC):
|
||||
r"""This is class is used to build a object of :class:`cpl.application.application_abc.ApplicationABC`
|
||||
|
||||
Parameter
|
||||
---------
|
||||
app: Type[:class:`cpl.application.application_abc.ApplicationABC`]
|
||||
Application to build
|
||||
"""
|
||||
|
||||
def __init__(self, app: Type[ApplicationABC]):
|
||||
"""
|
||||
Builder class for application
|
||||
"""
|
||||
ApplicationBuilderABC.__init__(self)
|
||||
self._app = app
|
||||
self._startup: Optional[StartupABC] = None
|
||||
@@ -22,18 +26,9 @@ class ApplicationBuilder(ApplicationBuilderABC):
|
||||
self._services = ServiceCollection(self._configuration)
|
||||
|
||||
def use_startup(self, startup: Type[StartupABC]):
|
||||
"""
|
||||
Sets the used startup class
|
||||
:param startup:
|
||||
:return:
|
||||
"""
|
||||
self._startup = startup(self._configuration, self._services)
|
||||
|
||||
def build(self) -> ApplicationABC:
|
||||
"""
|
||||
Creates application host and runtime
|
||||
:return:
|
||||
"""
|
||||
if self._startup is not None:
|
||||
self._startup.configure_configuration()
|
||||
self._startup.configure_services()
|
||||
|
@@ -6,25 +6,29 @@ from cpl.application.startup_abc import StartupABC
|
||||
|
||||
|
||||
class ApplicationBuilderABC(ABC):
|
||||
r"""ABC for the :class:`cpl.application.application_builder.ApplicationBuilder`"""
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self, *args):
|
||||
"""
|
||||
ABC of application builder
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def use_startup(self, startup: Type[StartupABC]):
|
||||
"""
|
||||
Sets the used startup class
|
||||
:param startup:
|
||||
:return:
|
||||
r"""Sets the custom startup class to use
|
||||
|
||||
Parameter
|
||||
---------
|
||||
startup: Type[:class:`cpl.application.startup_abc.StartupABC`]
|
||||
Type of :class:`cpl.application.startup_abc.StartupABC`
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def build(self) -> ApplicationABC:
|
||||
"""
|
||||
Creates application host and runtime
|
||||
:return:
|
||||
r"""Creates custom application object
|
||||
|
||||
Returns
|
||||
-------
|
||||
Object of :class:`cpl.application.application_abc.ApplicationABC`
|
||||
"""
|
||||
pass
|
||||
|
@@ -5,25 +5,28 @@ from cpl.dependency_injection.service_provider_abc import ServiceProviderABC
|
||||
|
||||
|
||||
class StartupABC(ABC):
|
||||
r"""ABC for the startup class"""
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self, *args):
|
||||
"""
|
||||
ABC for a startup class
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def configure_configuration(self) -> ConfigurationABC:
|
||||
"""
|
||||
Creates configuration of application
|
||||
:return: configuration
|
||||
r"""Creates configuration of application
|
||||
|
||||
Returns
|
||||
-------
|
||||
Object of :class:`cpl.configuration.configuration_abc.ConfigurationABC`
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def configure_services(self) -> ServiceProviderABC:
|
||||
"""
|
||||
Creates service provider
|
||||
:return: service provider
|
||||
r"""Creates service provider
|
||||
|
||||
Returns
|
||||
-------
|
||||
Object of :class:`cpl.dependency_injection.service_provider_abc.ServiceProviderABC`
|
||||
"""
|
||||
pass
|
||||
|
Reference in New Issue
Block a user