betty.project.extension package - Betty 0.4.0a3 documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.project.extension package

## Submodules

- betty.project.extension.requirement module
  - `Dependencies`
    - `Dependencies.__init__()`
    - `Dependencies.summary()`
  - `Dependents`
    - `Dependents.__init__()`
    - `Dependents.is_met()`
    - `Dependents.summary()`

## Module contents

Provide Betty’s extension API.

class betty.project.extension.ConfigurableExtension

  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)
    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

    Get this extension’s default configuration.

    Return type:

      `typing.TypeVar`(`_ConfigurationT`, bound= `betty.config.Configuration`)

exception betty.project.extension.CyclicDependencyError

  Bases: `ExtensionError`, `RuntimeError`

  Raised 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]])
    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

  Bases: `Plugin`

  Integrate 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)
    Parameters:

      - project (`betty.project.Project`)

      - args (`typing.Any`)

      - kwargs (`typing.Any`)

  classmethod assets_directory_path() → pathlib.Path | None

    Return the path on disk where the extension’s assets are located.

    This may be anywhere in your Python package.

    Return type:

      `pathlib.Path` | `None`

  classmethod comes_after() → set[str]

    The extensions that this one comes after.

    The other extensions may or may not be enabled.

    Return type:

      `set`[`str`]

  classmethod comes_before() → set[str]

    The extensions that this one comes before.

    The other extensions may or may not be enabled.

    Return type:

      `set`[`str`]

  classmethod depends_on() → set[str]

    The extensions this one depends on, and comes after.

    Return type:

      `set`[`str`]

  disable_requirement() → betty.requirement.Requirement

    Define the requirement for this extension to be disabled.

    This defaults to the extension’s dependents.

    Return type:

      `betty.requirement.Requirement`

  classmethod enable_requirement() → betty.requirement.Requirement

    Define the requirement for this extension to be enabled.

    This defaults to the extension’s dependencies.

    Return type:

      `betty.requirement.Requirement`

  property project: Project

    The project this extension runs within.

final class betty.project.extension.ExtensionDispatcher

  Bases: `Dispatcher`

  Dispatch events to extensions.

  Parameters:

    extensions (`betty.project.extension.Extensions`)

  __init__(extensions: betty.project.extension.Extensions)
    Parameters:

      extensions (`betty.project.extension.Extensions`)

  dispatch(target_type: type[Any]) → Callable[[...], Awaitable[Sequence[Any]]]

    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

  Bases: `BaseException`

  A generic extension API error.

class betty.project.extension.Extensions

  Bases: `ABC`

  Manage available extensions.

  abstract flatten() → Iterator[betty.project.extension.Extension]

    Get a sequence of topologically sorted extensions.

    Return type:

      `typing.Iterator`[`betty.project.extension.Extension`]

final class betty.project.extension.ListExtensions

  Bases: `Extensions`

  Manage available extensions, backed by a list.

  Parameters:

    extensions (`list`[`list`[`betty.project.extension.Extension`]])

  __init__(extensions: list[list[betty.project.extension.Extension]])
    Parameters:

      extensions (`list`[`list`[`betty.project.extension.Extension`]])

  flatten() → Iterator[betty.project.extension.Extension]

    Get a sequence of topologically sorted extensions.

    Return type:

      `typing.Iterator`[`betty.project.extension.Extension`]

class betty.project.extension.Theme

  Bases: `Extension`

  An 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]]]

  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`]]]