Source code for betty.extension.http_api_doc

"""Integrate Betty with `ReDoc <https://redocly.com/redoc/>`_."""

from __future__ import annotations

from collections.abc import Sequence
from pathlib import Path

from betty.app.extension import Extension, UserFacingExtension
from betty.extension.webpack import Webpack, WebpackEntrypointProvider
from betty.locale import Str


[docs] class HttpApiDoc(UserFacingExtension, WebpackEntrypointProvider):
[docs] @classmethod def name(cls) -> str: return "betty.extension.HttpApiDoc"
[docs] @classmethod def depends_on(cls) -> set[type[Extension]]: return {Webpack}
[docs] @classmethod def assets_directory_path(cls) -> Path: return Path(__file__).parent / "assets"
[docs] @classmethod def webpack_entrypoint_directory_path(cls) -> Path: return Path(__file__).parent / "webpack"
[docs] def webpack_entrypoint_cache_keys(self) -> Sequence[str]: return ()
[docs] @classmethod def label(cls) -> Str: return Str._("HTTP API Documentation")
[docs] @classmethod def description(cls) -> Str: return Str._( 'Display the HTTP API documentation in a user-friendly way using <a href="https://github.com/Redocly/redoc">ReDoc</a>.' )