test_wiki_apiref.py

tests/test_wiki_apiref.py

The public-API reference: one page per declared public header, from the index (PAPI, 2.0.0).

test_a_class_declared_in_test_code_is_not_in_the_hierarchy

None test_wiki_apiref.test_a_class_declared_in_test_code_is_not_in_the_hierarchy()

Hierarchy excludes test classes.

tests/test_wiki_apiref.py:221

Show on the map →

Called by none

Calls header_classes

Checks

  • assert base.derived == ("Real",)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003measuredtest_a_class_declared_in_test_code_is_not_in_the_hierarchy → header_classes → table_exists
REQ-DDB-WIKI-053measuredtest_a_class_declared_in_test_code_is_not_in_the_hierarchy → header_classes → doc_text
Source · 28 lines
def test_a_class_declared_in_test_code_is_not_in_the_hierarchy() -> None:
    """FOUND ON ENTROPIC'S INDEX: `ChatAdapter`'s derived list carried test fixtures
    (`anonymous_namespace{adapter_base_test.cpp}::TestAdapter`). Test code is not public API.

    @brief Hierarchy excludes test classes.
    """
    import sqlite3

    from clew.wiki.apiref import header_classes

    conn = sqlite3.connect(":memory:")
    conn.executescript(
        "CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT, type INT, found INT);"
        "CREATE TABLE compounddef (rowid INTEGER PRIMARY KEY, name TEXT, kind TEXT, prot INT,"
        " file_id INT, line INT, briefdescription TEXT, detaileddescription TEXT);"
        "CREATE TABLE compoundref (rowid INTEGER PRIMARY KEY, base_rowid INT, derived_rowid INT,"
        " prot INT, virt INT);"
        "CREATE TABLE test_scope (path_rowid INTEGER);"
        "INSERT INTO path VALUES (1, 'include/a.h', 1, 1), (2, 'tests/a_test.cpp', 1, 1);"
        "INSERT INTO compounddef VALUES (1, 'Base', 'class', 0, 1, 1, '', ''),"
        " (2, 'Real', 'class', 0, 1, 9, '', ''), (3, 'TestAdapter', 'class', 0, 2, 3, '', '');"
        "INSERT INTO compoundref VALUES (1, 1, 2, 0, 0), (2, 1, 3, 0, 0);"
        "INSERT INTO test_scope VALUES (2);"
    )
    (base,) = [c for c in header_classes(conn, "include/a.h") if c.name == "Base"]
    assert base.derived == ("Real",)

Activity · 6 steps
lines 227–227import sqlite3lines 229–229from clew.wiki.apiref import header_classeslines 231–231conn = sqlite3.connect(":memory:")lines 232–244conn.executescript( "CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT, type INT, found INT);" "CREATE TABLE compounddef (rowid INTEGER PRIMARY KEY, name TEXT, kind TEXT, prot INT," " file_id INT, line INT, briefdescription TEXT, detaileddescription TEXT);" "CREATE TABLE compoundref (rowid INTEGER PRIMARY KEY, base_rowid INT, derived_rowid INT," " prot INT, virt INT);" "CREATE TABLE test_scope (path_rowid INTEGER);" "INSERT INTO path VALUES (1, 'include/a.h', 1, 1), (2, 'tests/a_test.cpp', 1, 1);" "INSERT INTO compounddef VALUES (1, 'Base', 'class', 0, 1, 1, '', '')," " (2, 'Real', 'class', 0, 1, 9, '', ''), (3, 'TestAdapter', 'class', 0, 2, 3, '', '');" "INSERT INTO compoundref VALUES (1, 1, 2, 0, 0), (2, 1, 3, 0, 0);" "INSERT INTO test_scope VALUES (2);" )lines 245–245(base,) = [c for c in header_classes(conn, "include/a.h") if c.name == "Base"]lines 246–246assert base.derived == ("Real",)

test_a_class_is_found_by_its_members_scope_not_only_its_file

None test_wiki_apiref.test_a_class_is_found_by_its_members_scope_not_only_its_file()

Classes found by name.

tests/test_wiki_apiref.py:350

Show on the map →

Called by none

Calls header_classes

Checks

  • assert by["ns::ChatAdapter"].derived == ("ns::QwenAdapter",)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003measuredtest_a_class_is_found_by_its_members_scope_not_only_its_file → header_classes → table_exists
REQ-DDB-WIKI-053measuredtest_a_class_is_found_by_its_members_scope_not_only_its_file → header_classes → doc_text
Source · 27 lines
def test_a_class_is_found_by_its_members_scope_not_only_its_file() -> None:
    """ENTROPIC'S AUDIT: `ChatAdapter` showed no hierarchy on its header's page on entropic's index,
    though the class's members were listed there. A class whose members a header declares is
    looked up by name, whichever file its compounddef records.

    @brief Classes found by name.
    """
    import sqlite3

    from clew.wiki.apiref import header_classes

    conn = sqlite3.connect(":memory:")
    conn.executescript(
        "CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT, type INT, found INT);"
        "CREATE TABLE compounddef (rowid INTEGER PRIMARY KEY, name TEXT, kind TEXT, prot INT,"
        " file_id INT, line INT, briefdescription TEXT, detaileddescription TEXT);"
        "CREATE TABLE compoundref (rowid INTEGER PRIMARY KEY, base_rowid INT, derived_rowid INT,"
        " prot INT, virt INT);"
        "INSERT INTO path VALUES (1, 'include/a.h', 1, 1), (2, 'src/a.cpp', 1, 1);"
        "INSERT INTO compounddef VALUES (1, 'ns::ChatAdapter', 'class', 0, 2, 1, '', ''),"
        " (2, 'ns::QwenAdapter', 'class', 0, 1, 9, '', '');"
        "INSERT INTO compoundref VALUES (1, 1, 2, 0, 0);"
    )
    by = {c.name: c for c in header_classes(conn, "include/a.h", scopes={"ns::ChatAdapter"})}
    assert by["ns::ChatAdapter"].derived == ("ns::QwenAdapter",)

Activity · 6 steps
lines 357–357import sqlite3lines 359–359from clew.wiki.apiref import header_classeslines 361–361conn = sqlite3.connect(":memory:")lines 362–372conn.executescript( "CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT, type INT, found INT);" "CREATE TABLE compounddef (rowid INTEGER PRIMARY KEY, name TEXT, kind TEXT, prot INT," " file_id INT, line INT, briefdescription TEXT, detaileddescription TEXT);" "CREATE TABLE compoundref (rowid INTEGER PRIMARY KEY, base_rowid INT, derived_rowid INT," " prot INT, virt INT);" "INSERT INTO path VALUES (1, 'include/a.h', 1, 1), (2, 'src/a.cpp', 1, 1);" "INSERT INTO compounddef VALUES (1, 'ns::ChatAdapter', 'class', 0, 2, 1, '', '')," " (2, 'ns::QwenAdapter', 'class', 0, 1, 9, '', '');" "INSERT INTO compoundref VALUES (1, 1, 2, 0, 0);" )lines 373–373by = {c.name: c for c in header_classes(conn, "include/a.h", scopes={"ns::ChatAdapter"})}lines 374–374assert by["ns::ChatAdapter"].derived == ("ns::QwenAdapter",)

test_a_class_named_twice_is_listed_once_by_its_qualified_name

None test_wiki_apiref.test_a_class_named_twice_is_listed_once_by_its_qualified_name()

Hierarchy names deduplicated.

tests/test_wiki_apiref.py:334

Show on the map →

Called by none

Calls _qualified_only

Checks

  • assert _qualified_only(("FilesystemServer", "GitServer", "entropic::FilesystemServer", "entropic::GitServer") ) == ("entropic::FilesystemServer", "entropic::GitServer", )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-053catalog
Source · 16 lines
def test_a_class_named_twice_is_listed_once_by_its_qualified_name() -> None:
    """ENTROPIC'S AUDIT: "Derived by FilesystemServer, …, entropic::FilesystemServer" — the index
    holds both spellings. The qualified one stays.

    @brief Hierarchy names deduplicated.
    """
    from clew.wiki.apiref import _qualified_only

    assert _qualified_only(
        ("FilesystemServer", "GitServer", "entropic::FilesystemServer", "entropic::GitServer")
    ) == (
        "entropic::FilesystemServer",
        "entropic::GitServer",
    )

Activity · 2 steps
lines 340–340from clew.wiki.apiref import _qualified_onlylines 342–347assert _qualified_only( ("FilesystemServer", "GitServer", "entropic::FilesystemServer", "entropic::GitServer") ) == ( "entropic::FilesystemServer", "entropic::GitServer", )

test_a_class_shows_its_bases_and_derived

None test_wiki_apiref.test_a_class_shows_its_bases_and_derived()

Inheritance.

tests/test_wiki_apiref.py:179

Show on the map →

Called by none

Calls header_classes

Checks

  • assert by_name["ChatAdapter"].bases == ("Base",)
  • assert by_name["ChatAdapter"].derived == ("QwenAdapter",)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003measuredtest_a_class_shows_its_bases_and_derived → header_classes → table_exists
REQ-DDB-WIKI-053measuredtest_a_class_shows_its_bases_and_derived → header_classes → doc_text
Source · 27 lines
def test_a_class_shows_its_bases_and_derived() -> None:
    """ENTROPIC'S GAP 3: no inheritance. From the index's `compoundref`: a class lists what it
    inherits from and what derives from it.

    @brief Inheritance.
    """
    import sqlite3

    from clew.wiki.apiref import header_classes

    conn = sqlite3.connect(":memory:")
    conn.executescript(
        "CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT, type INT, found INT);"
        "CREATE TABLE compounddef (rowid INTEGER PRIMARY KEY, name TEXT, kind TEXT, prot INT,"
        " file_id INT, line INT, briefdescription TEXT, detaileddescription TEXT);"
        "CREATE TABLE compoundref (rowid INTEGER PRIMARY KEY, base_rowid INT, derived_rowid INT,"
        " prot INT, virt INT);"
        "INSERT INTO path VALUES (1, 'include/a.h', 1, 1);"
        "INSERT INTO compounddef VALUES (1, 'ChatAdapter', 'class', 0, 1, 1, '', ''),"
        " (2, 'QwenAdapter', 'class', 0, 1, 9, '', ''), (3, 'Base', 'class', 0, 1, 20, '', '');"
        "INSERT INTO compoundref VALUES (1, 1, 2, 0, 0), (2, 3, 1, 0, 0);"
    )
    by_name = {c.name: c for c in header_classes(conn, "include/a.h")}
    assert by_name["ChatAdapter"].bases == ("Base",)
    assert by_name["ChatAdapter"].derived == ("QwenAdapter",)

Activity · 7 steps
lines 185–185import sqlite3lines 187–187from clew.wiki.apiref import header_classeslines 189–189conn = sqlite3.connect(":memory:")lines 190–200conn.executescript( "CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT, type INT, found INT);" "CREATE TABLE compounddef (rowid INTEGER PRIMARY KEY, name TEXT, kind TEXT, prot INT," " file_id INT, line INT, briefdescription TEXT, detaileddescription TEXT);" "CREATE TABLE compoundref (rowid INTEGER PRIMARY KEY, base_rowid INT, derived_rowid INT," " prot INT, virt INT);" "INSERT INTO path VALUES (1, 'include/a.h', 1, 1);" "INSERT INTO compounddef VALUES (1, 'ChatAdapter', 'class', 0, 1, 1, '', '')," " (2, 'QwenAdapter', 'class', 0, 1, 9, '', ''), (3, 'Base', 'class', 0, 1, 20, '', '');" "INSERT INTO compoundref VALUES (1, 1, 2, 0, 0), (2, 3, 1, 0, 0);" )lines 201–201by_name = {c.name: c for c in header_classes(conn, "include/a.h")}lines 202–202assert by_name["ChatAdapter"].bases == ("Base",)lines 203–203assert by_name["ChatAdapter"].derived == ("QwenAdapter",)

test_a_declaration_takes_the_parts_only_its_definition_documents

None test_wiki_apiref.test_a_declaration_takes_the_parts_only_its_definition_documents()

Declaration merges the definition's missing parts.

tests/test_wiki_apiref.py:295

Checks

  • assert open_.doc.params == (("path", "", "Where the store lives."),)
  • assert open_.doc.returns == ("0 on success.",)
  • assert "Returns 0 on success." in open_.detail or open_.detail == "Returns 0 on success."

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003inferredtest_a_declaration_takes_the_parts_only_its_definition_documents → header_symbols → doc_text → strip_xml
REQ-DDB-WIKI-053measuredtest_a_declaration_takes_the_parts_only_its_definition_documents → header_symbols
Source · 39 lines
def test_a_declaration_takes_the_parts_only_its_definition_documents() -> None:
    """ENTROPIC'S AUDIT (~23 functions): the header declaration carries prose, while doxygen put
    the structured `parameterlist` / `simplesect` on the DEFINITION's memberdef (the `.cpp`). Each
    part the declaration lacks — params, returns, throws — is taken from the definition; a part it
    has is kept.

    @brief Declaration merges the definition's missing parts.
    """
    import sqlite3

    from clew.wiki.apiref import header_symbols

    conn = sqlite3.connect(":memory:")
    conn.executescript(
        _SCHEMA.replace(
            "(1, 'include/demo/api.h', 1, 1), (2, 'src/impl.cpp', 1, 1)",
            "(1, 'include/demo/api.h', 1, 1), (2, 'src/impl.cpp', 1, 1)",
        )
    )
    conn.execute(
        "INSERT INTO memberdef VALUES (11, 'function', 'demo_open', NULL, 'int', 'int demo_open', "
        "'(const char *path)', NULL, '', ?, 5, 0, 2, 2)",
        (
            '<para><parameterlist kind="param"><parameteritem><parameternamelist>'
            "<parametername>path</parametername></parameternamelist><parameterdescription>"
            "<para>Where the store lives.</para></parameterdescription></parameteritem>"
            '</parameterlist><simplesect kind="return"><para>0 on success.</para></simplesect></para>',
        ),
    )
    (open_,) = [
        s
        for s in header_symbols(conn, ("include/**",))["include/demo/api.h"]
        if s.name == "demo_open"
    ]
    assert open_.doc.params == (("path", "", "Where the store lives."),)
    assert open_.doc.returns == ("0 on success.",)
    assert "Returns 0 on success." in open_.detail or open_.detail == "Returns 0 on success."

Activity · 9 steps
lines 303–303import sqlite3lines 305–305from clew.wiki.apiref import header_symbolslines 307–307conn = sqlite3.connect(":memory:")lines 308–313conn.executescript( _SCHEMA.replace( "(1, 'include/demo/api.h', 1, 1), (2, 'src/impl.cpp', 1, 1)", "(1, 'include/demo/api.h', 1, 1), (2, 'src/impl.cpp', 1, 1)", ) )lines 314–323conn.execute( "INSERT INTO memberdef VALUES (11, 'function', 'demo_open', NULL, 'int', 'int demo_open', " "'(const char *path)', NULL, '', ?, 5, 0, 2, 2)", ( '<para><parameterlist kind="param"><parameteritem><parameternamelist>' "<parametername>path</parametername></parameternamelist><parameterdescription>" "<para>Where the store lives.</para></parameterdescription></parameteritem>" '</parameterlist><simplesect kind="return"><para>0 on success.</para></simplesect></para>', ), )lines 324–328(open_,) = [ s for s in header_symbols(conn, ("include/**",))["include/demo/api.h"] if s.name == "demo_open" ]lines 329–329assert open_.doc.params == (("path", "", "Where the store lives."),)lines 330–330assert open_.doc.returns == ("0 on success.",)lines 331–331assert "Returns 0 on success." in open_.detail or open_.detail == "Returns 0 on success."

test_a_declared_tag_inside_a_return_or_param_is_split_out

None test_wiki_apiref.test_a_declared_tag_inside_a_return_or_param_is_split_out()

Declared tags inside returns and params.

tests/test_wiki_apiref.py:249

Show on the map →

Called by none

Calls parse_doc

Checks

  • assert doc.params == (("hash", "", "Content hash."),)
  • assert doc.returns == ("Count.",)
  • assert set(doc.fields) == {

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003inferredtest_a_declared_tag_inside_a_return_or_param_is_split_out → parse_doc → doc_text → strip_xml
REQ-DDB-WIKI-053measuredtest_a_declared_tag_inside_a_return_or_param_is_split_out → parse_doc
Source · 26 lines
def test_a_declared_tag_inside_a_return_or_param_is_split_out() -> None:
    """ENTROPIC'S AUDIT (19f439fb, 33 cases): with no ALIASES, doxygen runs `@threadsafety` into
    the paragraph before it — the return's or a parameter's. Declared tags are split out of those
    texts too.

    @brief Declared tags inside returns and params.
    """
    from clew.wiki.apiref import parse_doc

    xml = (
        '<para><parameterlist kind="param"><parameteritem><parameternamelist>'
        "<parametername>hash</parametername></parameternamelist><parameterdescription>"
        "<para>Content hash. @threadsafety Safe from any thread</para></parameterdescription>"
        "</parameteritem></parameterlist>"
        '<simplesect kind="return"><para>Count. @threadsafety Takes the root lock.</para>'
        "</simplesect></para>"
    )
    doc = parse_doc(xml, ("threadsafety",))
    assert doc.params == (("hash", "", "Content hash."),)
    assert doc.returns == ("Count.",)
    assert set(doc.fields) == {
        ("threadsafety", "Safe from any thread"),
        ("threadsafety", "Takes the root lock."),
    }

Activity · 6 steps
lines 256–256from clew.wiki.apiref import parse_doclines 258–265xml = ( '<para><parameterlist kind="param"><parameteritem><parameternamelist>' "<parametername>hash</parametername></parameternamelist><parameterdescription>" "<para>Content hash. @threadsafety Safe from any thread</para></parameterdescription>" "</parameteritem></parameterlist>" '<simplesect kind="return"><para>Count. @threadsafety Takes the root lock.</para>' "</simplesect></para>" )lines 266–266doc = parse_doc(xml, ("threadsafety",))lines 267–267assert doc.params == (("hash", "", "Content hash."),)lines 268–268assert doc.returns == ("Count.",)lines 269–272assert set(doc.fields) == { ("threadsafety", "Safe from any thread"), ("threadsafety", "Takes the root lock."), }

test_a_declared_tag_is_a_labelled_field

None test_wiki_apiref.test_a_declared_tag_is_a_labelled_field()

Declared tags as fields.

tests/test_wiki_apiref.py:150

Show on the map →

Called by none

Calls parse_doc

Checks

  • assert doc.fields == (("threadsafety", "Single-threaded init/destroy."),)
  • assert "@threadsafety" not in doc.prose

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003inferredtest_a_declared_tag_is_a_labelled_field → parse_doc → doc_text → strip_xml
REQ-DDB-WIKI-053measuredtest_a_declared_tag_is_a_labelled_field → parse_doc
Source · 13 lines
def test_a_declared_tag_is_a_labelled_field() -> None:
    """ENTROPIC'S GAP 1: `@threadsafety` (declared in `guard.validate.extra_tags`) printed raw. It
    is a labelled field; an undeclared `@word` stays in the prose as written.

    @brief Declared tags as fields.
    """
    from clew.wiki.apiref import parse_doc

    doc = parse_doc(_CREATE, ("threadsafety",))
    assert doc.fields == (("threadsafety", "Single-threaded init/destroy."),)
    assert "@threadsafety" not in doc.prose

Activity · 4 steps
lines 156–156from clew.wiki.apiref import parse_doclines 158–158doc = parse_doc(_CREATE, ("threadsafety",))lines 159–159assert doc.fields == (("threadsafety", "Single-threaded init/destroy."),)lines 160–160assert "@threadsafety" not in doc.prose

test_a_function_pointer_typedef_reads_as_c

None test_wiki_apiref.test_a_function_pointer_typedef_reads_as_c()

Hook typedef signature.

tests/test_wiki_apiref.py:86

Show on the map →

Called by none

Calls none

Checks

  • assert sig == "typedef int(*cb_t)(int x)"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-053catalog
Source · 13 lines
def test_a_function_pointer_typedef_reads_as_c() -> None:
    """FOUND ON ENTROPIC'S INDEX: doxygen's definition for a function-pointer typedef is
    `typedef int(*) cb_t(int x)` (arguments included), and appending them again garbled it. The
    reference shows the C a reader would write: `typedef int(*cb_t)(int x)`.

    @brief Hook typedef signature.
    """
    from clew.wiki.apiref import _signature

    sig = _signature("typedef", "typedef int(*) cb_t(int x)", "(int x)", "int(*)", "cb_t")
    assert sig == "typedef int(*cb_t)(int x)"

Activity · 3 steps
lines 93–93from clew.wiki.apiref import _signaturelines 95–95sig = _signature("typedef", "typedef int(*) cb_t(int x)", "(int x)", "int(*)", "cb_t")lines 96–96assert sig == "typedef int(*cb_t)(int x)"

test_a_header_page_lists_its_public_api

None test_wiki_apiref.test_a_header_page_lists_its_public_api()

Functions with signatures, enum values, hook typedefs, macros, class members.

tests/test_wiki_apiref.py:62

Show on the map →

Called by none

Calls _conn, api_html, header_classes, header_symbols

Checks

  • assert "<code>int demo_open(const char *path)</code>" in html and "Open a store." in html
  • assert "DEMO_READ" in html and "= 1" in html
  • assert "demo_cb" in html and 'class="hook"' in html
  • assert "DEMO_VERSION" in html
  • assert "flush" in store and "A store." in html

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003measuredtest_a_header_page_lists_its_public_api → header_classes → table_exists
REQ-DDB-WIKI-053measuredtest_a_header_page_lists_its_public_api → header_symbols
Source · 13 lines
def test_a_header_page_lists_its_public_api() -> None:
    """@brief Functions with signatures, enum values, hook typedefs, macros, class members."""
    conn = _conn()
    rel = "include/demo/api.h"
    html = api_html(rel, header_symbols(conn, ("include/**",))[rel], header_classes(conn, rel))
    assert "<code>int demo_open(const char *path)</code>" in html and "Open a store." in html
    assert "DEMO_READ" in html and "= 1" in html
    assert "demo_cb" in html and 'class="hook"' in html
    assert "DEMO_VERSION" in html
    store = html.split("demo::Store", 1)[1]
    assert "flush" in store and "A store." in html

Activity · 9 steps
lines 64–64conn = _conn()lines 65–65rel = "include/demo/api.h"lines 66–66html = api_html(rel, header_symbols(conn, ("include/**",))[rel], header_classes(conn, rel))lines 67–67assert "<code>int demo_open(const char *path)</code>" in html and "Open a store." in htmllines 68–68assert "DEMO_READ" in html and "= 1" in htmllines 69–69assert "demo_cb" in html and 'class="hook"' in htmllines 70–70assert "DEMO_VERSION" in htmllines 71–71store = html.split("demo::Store", 1)[1]lines 72–72assert "flush" in store and "A store." in html

test_a_return_repeated_inside_a_longer_one_is_shown_once

None test_wiki_apiref.test_a_return_repeated_inside_a_longer_one_is_shown_once()

Returns de-duplicated by containment.

tests/test_wiki_apiref.py:206

Show on the map →

Called by none

Calls parse_doc

Checks

  • assert parse_doc(xml).returns == ("OK on success. ERR on failure.",)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003inferredtest_a_return_repeated_inside_a_longer_one_is_shown_once → parse_doc → doc_text → strip_xml
REQ-DDB-WIKI-053measuredtest_a_return_repeated_inside_a_longer_one_is_shown_once → parse_doc
Source · 15 lines
def test_a_return_repeated_inside_a_longer_one_is_shown_once() -> None:
    """FOUND ON ENTROPIC'S INDEX: the definition's block repeats "ENTROPIC_OK on success." and the
    declaration's carries it plus its error list. A return contained in another is dropped.

    @brief Returns de-duplicated by containment.
    """
    from clew.wiki.apiref import parse_doc

    xml = (
        '<para><simplesect kind="return"><para>OK on success. ERR on failure.</para></simplesect></para>'
        '<para><simplesect kind="return"><para>OK on success.</para></simplesect></para>'
    )
    assert parse_doc(xml).returns == ("OK on success. ERR on failure.",)

Activity · 3 steps
lines 212–212from clew.wiki.apiref import parse_doclines 214–217xml = ( '<para><simplesect kind="return"><para>OK on success. ERR on failure.</para></simplesect></para>' '<para><simplesect kind="return"><para>OK on success.</para></simplesect></para>' )lines 218–218assert parse_doc(xml).returns == ("OK on success. ERR on failure.",)

test_code_text_doxygen_stored_verbatim_is_kept_and_structured

None test_wiki_apiref.test_code_text_doxygen_stored_verbatim_is_kept_and_structured()

Stray `&lt;` and `&amp;` are text, and the doc stays structured.

tests/test_wiki_apiref.py:399

Show on the map →

Called by none

Calls parse_doc

Checks

  • assert doc.params == (("n_tokens", "", "Count (fails when n_tokens < 2)."),)
  • assert doc.returns == ("A std::atomic<bool> & a flag.",)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003inferredtest_code_text_doxygen_stored_verbatim_is_kept_and_structured → parse_doc → doc_text → strip_xml
REQ-DDB-WIKI-053measuredtest_code_text_doxygen_stored_verbatim_is_kept_and_structured → parse_doc
Source · 22 lines
def test_code_text_doxygen_stored_verbatim_is_kept_and_structured() -> None:
    """ENTROPIC'S AUDIT OF f6ff1f7c (23 entries, 83 of 1,482 include/ descriptions): doxygen
    stores code text verbatim inside its XML, so `(n_tokens < 2)` or `std::atomic<bool>` made the
    fragment unparseable. The entry fell back to one flat paragraph with no Parameters or Returns,
    and the fallback stripped `< 2)` AS A TAG — text lost silently.

    @brief Stray `<` and `&` are text, and the doc stays structured.
    """
    from clew.wiki.apiref import parse_doc

    xml = (
        '<para><parameterlist kind="param"><parameteritem><parameternamelist>'
        "<parametername>n_tokens</parametername></parameternamelist><parameterdescription>"
        "<para>Count (fails when n_tokens < 2).</para></parameterdescription></parameteritem>"
        '</parameterlist><simplesect kind="return"><para>A std::atomic<bool> & a flag.</para>'
        "</simplesect></para>"
    )
    doc = parse_doc(xml)
    assert doc.params == (("n_tokens", "", "Count (fails when n_tokens < 2)."),)
    assert doc.returns == ("A std::atomic<bool> & a flag.",)

Activity · 5 steps
lines 407–407from clew.wiki.apiref import parse_doclines 409–415xml = ( '<para><parameterlist kind="param"><parameteritem><parameternamelist>' "<parametername>n_tokens</parametername></parameternamelist><parameterdescription>" "<para>Count (fails when n_tokens < 2).</para></parameterdescription></parameteritem>" '</parameterlist><simplesect kind="return"><para>A std::atomic<bool> & a flag.</para>' "</simplesect></para>" )lines 416–416doc = parse_doc(xml)lines 417–417assert doc.params == (("n_tokens", "", "Count (fails when n_tokens < 2)."),)lines 418–418assert doc.returns == ("A std::atomic<bool> & a flag.",)

test_no_declared_headers_means_no_reference

None test_wiki_apiref.test_no_declared_headers_means_no_reference()

`wiki.api` absent: nothing is read, so no tab is built.

tests/test_wiki_apiref.py:81

Show on the map →

Called by none

Calls _conn, header_symbols

Checks

  • assert header_symbols(_conn(), ()) == {}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003inferredtest_no_declared_headers_means_no_reference → header_symbols → doc_text → strip_xml
REQ-DDB-WIKI-053measuredtest_no_declared_headers_means_no_reference → header_symbols
Source · 5 lines
def test_no_declared_headers_means_no_reference() -> None:
    """@brief `wiki.api` absent: nothing is read, so no tab is built."""
    assert header_symbols(_conn(), ()) == {}

Activity · 1 steps
lines 83–83assert header_symbols(_conn(), ()) == {}

test_only_declared_public_headers_are_read

None test_wiki_apiref.test_only_declared_public_headers_are_read()

`include/**` holds the API; `src/impl.cpp` does not, whatever it defines.

tests/test_wiki_apiref.py:54

Show on the map →

Called by none

Calls _conn, header_symbols, list

Checks

  • assert list(headers) == ["include/demo/api.h"]
  • assert "impl_only" not in names

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003inferredtest_only_declared_public_headers_are_read → header_symbols → doc_text → strip_xml
REQ-DDB-WIKI-053measuredtest_only_declared_public_headers_are_read → header_symbols
Source · 8 lines
def test_only_declared_public_headers_are_read() -> None:
    """@brief `include/**` holds the API; `src/impl.cpp` does not, whatever it defines."""
    headers = header_symbols(_conn(), ("include/**",))
    assert list(headers) == ["include/demo/api.h"]
    names = {s.name for s in headers["include/demo/api.h"]}
    assert "impl_only" not in names

Activity · 4 steps
lines 56–56headers = header_symbols(_conn(), ("include/**",))lines 57–57assert list(headers) == ["include/demo/api.h"]lines 58–58names = {s.name for s in headers["include/demo/api.h"]}lines 59–59assert "impl_only" not in names

test_params_returns_and_retvals_are_structured

None test_wiki_apiref.test_params_returns_and_retvals_are_structured()

Structured params and returns.

tests/test_wiki_apiref.py:134

Show on the map →

Called by none

Calls parse_doc

Checks

  • assert doc.params == (("handle", "out", "Pointer to receive the new handle."),)
  • assert doc.returns == ("ENTROPIC_OK on success.",)
  • assert doc.retvals == (("ENTROPIC_ERROR_INVALID_ARGUMENT", "handle is NULL."),)
  • assert doc.prose == "Allocates an engine handle."

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003inferredtest_params_returns_and_retvals_are_structured → parse_doc → doc_text → strip_xml
REQ-DDB-WIKI-053measuredtest_params_returns_and_retvals_are_structured → parse_doc
Source · 16 lines
def test_params_returns_and_retvals_are_structured() -> None:
    """ENTROPIC'S GAP 2: parameters, the return and return values flattened into one paragraph.
    Doxygen stores them as `<parameterlist>` / `<simplesect kind="return">`; they are read as such,
    and the definition's identical return collapses into one.

    @brief Structured params and returns.
    """
    from clew.wiki.apiref import parse_doc

    doc = parse_doc(_CREATE, ("threadsafety",))
    assert doc.params == (("handle", "out", "Pointer to receive the new handle."),)
    assert doc.returns == ("ENTROPIC_OK on success.",)
    assert doc.retvals == (("ENTROPIC_ERROR_INVALID_ARGUMENT", "handle is NULL."),)
    assert doc.prose == "Allocates an engine handle."

Activity · 6 steps
lines 141–141from clew.wiki.apiref import parse_doclines 143–143doc = parse_doc(_CREATE, ("threadsafety",))lines 144–144assert doc.params == (("handle", "out", "Pointer to receive the new handle."),)lines 145–145assert doc.returns == ("ENTROPIC_OK on success.",)lines 146–146assert doc.retvals == (("ENTROPIC_ERROR_INVALID_ARGUMENT", "handle is NULL."),)lines 147–147assert doc.prose == "Allocates an engine handle."

test_private_members_and_internal_symbols_are_not_public_api

None test_wiki_apiref.test_private_members_and_internal_symbols_are_not_public_api()

`prot` private and a `\\internal`-documented function stay out.

tests/test_wiki_apiref.py:75

Show on the map →

Called by none

Calls _conn, header_symbols

Checks

  • assert "secret" not in names and "hidden" not in names

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003inferredtest_private_members_and_internal_symbols_are_not_public_api → header_symbols → doc_text → strip_xml
REQ-DDB-WIKI-053measuredtest_private_members_and_internal_symbols_are_not_public_api → header_symbols
Source · 6 lines
def test_private_members_and_internal_symbols_are_not_public_api() -> None:
    """@brief `prot` private and a `\\internal`-documented function stay out."""
    names = {s.name for s in header_symbols(_conn(), ("include/**",))["include/demo/api.h"]}
    assert "secret" not in names and "hidden" not in names

Activity · 2 steps
lines 77–77names = {s.name for s in header_symbols(_conn(), ("include/**",))["include/demo/api.h"]}lines 78–78assert "secret" not in names and "hidden" not in names

test_text_that_looks_like_a_doxygen_element_is_kept

None test_wiki_apiref.test_text_that_looks_like_a_doxygen_element_is_kept()

Unbalanced element names are text.

tests/test_wiki_apiref.py:434

Show on the map →

Called by none

Calls doc_text

Checks

  • assert (doc_text("<para>Path (e.g. <root>/sub/.gitignore).</para>") == "Path (e.g. <root>/sub/.gitignore)." )
  • assert doc_text('<para>{"summary":"<summary>"}</para>') == '{"summary":"<summary>"}'
  • assert (doc_text('<para>See <image type="html" name="a.png"/><ulink url="u">it</ulink>.</para>') == "See it ." )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003inferredtest_text_that_looks_like_a_doxygen_element_is_kept → doc_text → strip_xml
REQ-DDB-WIKI-053measuredtest_text_that_looks_like_a_doxygen_element_is_kept → doc_text
Source · 22 lines
def test_text_that_looks_like_a_doxygen_element_is_kept() -> None:
    """ENTROPIC'S AUDIT, the last 3 of 1,485: `<root>/sub/.gitignore` and `"summary":"<summary>"`
    are text, though `summary` is also a doxygen element name. An element name whose opens and
    closes do not balance is text.

    @brief Unbalanced element names are text.
    """
    from clew.wiki.apiref import doc_text

    assert (
        doc_text("<para>Path (e.g. <root>/sub/.gitignore).</para>")
        == "Path (e.g. <root>/sub/.gitignore)."
    )
    assert doc_text('<para>{"summary":"<summary>"}</para>') == '{"summary":"<summary>"}'
    ## A SELF-CLOSING element with attributes is markup, not an unclosed open. (A tag boundary is
    ## a space, as the regex strip always made it, so adjacent paragraphs never run together.)
    assert (
        doc_text('<para>See <image type="html" name="a.png"/><ulink url="u">it</ulink>.</para>')
        == "See it ."
    )

Activity · 4 steps
lines 441–441from clew.wiki.apiref import doc_textlines 443–446assert ( doc_text("<para>Path (e.g. <root>/sub/.gitignore).</para>") == "Path (e.g. <root>/sub/.gitignore)." )lines 447–447assert doc_text('<para>{"summary":"<summary>"}</para>') == '{"summary":"<summary>"}'lines 450–453assert ( doc_text('<para>See <image type="html" name="a.png"/><ulink url="u">it</ulink>.</para>') == "See it ." )

test_the_entry_renders_labelled_lists

None test_wiki_apiref.test_the_entry_renders_labelled_lists()

Parameters, Returns, Return values and the field, each under its own label.

tests/test_wiki_apiref.py:163

Show on the map →

Called by none

Calls parse_doc

Checks

  • assert f"<dt>{label}</dt>" in html, label
  • assert '<code>handle</code> <span class="dir">out</span>' in html

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003inferredtest_the_entry_renders_labelled_lists → parse_doc → doc_text → strip_xml
REQ-DDB-WIKI-053measuredtest_the_entry_renders_labelled_lists → parse_doc
Source · 16 lines
def test_the_entry_renders_labelled_lists() -> None:
    """@brief Parameters, Returns, Return values and the field, each under its own label."""
    from clew.wiki.apiref import Symbol, _entry, parse_doc

    doc = parse_doc(_CREATE, ("threadsafety",))
    html = _entry(
        Symbol(
            "function", "entropic_create", "", "int entropic_create(handle)", "", "", 1, doc=doc
        ),
        {},
    )
    for label in ("Parameters", "Returns", "Return values", "threadsafety"):
        assert f"<dt>{label}</dt>" in html, label
    assert '<code>handle</code> <span class="dir">out</span>' in html

Activity · 6 steps
lines 165–165from clew.wiki.apiref import Symbol, _entry, parse_doclines 167–167doc = parse_doc(_CREATE, ("threadsafety",))lines 168–173html = _entry( Symbol( "function", "entropic_create", "", "int entropic_create(handle)", "", "", 1, doc=doc ), {}, )lines 174–174◇ for label in ("Parameters", "Returns", "Return values", "threadsafety")lines 175–175assert f"<dt>{label}</dt>" in html, labellines 176–176assert '<code>handle</code> <span class="dir">out</span>' in html

test_the_flat_text_keeps_a_less_than_sign

None test_wiki_apiref.test_the_flat_text_keeps_a_less_than_sign()

doc_text keeps code text.

tests/test_wiki_apiref.py:421

Show on the map →

Called by none

Calls doc_text

Checks

  • assert doc_text("<para>Fails (n_tokens < 2) on a std::atomic<bool>.</para>") == ("Fails (n_tokens < 2) on a std::atomic<bool>." )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003inferredtest_the_flat_text_keeps_a_less_than_sign → doc_text → strip_xml
REQ-DDB-WIKI-053measuredtest_the_flat_text_keeps_a_less_than_sign → doc_text
Source · 13 lines
def test_the_flat_text_keeps_a_less_than_sign() -> None:
    """ENTROPIC'S AUDIT OF f6ff1f7c: "- ENTROPIC_ERROR_INVALID_CONFIG (n_tokens < 2)" rendered as
    "(n_tokens ENTROPIC_ERROR_EVAL_FAILED …" — briefs and the flat fallback stripped `< 2)` as a tag.

    @brief doc_text keeps code text.
    """
    from clew.wiki.apiref import doc_text

    assert doc_text("<para>Fails (n_tokens < 2) on a std::atomic<bool>.</para>") == (
        "Fails (n_tokens < 2) on a std::atomic<bool>."
    )

Activity · 2 steps
lines 427–427from clew.wiki.apiref import doc_textlines 429–431assert doc_text("<para>Fails (n_tokens < 2) on a std::atomic<bool>.</para>") == ( "Fails (n_tokens < 2) on a std::atomic<bool>." )

test_the_gates_own_report_is_not_swept_into_the_docs

None test_wiki_apiref.test_the_gates_own_report_is_not_swept_into_the_docs(tmp_path)

The impact report is not a doc page.

tests/test_wiki_apiref.py:377

Show on the map →

Called by none

Calls _prose, impact_path

Checks

  • assert "docs/guide.md" in rels and not any(r.endswith("impact.md") for r in rels), rels

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_the_gates_own_report_is_not_swept_into_the_docs → impact_path → load_guard_config
REQ-DDB-GUARD-012inferredtest_the_gates_own_report_is_not_swept_into_the_docs → impact_path → load_guard_config → read_guard_config → read_requirements_section
REQ-DDB-GUARD-024inferredtest_the_gates_own_report_is_not_swept_into_the_docs → impact_path → load_guard_config → read_guard_config → load_config → apply_opt_in_languages
REQ-DDB-WIKI-015measuredtest_the_gates_own_report_is_not_swept_into_the_docs → impact_path
REQ-DDB-WIKI-053catalog
Source · 22 lines
def test_the_gates_own_report_is_not_swept_into_the_docs(tmp_path) -> None:
    """ENTROPIC'S AUDIT: 12 toctree warnings for `docs/generated/impact`. The guard writes its
    impact report (`impact.md`, no title) under its `report_dir`, and a `docs/**` glob swept it in
    as a doc page. The wiki leaves the gate's report directory out of the prose.

    @brief The impact report is not a doc page.
    """
    from clew.wiki.build import _prose
    from clew.wiki.config import WikiConfig
    from clew.wiki.tracepages import impact_path

    (tmp_path / "docs").mkdir()
    (tmp_path / "docs" / "guide.md").write_text("# Guide\n")
    report = impact_path(tmp_path, WikiConfig()).parent
    report.mkdir(parents=True)
    (report / "impact.md").write_text("| req | fn |\n")
    source = tmp_path / "_src"
    source.mkdir()
    rels = {rel for _page, rel in _prose(tmp_path, WikiConfig(docs=("docs/**/*.md",)), source)}
    assert "docs/guide.md" in rels and not any(r.endswith("impact.md") for r in rels), rels

Activity · 12 steps
lines 384–384from clew.wiki.build import _proselines 385–385from clew.wiki.config import WikiConfiglines 386–386from clew.wiki.tracepages import impact_pathlines 388–388(tmp_path / "docs").mkdir()lines 389–389(tmp_path / "docs" / "guide.md").write_text("# Guide\n")lines 390–390report = impact_path(tmp_path, WikiConfig()).parentlines 391–391report.mkdir(parents=True)lines 392–392(report / "impact.md").write_text("| req | fn |\n")lines 393–393source = tmp_path / "_src"lines 394–394source.mkdir()lines 395–395rels = {rel for _page, rel in _prose(tmp_path, WikiConfig(docs=("docs/**/*.md",)), source)}lines 396–396assert "docs/guide.md" in rels and not any(r.endswith("impact.md") for r in rels), rels

test_throws_are_rendered

None test_wiki_apiref.test_throws_are_rendered()

Throws.

tests/test_wiki_apiref.py:275

Show on the map →

Called by none

Calls parse_doc

Checks

  • assert doc.throws == (("std::runtime_error", "On a bad path."),)
  • assert "<dt>Throws</dt>" in html

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003inferredtest_throws_are_rendered → parse_doc → doc_text → strip_xml
REQ-DDB-WIKI-053measuredtest_throws_are_rendered → parse_doc
Source · 20 lines
def test_throws_are_rendered() -> None:
    """ENTROPIC'S AUDIT (5 functions): `@throws` / `@exception` is doxygen's
    `parameterlist kind="exception"`, and was dropped.

    @brief Throws.
    """
    from clew.wiki.apiref import Symbol, _entry, parse_doc

    xml = (
        '<para><parameterlist kind="exception"><parameteritem><parameternamelist>'
        "<parametername>std::runtime_error</parametername></parameternamelist>"
        "<parameterdescription><para>On a bad path.</para></parameterdescription>"
        "</parameteritem></parameterlist></para>"
    )
    doc = parse_doc(xml)
    assert doc.throws == (("std::runtime_error", "On a bad path."),)
    html = _entry(Symbol("function", "f", "", "void f()", "", "", 1, doc=doc), {})
    assert "<dt>Throws</dt>" in html

Activity · 6 steps
lines 281–281from clew.wiki.apiref import Symbol, _entry, parse_doclines 283–288xml = ( '<para><parameterlist kind="exception"><parameteritem><parameternamelist>' "<parametername>std::runtime_error</parametername></parameternamelist>" "<parameterdescription><para>On a bad path.</para></parameterdescription>" "</parameteritem></parameterlist></para>" )lines 289–289doc = parse_doc(xml)lines 290–290assert doc.throws == (("std::runtime_error", "On a bad path."),)lines 291–291html = _entry(Symbol("function", "f", "", "void f()", "", "", 1, doc=doc), {})lines 292–292assert "<dt>Throws</dt>" in html

test_traceability_tags_are_not_api_prose

None test_wiki_apiref.test_traceability_tags_are_not_api_prose()

Doc text without guard tags.

tests/test_wiki_apiref.py:99

Show on the map →

Called by none

Calls doc_text

Checks

  • assert doc_text(xml) == "Hook points."

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003inferredtest_traceability_tags_are_not_api_prose → doc_text → strip_xml
REQ-DDB-WIKI-053measuredtest_traceability_tags_are_not_api_prose → doc_text
Source · 15 lines
def test_traceability_tags_are_not_api_prose() -> None:
    """FOUND ON ENTROPIC'S INDEX: `@req REQ-TYPE-002` and the `@version` simplesect read as
    documentation. They belong to the requirement pages; the API page shows the prose.

    @brief Doc text without guard tags.
    """
    from clew.wiki.apiref import doc_text

    xml = (
        "<para>Hook points. @req REQ-TYPE-002 @req REQ-TYPE-004 @utility </para>"
        '<simplesect kind="version"><para>2.0.6-rc16</para></simplesect>'
    )
    assert doc_text(xml) == "Hook points."

Activity · 3 steps
lines 105–105from clew.wiki.apiref import doc_textlines 107–110xml = ( "<para>Hook points. @req REQ-TYPE-002 @req REQ-TYPE-004 @utility </para>" '<simplesect kind="version"><para>2.0.6-rc16</para></simplesect>' )lines 111–111assert doc_text(xml) == "Hook points."

test_two_returns_share_one_definition

None test_wiki_apiref.test_two_returns_share_one_definition()

One dt, one dd per label.

tests/test_wiki_apiref.py:456

Show on the map →

Called by none

Calls _doc_lists

Checks

  • assert html.count("<dd>") == html.count("<dt>") == 1, html
  • assert "<li>A.</li><li>B.</li>" in html

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-053catalog
Source · 12 lines
def test_two_returns_share_one_definition() -> None:
    """P6 at 390px (owner Q/A 2026-11-20): an entry with two distinct returns emitted a second
    `<dd>` with no `<dt>`; the `dl.api-doc` grid put it in the LABEL column, which grew to the
    sentence's width (844px) and pushed the page sideways. Several returns are one list in one dd.

    @brief One dt, one dd per label.
    """
    from clew.wiki.apiref import Doc, _doc_lists

    html = _doc_lists(Doc(prose="", returns=("A.", "B.")))
    assert html.count("<dd>") == html.count("<dt>") == 1, html
    assert "<li>A.</li><li>B.</li>" in html

1 more lines, not shown

Activity · 4 steps
lines 463–463from clew.wiki.apiref import Doc, _doc_listslines 465–465html = _doc_lists(Doc(prose="", returns=("A.", "B.")))lines 466–466assert html.count("<dd>") == html.count("<dt>") == 1, htmllines 467–467assert "<li>A.</li><li>B.</li>" in html