"""
Provide the HTML API, for generating HTML pages.
"""
from __future__ import annotations
from abc import ABC, abstractmethod
from threading import Lock
from typing import MutableSequence, TYPE_CHECKING, final
from typing_extensions import override
from betty.link import Link
from betty.serde.dump import Dumpable, DumpMapping, Dump
if TYPE_CHECKING:
from betty.locale.localizable import (
Localizable,
)
from betty.ancestry.citation import Citation
from collections.abc import Sequence
[docs]
class CssProvider(ABC):
"""
Provide CSS for HTML pages.
"""
@property
@abstractmethod
def public_css_paths(self) -> Sequence[str]:
"""
The public URL paths to the CSS files to include in each HTML page.
"""
pass
[docs]
class JsProvider(ABC):
"""
Provide JavaScript for HTML pages.
"""
@property
@abstractmethod
def public_js_paths(self) -> Sequence[str]:
"""
The public URL paths to the JavaScript files to include in each HTML page.
"""
pass
[docs]
@final
class NavigationLink(Link):
"""
A navigation link.
"""
[docs]
def cite(self, citation: Citation) -> int:
"""
Reference a citation.
:returns: The citation's sequential reference number.
"""
with self._lock:
if citation not in self._cited:
self._cited.append(citation)
return self._cited.index(citation) + 1