Source code for betty.project.extension.http_api_doc

"""Integrate Betty with `Swagger UI <https://swagger.io/tools/swagger-ui>`_."""

from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING, final

from typing_extensions import override

from betty.html import NavigationLinkProvider, NavigationLink
from betty.locale.localizable import _
from betty.plugin import ShorthandPluginBase
from betty.project.extension.webpack import Webpack
from betty.project.extension.webpack.build import EntryPointProvider


if TYPE_CHECKING:
    from betty.project.extension import Extension
    from betty.plugin import PluginIdentifier
    from collections.abc import Sequence


[docs] @final class HttpApiDoc(ShorthandPluginBase, EntryPointProvider, NavigationLinkProvider): """ Provide user-friendly HTTP API documentation. """ _plugin_id = "http-api-doc" _plugin_label = _("HTTP API Documentation") _plugin_description = _( 'Display the HTTP API documentation in a user-friendly way using <a href="https://swagger.io/tools/swagger-ui">Swagger UI</a>.' )
[docs] @override @classmethod def depends_on(cls) -> set[PluginIdentifier[Extension]]: return {Webpack}
[docs] @override @classmethod def assets_directory_path(cls) -> Path: return Path(__file__).parent / "assets"
[docs] @override @classmethod def webpack_entry_point_directory_path(cls) -> Path: return Path(__file__).parent / "webpack"
[docs] @override def webpack_entry_point_cache_keys(self) -> Sequence[str]: return ()