htmltable.py

clew/wiki/htmltable.py

HTML tables and source links for the wiki's pages.

code

str clew.wiki.htmltable.code(str value)

Repository text as inline code.

clew/wiki/htmltable.py:71

Show on the map →

Called by _body, _by_requirement, _catalogs_section, _evidence, _extent, _functions, _line, _problems, _requirement_table, _rules_section, _site_cell, flow_page

4 morelinked, nodes_page, test_link, traceability_page

Calls none

Source · 5 lines
def code(value: str) -> str:
    """@brief Escape as code. @return HTML."""
    return f"<code>{escape(value)}</code>"

Activity · 1 steps
lines 73–73return f"<code>{escape(value)}</code>"

Flows

gherkin

str clew.wiki.htmltable.gherkin(tuple[str,...]|list[str] lines)

Gherkin steps as a list, each keyword marked (W-1 / W-9, owner review 2026-11-22).

clew/wiki/htmltable.py:136

Show on the map →

Called by _preface, _what

Calls none

Source · 13 lines
def gherkin(lines: tuple[str, ...] | list[str]) -> str:
    """ONE RENDERING for a flow's scenario and a requirement's: declared text, escaped.

    @brief Scenario list.
    @return HTML.
    """
    rows = "".join(
        f'<li><b class="kw">{escape(kw)}</b> {escape(rest)}</li>'
        for kw, _sp, rest in (str(line).partition(" ") for line in lines if str(line).strip())
    )
    return f'<ol class="gherkin" aria-label="Scenario">{rows}</ol>' if rows else ""

Activity · 2 steps
lines 142–145rows = "".join( f'<li><b class="kw">{escape(kw)}</b> {escape(rest)}</li>' for kw, _sp, rest in (str(line).partition(" ") for line in lines if str(line).strip()) )lines 146–146return f'<ol class="gherkin" aria-label="Scenario">{rows}</ol>' if rows else ""

Flows

md_title

str clew.wiki.htmltable.md_title(str title)

A flow title (Markdown with inline code spans) as HTML.

clew/wiki/htmltable.py:125

Show on the map →

Called by _flow_cell, _flows, _section, _title_cell, _what, group_pages, requirement_pages

Calls none

Source · 6 lines
def md_title(title: str) -> str:
    """@brief Inline code spans become <code>, everything escaped. @return HTML."""
    parts = escape(title).split("`")
    return "".join(f"<code>{s}</code>" if i % 2 else s for i, s in enumerate(parts))

Activity · 2 steps
lines 127–127parts = escape(title).split("`")lines 128–128return "".join(f"<code>{s}</code>" if i % 2 else s for i, s in enumerate(parts))

Flows

plural

str clew.wiki.htmltable.plural(int n, str noun, str kind="")

A count with its noun, pluralised: "1 requirement", "3 tooling flows".

clew/wiki/htmltable.py:156

Show on the map →

Called by _functions, _message_of, _overview, _requirements, _role_block, flow_page, imported_trace, test_plurals_read_as_english, write_quick_views

Calls none

Source · 8 lines
def plural(n: int, noun: str, kind: str = "") -> str:
    """UX review E-22 (owner Q/A 2026-11-22): "1 tests flows", "Also reaches 1 requirements".

    @brief Pluralise.
    @return Text.
    """
    word = noun if n == 1 else f"{noun}s"
    return f"{n} {kind + ' ' if kind else ''}{word}"

1 more lines, not shown

Activity · 2 steps
lines 162–162word = noun if n == 1 else f"{noun}s"lines 163–163return f"{n} {kind + ' ' if kind else ''}{word}"

Flows

source_url

str clew.wiki.htmltable.source_url(str template, str commit, str rel, int line)

A source URL from the link template, or "" when no template is set.

clew/wiki/htmltable.py:104

Show on the map →

Called by _body, _definition, _issue_link, _section, link, step_data

Calls none

Source · 5 lines
def source_url(template: str, commit: str, rel: str, line: int) -> str:
    """@brief Format. @return URL."""
    return template.format(commit=commit, file=rel, line=line) if template and rel else ""

Activity · 1 steps
lines 106–106return template.format(commit=commit, file=rel, line=line) if template and rel else ""

Flows

table

str clew.wiki.htmltable.table(list[str] headers, list[list[str]] rows, str cls="", tuple[str,...] numeric=(), tuple[str,...] keep=(), list[str]|None row_attrs=None)

A table, its all-empty columns dropped and its empty cells dashed.

clew/wiki/htmltable.py:39

Show on the map →

Called by _body, _by_requirement, _catalogs_section, _requirement_table, _role_block, _rules_section, _tests, decisions_page, flow_page, nodes_page

Tested by

2 teststest_an_empty_cell_reads_as_a_dash_and_an_empty_column_is_dropped, test_tables_become_cards_and_diagrams_pan_on_a_narrow_screen

Calls none

Source · 27 lines
def table(
    headers: list[str],
    rows: list[list[str]],
    cls: str = "",
    numeric: tuple[str, ...] = (),
    keep: tuple[str, ...] = (),
    row_attrs: list[str] | None = None,
) -> str:
    """@brief Render a table. @return HTML."""
    used = [i for i, h in enumerate(headers) if h in keep or any(r[i] for r in rows)]
    align = {i: ' class="n"' if headers[i] in numeric else "" for i in used}
    label = {i: f' data-label="{escape(headers[i])}"' for i in used}
    head = "".join(f"<th{align[i]}>{escape(headers[i])}</th>" for i in used)
    attrs = row_attrs or [""] * len(rows)
    body = "".join(
        f"<tr{a}>"
        + "".join(f"<td{align[i]}{label[i]}>{r[i] or _NONE}</td>" for i in used)
        + "</tr>"
        for r, a in zip(rows, attrs, strict=True)
    )
    classes = f"clew {cls}".strip()
    return (
        f'<div class="table-wrap"><table class="{classes}"><thead><tr>{head}</tr></thead>'
        f"<tbody>{body}</tbody></table></div>"
    )

Activity · 8 steps
lines 48–48used = [i for i, h in enumerate(headers) if h in keep or any(r[i] for r in rows)]lines 49–49align = {i: ' class="n"' if headers[i] in numeric else "" for i in used}lines 50–50label = {i: f' data-label="{escape(headers[i])}"' for i in used}lines 51–51head = "".join(f"<th{align[i]}>{escape(headers[i])}</th>" for i in used)lines 52–52attrs = row_attrs or [""] * len(rows)lines 53–58body = "".join( f"<tr{a}>" + "".join(f"<td{align[i]}{label[i]}>{r[i] or _NONE}</td>" for i in used) + "</tr>" for r, a in zip(rows, attrs, strict=True) )lines 59–59classes = f"clew {cls}".strip()lines 60–63return ( f'<div class="table-wrap"><table class="{classes}"><thead><tr>{head}</tr></thead>' f"<tbody>{body}</tbody></table></div>" )

Requirements

REQ-DDB-WIKI-012

Flows

tag

str clew.wiki.htmltable.tag(str value)

A tier or status as a themed tag.

clew/wiki/htmltable.py:91

Show on the map →

Called by _catalogs_section, _requirement_table, _result, _rules_section, _tests, _tests_cell, _what, verifies_block

Calls none

Source · 5 lines
def tag(value: str) -> str:
    """@brief Tag. @return HTML."""
    return f'<span class="tier t-{escape(value)}">{escape(value)}</span>'

Activity · 1 steps
lines 93–93return f'<span class="tier t-{escape(value)}">{escape(value)}</span>'

Flows