PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
 
Loading...
Searching...
No Matches
Functions | Variables
audit_generic_expansion Namespace Reference

Functions

dict load_contract ()
 Load the forbidden-signature contract.
 
 iter_markdown (dict contract)
 Yield every repository Markdown file inside the contract's scan scope.
 
str normalize (str text)
 Collapse whitespace so formatting changes cannot hide an exact template copy.
 
list[str] scan (dict contract)
 Collect every forbidden-signature hit in the Markdown corpus.
 
int main ()
 Fail when generic expansion debris is present in the Markdown corpus.
 

Variables

 REPO_ROOT = Path(__file__).resolve().parents[2]
 
str CONTRACT_PATH = REPO_ROOT / "tests" / "tooling" / "generic_expansion_contract.json"
 

Detailed Description

Reject generic documentation-expansion debris anywhere in the repository Markdown corpus.

Function Documentation

◆ load_contract()

dict audit_generic_expansion.load_contract ( )

Load the forbidden-signature contract.

Returns
Parsed contract mapping.

Definition at line 15 of file audit_generic_expansion.py.

15def load_contract() -> dict:
16 """!
17 @brief Load the forbidden-signature contract.
18 @return Parsed contract mapping.
19 """
20 return json.loads(CONTRACT_PATH.read_text(encoding="utf-8"))
21
22
Here is the caller graph for this function:

◆ iter_markdown()

audit_generic_expansion.iter_markdown ( dict  contract)

Yield every repository Markdown file inside the contract's scan scope.

Parameters
[in]contractParsed contract mapping.
Returns
Generator of Markdown paths.

Definition at line 23 of file audit_generic_expansion.py.

23def iter_markdown(contract: dict):
24 """!
25 @brief Yield every repository Markdown file inside the contract's scan scope.
26 @param[in] contract Parsed contract mapping.
27 @return Generator of Markdown paths.
28 """
29 excluded = set(contract["scan"]["exclude_dirs"])
30 for path in sorted(REPO_ROOT.rglob("*.md")):
31 if excluded.intersection(path.relative_to(REPO_ROOT).parts):
32 continue
33 yield path
34
35
Here is the caller graph for this function:

◆ normalize()

str audit_generic_expansion.normalize ( str  text)

Collapse whitespace so formatting changes cannot hide an exact template copy.

Parameters
[in]textRaw file text.
Returns
Whitespace-normalized text.

Definition at line 36 of file audit_generic_expansion.py.

36def normalize(text: str) -> str:
37 """!
38 @brief Collapse whitespace so formatting changes cannot hide an exact template copy.
39 @param[in] text Raw file text.
40 @return Whitespace-normalized text.
41 """
42 return " ".join(text.split())
43
44
Here is the caller graph for this function:

◆ scan()

list[str] audit_generic_expansion.scan ( dict  contract)

Collect every forbidden-signature hit in the Markdown corpus.

Parameters
[in]contractParsed contract mapping.
Returns
Human-readable violation lines.

Definition at line 45 of file audit_generic_expansion.py.

45def scan(contract: dict) -> list[str]:
46 """!
47 @brief Collect every forbidden-signature hit in the Markdown corpus.
48 @param[in] contract Parsed contract mapping.
49 @return Human-readable violation lines.
50 """
51 signatures = [
52 ("marker", contract["forbidden_markers"]),
53 ("heading", contract["forbidden_headings"]),
54 ("fragment", contract["forbidden_fragments"]),
55 ]
56 violations: list[str] = []
57 for path in iter_markdown(contract):
58 text = path.read_text(encoding="utf-8", errors="replace")
59 collapsed = normalize(text)
60 relative = path.relative_to(REPO_ROOT)
61 for kind, patterns in signatures:
62 for pattern in patterns:
63 if pattern in text or normalize(pattern) in collapsed:
64 violations.append(f"{relative}: forbidden {kind}: {pattern[:72]}")
65 return violations
66
67
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int audit_generic_expansion.main ( )

Fail when generic expansion debris is present in the Markdown corpus.

Returns
Process status code.

Definition at line 68 of file audit_generic_expansion.py.

68def main() -> int:
69 """!
70 @brief Fail when generic expansion debris is present in the Markdown corpus.
71 @return Process status code.
72 """
73 contract = load_contract()
74 violations = scan(contract)
75 if violations:
76 print("Generic documentation-expansion debris detected:", file=sys.stderr)
77 for violation in violations:
78 print(f" {violation}", file=sys.stderr)
79 print(
80 "\nThese signatures mark uniform agent-generated filler. Replace them with "
81 "guidance specific to this page's subject, or remove the section.",
82 file=sys.stderr,
83 )
84 return 1
85 print(f"Generic-expansion audit passed: {sum(1 for _ in iter_markdown(contract))} Markdown files clean.")
86 return 0
87
88
int main(int argc, char **argv)
Entry point for the postprocessor executable.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ REPO_ROOT

audit_generic_expansion.REPO_ROOT = Path(__file__).resolve().parents[2]

Definition at line 11 of file audit_generic_expansion.py.

◆ CONTRACT_PATH

str audit_generic_expansion.CONTRACT_PATH = REPO_ROOT / "tests" / "tooling" / "generic_expansion_contract.json"

Definition at line 12 of file audit_generic_expansion.py.