architecture.py

clew/wiki/architecture.py

The Architecture tab: C4's four levels, derived from the index (round 5, P5.6).

architecture_html

str clew.wiki.architecture.architecture_html(str title, dict graph, list[Entry] entries)

The four levels' HTML.

clew/wiki/architecture.py:100

Source · 15 lines
def architecture_html(title: str, graph: dict, entries: list[Entry]) -> str:
    """@brief L1 → L4, a section each. @return HTML."""
    comps = graph.get("components") or []
    first = [c for c in comps if not c.get("vendor")]
    vendor = [c for c in comps if c.get("vendor")]
    return "".join(
        (
            _section(1, "Context", _context(title, entries, vendor)),
            _section(2, "Containers", _containers(title, entries)),
            _section(3, "Components", _components(first, graph.get("links") or [])),
            _section(4, "Code", _code()),
        )
    )

Activity · 4 steps
lines 102–102comps = graph.get("components") or []lines 103–103first = [c for c in comps if not c.get("vendor")]lines 104–104vendor = [c for c in comps if c.get("vendor")]lines 105–112return "".join( ( _section(1, "Context", _context(title, entries, vendor)), _section(2, "Containers", _containers(title, entries)), _section(3, "Components", _components(first, graph.get("links") or [])), _section(4, "Code", _code()), ) )

Requirements

REQ-DDB-WIKI-046

architecture_page

str clew.wiki.architecture.architecture_page(str title, dict graph, list[Entry] entries, Path source)

Write the Architecture page.

clew/wiki/architecture.py:76

Source · 17 lines
def architecture_page(title: str, graph: dict, entries: list[Entry], source: Path) -> str:
    """@brief Write architecture.md. @return Page name."""
    lines = [
        "# Architecture",
        "",
        "The system at C4's four levels (S. Brown's C4 model), each drawn from the index. Anything "
        "C4 asks for that the index cannot show is left out and named as missing, not guessed.",
        "",
        "```{raw} html",
        architecture_html(title, graph, entries),
        "```",
        "",
    ]
    (Path(source) / "architecture.md").write_text("\n".join(lines), encoding="utf-8")
    return "architecture"

Activity · 3 steps
lines 78–88lines = [ "# Architecture", "", "The system at C4's four levels (S. Brown's C4 model), each drawn from the index. Anything " "C4 asks for that the index cannot show is left out and named as missing, not guessed.", "", "```{raw} html", architecture_html(title, graph, entries), "```", "", ]lines 89–89(Path(source) / "architecture.md").write_text("\n".join(lines), encoding="utf-8")lines 90–90return "architecture"

Requirements

REQ-DDB-WIKI-046