4444
4545
4646class App :
47+ """
48+ The main Ellar Application class.
49+ """
50+
4751 def __init__ (
4852 self ,
4953 config : "Config" ,
@@ -117,6 +121,11 @@ def get_interceptors(
117121 async def use_global_guards (
118122 self , * guards : t .Union ["GuardCanActivate" , t .Type ["GuardCanActivate" ]]
119123 ) -> None :
124+ """
125+ Registers global guards for the application.
126+
127+ :param guards: Guards to register.
128+ """
120129 async with self .with_injector_context ():
121130 use_global_guards (* guards )
122131
@@ -125,6 +134,11 @@ async def use_global_guards(
125134 async def use_global_interceptors (
126135 self , * interceptors : t .Union [EllarInterceptor , t .Type [EllarInterceptor ]]
127136 ) -> None :
137+ """
138+ Registers global interceptors for the application.
139+
140+ :param interceptors: Interceptors to register.
141+ """
128142 async with self .with_injector_context ():
129143 use_global_interceptors (* interceptors )
130144
@@ -173,11 +187,13 @@ def request_context(
173187 send : TSend = constants .empty_send ,
174188 ) -> HttpRequestConnectionContext :
175189 """
176- Create an RequestContext during request and provides instance for `current_connection`.
177- e.g
190+ Creates a RequestContext during a request and provides an instance for `current_connection`.
178191
192+ Example:
193+ ```python
179194 request = current_connection.switch_http_connection().get_request()
180195 websocket = current_connection.switch_to_websocket().get_client()
196+ ```
181197 """
182198 context_factory = self .injector .get (IHostContextFactory )
183199 return HttpRequestConnectionContext (
@@ -226,6 +242,14 @@ async def enable_versioning(
226242 default_version : t .Optional [str ] = None ,
227243 ** init_kwargs : t .Any ,
228244 ) -> None :
245+ """
246+ Enables API versioning for the application.
247+
248+ :param schema: Versioning scheme to use.
249+ :param version_parameter: Parameter name for versioning.
250+ :param default_version: Default version if none specified.
251+ :param init_kwargs: Additional arguments for the versioning scheme.
252+ """
229253 async with self .with_injector_context ():
230254 enable_versioning (
231255 schema ,
@@ -262,6 +286,11 @@ async def add_exception_handler(
262286 self ,
263287 * exception_handlers : IExceptionHandler ,
264288 ) -> None :
289+ """
290+ Registers global exception handlers.
291+
292+ :param exception_handlers: Exception handlers to register.
293+ """
265294 async with self .with_injector_context ():
266295 use_exception_handler (* exception_handlers )
267296
@@ -274,6 +303,11 @@ def reflector(self) -> Reflector:
274303 async def add_authentication_schemes (
275304 self , * authentication : AuthenticationHandlerType
276305 ) -> None :
306+ """
307+ Registers authentication schemes for the application.
308+
309+ :param authentication: Authentication schemes to register.
310+ """
277311 async with self .with_injector_context ():
278312 use_authentication_schemes (* authentication )
279313
@@ -319,7 +353,11 @@ def url_for(context: t.Dict, name: str, **path_params: t.Any) -> URL:
319353 return jinja_env
320354
321355 def setup_jinja_environment (self ) -> Environment :
322- """Sets up Jinja2 Environment and adds it to DI"""
356+ """
357+ Sets up the Jinja2 Environment and adds it to the dependency injection container.
358+
359+ :return: Configured Jinja2 Environment.
360+ """
323361 jinja_environment = self ._create_jinja_environment ()
324362
325363 self .injector .tree_manager .get_app_module ().add_provider (
0 commit comments