betty.project.extension package¶
Submodules¶
Module contents¶
Provide Betty’s extension API.
- class betty.project.extension.ConfigurableExtension[source]¶
Bases:
Extension,Generic[_ConfigurationT],Configurable[_ConfigurationT]A configurable extension.
- Parameters:
args (
typing.Any)configuration (
typing.Optional[typing.TypeVar(_ConfigurationT, bound=betty.config.Configuration)])kwargs (
typing.Any)
- __init__(*args: Any, configuration: betty.project.extension._ConfigurationT | None = None, **kwargs: Any)[source]¶
- Parameters:
args (
typing.Any)configuration (
typing.Optional[typing.TypeVar(_ConfigurationT, bound=betty.config.Configuration)])kwargs (
typing.Any)
- abstract classmethod default_configuration() betty.project.extension._ConfigurationT[source]¶
Get this extension’s default configuration.
- Return type:
typing.TypeVar(_ConfigurationT, bound=betty.config.Configuration)
- exception betty.project.extension.CyclicDependencyError[source]¶
Bases:
ExtensionError,RuntimeErrorRaised when extensions define a cyclic dependency, e.g. two extensions depend on each other.
- Parameters:
extension_types (
typing.Iterable[type[betty.project.extension.Extension]])
- __init__(extension_types: Iterable[type[betty.project.extension.Extension]])[source]¶
- Parameters:
extension_types (
typing.Iterable[type[betty.project.extension.Extension]])
- betty.project.extension.EXTENSION_REPOSITORY: PluginRepository[Extension] = <betty.plugin.entry_point.EntryPointPluginRepository object>¶
The project extension plugin repository.
- class betty.project.extension.Extension[source]¶
Bases:
PluginIntegrate optional functionality with the Betty app.
- Parameters:
project (
betty.project.Project)args (
typing.Any)kwargs (
typing.Any)
- __init__(project: betty.project.Project, *args: Any, **kwargs: Any)[source]¶
- Parameters:
project (
betty.project.Project)args (
typing.Any)kwargs (
typing.Any)
- classmethod assets_directory_path() pathlib.Path | None[source]¶
Return the path on disk where the extension’s assets are located.
This may be anywhere in your Python package.
- Return type:
- classmethod comes_after() set[str][source]¶
The extensions that this one comes after.
The other extensions may or may not be enabled.
- classmethod comes_before() set[str][source]¶
The extensions that this one comes before.
The other extensions may or may not be enabled.
- disable_requirement() betty.requirement.Requirement[source]¶
Define the requirement for this extension to be disabled.
This defaults to the extension’s dependents.
- Return type:
- classmethod enable_requirement() betty.requirement.Requirement[source]¶
Define the requirement for this extension to be enabled.
This defaults to the extension’s dependencies.
- Return type:
- final class betty.project.extension.ExtensionDispatcher[source]¶
Bases:
DispatcherDispatch events to extensions.
- Parameters:
extensions (
betty.project.extension.Extensions)
- __init__(extensions: betty.project.extension.Extensions)[source]¶
- Parameters:
extensions (
betty.project.extension.Extensions)
- dispatch(target_type: type[Any]) Callable[[...], Awaitable[Sequence[Any]]][source]¶
Dispatch a single target.
- Parameters:
target_type (
type[typing.Any])- Return type:
typing.Callable[...,typing.Awaitable[typing.Sequence[typing.Any]]]
- exception betty.project.extension.ExtensionError[source]¶
Bases:
BaseExceptionA generic extension API error.
- class betty.project.extension.Extensions[source]¶
Bases:
ABCManage available extensions.
- abstract flatten() Iterator[betty.project.extension.Extension][source]¶
Get a sequence of topologically sorted extensions.
- Return type:
- final class betty.project.extension.ListExtensions[source]¶
Bases:
ExtensionsManage available extensions, backed by a list.
- Parameters:
extensions (
list[list[betty.project.extension.Extension]])
- __init__(extensions: list[list[betty.project.extension.Extension]])[source]¶
- Parameters:
extensions (
list[list[betty.project.extension.Extension]])
- flatten() Iterator[betty.project.extension.Extension][source]¶
Get a sequence of topologically sorted extensions.
- Return type:
- class betty.project.extension.Theme[source]¶
Bases:
ExtensionAn extension that is a front-end theme.
- Parameters:
project (
betty.project.Project)args (
typing.Any)kwargs (
typing.Any)
- async betty.project.extension.build_extension_type_graph(extension_types: Iterable[type[betty.project.extension.Extension]]) dict[type[betty.project.extension.Extension], set[type[betty.project.extension.Extension]]][source]¶
Build a dependency graph of the given extension types.
- Parameters:
extension_types (
typing.Iterable[type[betty.project.extension.Extension]])- Return type:
dict[type[betty.project.extension.Extension],set[type[betty.project.extension.Extension]]]