golem.views
AsciiDoc derived multi-view compilation engine for Golem.
Provides build-time synthesis of multi-view tabs from AsciiDoc listings:
source: syntax-highlighted AsciiDoc input (label: "AsciiDoc")asg: parsed AST -> ASG JSON -> syntax-highlighted JSON (label: "ASG")html: rendered HTML source -> syntax-highlighted HTML (label: "HTML")preview: live rendered HTML wrapped in<div class="rendered-preview">(label: "Preview")
Module Attributes
loggerDefault value:
logging.getLogger(__name__)VIEW_ATTRIBUTES(tuple[str, ...])
Default value: ('render', 'views', 'display', 'formats')
CANONICAL_VIEW_MAP(dict[str, str])
Default value: {'source': 'source', 'asciidoc': 'source', 'adoc': 'source', 'src': 'source', 'a... (truncated; see source)
VIEW_LABELS(dict[str, str])
Default value: {'source': 'AsciiDoc', 'asg': 'ASG', 'html': 'HTML', 'preview': 'Preview'}
parse_views_attribute
def parse_views_attribute(attributes: Optional[dict[str, Any]]) -> list[str]:
Extract and normalize requested view identifiers from node attributes.
Inspects the provided attributes mapping for any of the supported alias keys
(render, views, display, formats). Returns a list of canonical view
identifiers in the order requested.
attributes(dict[str, Any] | None)Node attribute dictionary.
list[str]Normalized list of canonical view identifiers (e.g.
["source", "preview"]).
generate_asciidoc_views
def generate_asciidoc_views(code_text: str, views: Union[str, Sequence[str]], highlighter: Optional[Callable[[str, str], Optional[str]]] = None, renderer_func: Optional[Union[BodyRendererProtocol, Callable[..., str]]] = None, renderer: Optional[Union[BodyRendererProtocol, Callable[..., str]]] = None, source_language: str = 'asciidoc') -> list[dict[str, str]]:
Synthesize multi-representation derived views for an AsciiDoc snippet.
Processes an AsciiDoc code listing into multiple derived representations at build time:
source: syntax-highlighted AsciiDoc input markup.asg: parsed AST converted to ASG dictionary, formatted as JSON, and syntax-highlighted.html: rendered HTML source markup, syntax-highlighted.preview: live rendered HTML wrapped in a<div class="rendered-preview">container.
code_text(str)Raw AsciiDoc source snippet to compile.
views(str | Sequence[str])Comma-separated string or sequence of requested view names.
highlighter(Callablestr, str], Optional[str | None, optional)Syntax highlighter callable. Defaults to
None.renderer_func(BodyRendererProtocol | Callable[..., str] | None, optional)Body renderer callable or protocol implementation. Defaults to
None.renderer(BodyRendererProtocol | Callable[..., str] | None, optional)Body renderer callable or protocol implementation alias. Defaults to
None.source_language(str, optional)Declared language of the source snippet for syntax highlighting. Defaults to
"asciidoc".
list[dict[str, str]]List of view dictionaries, each containing
id,label,content, andlanguage.
extract_listing_views
def extract_listing_views(node: dict[str, Any], highlighter: Optional[Callable[[str, str], Optional[str]]] = None, renderer_func: Optional[Union[BodyRendererProtocol, Callable[..., str]]] = None, renderer: Optional[Union[BodyRendererProtocol, Callable[..., str]]] = None) -> list[dict[str, str]]:
Extract requested derived views from an ASG listing block node.
node(dict[str, Any])ASG listing node dictionary.
highlighter(Callablestr, str], Optional[str | None, optional)Syntax highlighter callable. Defaults to
None.renderer_func(BodyRendererProtocol | Callable[..., str] | None, optional)Body renderer callable or protocol implementation. Defaults to
None.renderer(BodyRendererProtocol | Callable[..., str] | None, optional)Body renderer callable or protocol implementation alias. Defaults to
None.
list[dict[str, str]]List of derived view representations, or an empty list if no views were requested.