productpage.py

clew/wiki/productpage.py

The product trace page: the composite requirement tree across pinned dependencies (GH #68).

product_html

str clew.wiki.productpage.product_html(Composite tree, Audience rules, frozenset[str] pages=frozenset())

The page body.

clew/wiki/productpage.py:82

Source · 27 lines
def product_html(tree: Composite, rules: Audience, pages: frozenset[str] = frozenset()) -> str:
    """A REQUIREMENT WITH A PAGE HERE LINKS TO IT (2.0.0, P5.4); one without a page stays text,
    so no link leads nowhere. Function and test names stay text: the tree carries bare names with
    no file, and a link to a same-named symbol elsewhere would be a confident wrong answer.

    @brief Tree, problems, unreached.
    @return HTML.
    """
    roots = frozenset(tree.nodes[r].catalog for r in tree.roots if r in tree.nodes)
    links = _Links(pages, roots)
    items = "".join(_item(tree, ref, rules, set(), links) for ref in tree.roots)
    parts = [f'<ul class="ptree">{items}</ul>', _problems(tree)]
    if tree.implemented_here:
        rows = "".join(_line(tree.nodes[r], rules, links=links) for r in tree.implemented_here)
        parts.append(
            f'<details class="implemented-here" open><summary>{len(tree.implemented_here)} '
            f"dependency requirement(s) this repository implements</summary><ul>{rows}</ul></details>"
        )
    if tree.unreached:
        rows = "".join(_line(tree.nodes[r], rules, links=links) for r in tree.unreached)
        parts.append(
            f'<details class="unreached"><summary>{len(tree.unreached)} dependency requirement(s) '
            f"nothing on this tree reaches</summary><ul>{rows}</ul></details>"
        )
    return "\n".join(p for p in parts if p)

Activity · 11 steps
lines 90–90roots = frozenset(tree.nodes[r].catalog for r in tree.roots if r in tree.nodes)lines 91–91links = _Links(pages, roots)lines 92–92items = "".join(_item(tree, ref, rules, set(), links) for ref in tree.roots)lines 93–93parts = [f'<ul class="ptree">{items}</ul>', _problems(tree)]lines 94–94◇ if tree.implemented_herelines 95–95rows = "".join(_line(tree.nodes[r], rules, links=links) for r in tree.implemented_here)lines 96–99parts.append( f'<details class="implemented-here" open><summary>{len(tree.implemented_here)} ' f"dependency requirement(s) this repository implements</summary><ul>{rows}</ul></details>" )lines 100–100◇ if tree.unreachedlines 101–101rows = "".join(_line(tree.nodes[r], rules, links=links) for r in tree.unreached)lines 102–105parts.append( f'<details class="unreached"><summary>{len(tree.unreached)} dependency requirement(s) ' f"nothing on this tree reaches</summary><ul>{rows}</ul></details>" )lines 106–106return "\n".join(p for p in parts if p)

Requirements

REQ-DDB-WIKI-040

product_markdown

str clew.wiki.productpage.product_markdown(Composite tree, Audience rules)

The Product trace as plain Markdown, for wikis that take only Markdown.

clew/wiki/productpage.py:187

Source · 24 lines
def product_markdown(tree: Composite, rules: Audience) -> str:
    """#73 item 1 (owner Q/A 2026-11-23, 2.1): an Azure DevOps code wiki takes Markdown only, and
    the tree existed only in the HTML site. SAME TREE, SAME STATES, NO HTML: nested lists, the
    evidence state in bold, why-not and the checkout on the line below.

    @brief Product trace Markdown.
    @return Markdown.
    """
    lines = ["# Product trace", "", _LEAD, ""]
    for ref in tree.roots:
        lines += _md_item(tree, ref, rules, set(), 0)
    problems = [f"- `{a}` satisfies `{b}`, which no catalogue holds" for a, b in tree.dangling]
    problems += [f"- {c}" for c in tree.conflicts]
    for heading, refs in (
        ("## Problems", None),
        ("## Dependency requirements this repository implements", tree.implemented_here),
        ("## Nothing on the tree reaches", tree.unreached),
    ):
        rows = problems if refs is None else [_md_line(tree.nodes[r], rules) for r in refs]
        if rows:
            lines += ["", heading, "", *rows]
    return "\n".join(lines) + "\n"

Activity · 10 steps
lines 195–195lines = ["# Product trace", "", _LEAD, ""]lines 196–196◇ for ref in tree.rootslines 197–197lines += _md_item(tree, ref, rules, set(), 0)lines 198–198problems = [f"- `{a}` satisfies `{b}`, which no catalogue holds" for a, b in tree.dangling]lines 199–199problems += [f"- {c}" for c in tree.conflicts]lines 200–200◇ for heading, refs in (lines 205–205rows = problems if refs is None else [_md_line(tree.nodes[r], rules) for r in refs]lines 206–206◇ if rowslines 207–207lines += ["", heading, "", *rows]lines 208–208return "\n".join(lines) + "\n"

Requirements

REQ-DDB-WIKI-040

product_page

str clew.wiki.productpage.product_page(Composite tree, Audience rules, Path source, frozenset[str] pages=frozenset())

Write the product trace page.

clew/wiki/productpage.py:56

Show on the map →

Called by _product_section

Calls product_html

Source · 18 lines
def product_page(
    tree: Composite, rules: Audience, source: Path, pages: frozenset[str] = frozenset()
) -> str:
    """@brief Write product.md. @return Page name."""
    lines = [
        "# Product trace",
        "",
        _LEAD,
        "",
        "```{raw} html",
        product_html(tree, rules, pages),
        "```",
        "",
    ]
    (Path(source) / "product.md").write_text("\n".join(lines), encoding="utf-8")
    return "product"

Activity · 3 steps
lines 60–69lines = [ "# Product trace", "", _LEAD, "", "```{raw} html", product_html(tree, rules, pages), "```", "", ]lines 70–70(Path(source) / "product.md").write_text("\n".join(lines), encoding="utf-8")lines 71–71return "product"

Requirements

REQ-DDB-WIKI-040