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.
Checks
assert base.derived == ("Real",)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | measured | test_a_class_declared_in_test_code_is_not_in_the_hierarchy → header_classes → table_exists |
| REQ-DDB-WIKI-053 | measured | test_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
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.
Checks
assert by["ns::ChatAdapter"].derived == ("ns::QwenAdapter",)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | measured | test_a_class_is_found_by_its_members_scope_not_only_its_file → header_classes → table_exists |
| REQ-DDB-WIKI-053 | measured | test_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
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.
Checks
assert _qualified_only(("FilesystemServer", "GitServer", "entropic::FilesystemServer", "entropic::GitServer") ) == ("entropic::FilesystemServer", "entropic::GitServer", )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-053 | catalog |
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
test_a_class_shows_its_bases_and_derived
None test_wiki_apiref.test_a_class_shows_its_bases_and_derived()
Inheritance.
Checks
assert by_name["ChatAdapter"].bases == ("Base",)assert by_name["ChatAdapter"].derived == ("QwenAdapter",)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | measured | test_a_class_shows_its_bases_and_derived → header_classes → table_exists |
| REQ-DDB-WIKI-053 | measured | test_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
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.
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | inferred | test_a_declaration_takes_the_parts_only_its_definition_documents → header_symbols → doc_text → strip_xml |
| REQ-DDB-WIKI-053 | measured | test_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
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.
Checks
assert doc.params == (("hash", "", "Content hash."),)assert doc.returns == ("Count.",)assert set(doc.fields) == {
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | inferred | test_a_declared_tag_inside_a_return_or_param_is_split_out → parse_doc → doc_text → strip_xml |
| REQ-DDB-WIKI-053 | measured | test_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
test_a_declared_tag_is_a_labelled_field
None test_wiki_apiref.test_a_declared_tag_is_a_labelled_field()
Declared tags as fields.
Checks
assert doc.fields == (("threadsafety", "Single-threaded init/destroy."),)assert "@threadsafety" not in doc.prose
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | inferred | test_a_declared_tag_is_a_labelled_field → parse_doc → doc_text → strip_xml |
| REQ-DDB-WIKI-053 | measured | test_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
test_a_function_pointer_typedef_reads_as_c
None test_wiki_apiref.test_a_function_pointer_typedef_reads_as_c()
Hook typedef signature.
Checks
assert sig == "typedef int(*cb_t)(int x)"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-053 | catalog |
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
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.
Checks
assert "<code>int demo_open(const char *path)</code>" in html and "Open a store." in htmlassert "DEMO_READ" in html and "= 1" in htmlassert "demo_cb" in html and 'class="hook"' in htmlassert "DEMO_VERSION" in htmlassert "flush" in store and "A store." in html
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | measured | test_a_header_page_lists_its_public_api → header_classes → table_exists |
| REQ-DDB-WIKI-053 | measured | test_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
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.
Checks
assert parse_doc(xml).returns == ("OK on success. ERR on failure.",)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | inferred | test_a_return_repeated_inside_a_longer_one_is_shown_once → parse_doc → doc_text → strip_xml |
| REQ-DDB-WIKI-053 | measured | test_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
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 `<` and `&` are text, and the doc stays structured.
Checks
assert doc.params == (("n_tokens", "", "Count (fails when n_tokens < 2)."),)assert doc.returns == ("A std::atomic<bool> & a flag.",)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | inferred | test_code_text_doxygen_stored_verbatim_is_kept_and_structured → parse_doc → doc_text → strip_xml |
| REQ-DDB-WIKI-053 | measured | test_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
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.
Checks
assert header_symbols(_conn(), ()) == {}
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | inferred | test_no_declared_headers_means_no_reference → header_symbols → doc_text → strip_xml |
| REQ-DDB-WIKI-053 | measured | test_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
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.
Checks
assert list(headers) == ["include/demo/api.h"]assert "impl_only" not in names
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | inferred | test_only_declared_public_headers_are_read → header_symbols → doc_text → strip_xml |
| REQ-DDB-WIKI-053 | measured | test_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
test_params_returns_and_retvals_are_structured
None test_wiki_apiref.test_params_returns_and_retvals_are_structured()
Structured params and returns.
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | inferred | test_params_returns_and_retvals_are_structured → parse_doc → doc_text → strip_xml |
| REQ-DDB-WIKI-053 | measured | test_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
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.
Checks
assert "secret" not in names and "hidden" not in names
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | inferred | test_private_members_and_internal_symbols_are_not_public_api → header_symbols → doc_text → strip_xml |
| REQ-DDB-WIKI-053 | measured | test_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
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.
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | inferred | test_text_that_looks_like_a_doxygen_element_is_kept → doc_text → strip_xml |
| REQ-DDB-WIKI-053 | measured | test_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
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.
Checks
assert f"<dt>{label}</dt>" in html, labelassert '<code>handle</code> <span class="dir">out</span>' in html
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | inferred | test_the_entry_renders_labelled_lists → parse_doc → doc_text → strip_xml |
| REQ-DDB-WIKI-053 | measured | test_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
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.
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | inferred | test_the_flat_text_keeps_a_less_than_sign → doc_text → strip_xml |
| REQ-DDB-WIKI-053 | measured | test_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
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.
Checks
assert "docs/guide.md" in rels and not any(r.endswith("impact.md") for r in rels), rels
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_the_gates_own_report_is_not_swept_into_the_docs → impact_path → load_guard_config |
| REQ-DDB-GUARD-012 | inferred | test_the_gates_own_report_is_not_swept_into_the_docs → impact_path → load_guard_config → read_guard_config → read_requirements_section |
| REQ-DDB-GUARD-024 | inferred | test_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-015 | measured | test_the_gates_own_report_is_not_swept_into_the_docs → impact_path |
| REQ-DDB-WIKI-053 | catalog |
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
test_throws_are_rendered
None test_wiki_apiref.test_throws_are_rendered()
Throws.
Checks
assert doc.throws == (("std::runtime_error", "On a bad path."),)assert "<dt>Throws</dt>" in html
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | inferred | test_throws_are_rendered → parse_doc → doc_text → strip_xml |
| REQ-DDB-WIKI-053 | measured | test_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
test_traceability_tags_are_not_api_prose
None test_wiki_apiref.test_traceability_tags_are_not_api_prose()
Doc text without guard tags.
Checks
assert doc_text(xml) == "Hook points."
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-003 | inferred | test_traceability_tags_are_not_api_prose → doc_text → strip_xml |
| REQ-DDB-WIKI-053 | measured | test_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."