ra8-firmware
0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
check_markdown_references.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
# SPDX-License-Identifier: MIT
3
# Copyright (c) 2026 Brighton Sikarskie
4
"""Validate every first-party Markdown link, anchor, and repository path."""
5
6
from
__future__
import
annotations
7
8
import
argparse
9
import
json
10
import
subprocess
11
import
sys
12
from
pathlib
import
Path
13
14
sys.path.insert(0, str(Path(__file__).resolve().parent))
15
16
import
markdown_reference_selftest
17
import
markdown_references
as
core
18
19
20
def
main
() -> int:
21
"""Run the live Markdown audit, inventory mode, or detector selftest."""
22
parser = argparse.ArgumentParser(description=__doc__)
23
parser.add_argument(
"--selftest"
, action=
"store_true"
, help=
"run detector selftests"
)
24
parser.add_argument(
"--inventory"
, type=Path, help=
"write deterministic JSON evidence"
)
25
args = parser.parse_args()
26
if
args.selftest:
27
return
markdown_reference_selftest.selftest()
28
try
:
29
findings, counts, inventory = core.check_tree(core.REPO_ROOT)
30
except
(core.CheckError, OSError, subprocess.SubprocessError, UnicodeError)
as
exc:
31
print(f
"check_markdown_references.py: ERROR: {exc}"
, file=sys.stderr)
32
return
2
33
if
args.inventory
is
not
None
:
34
payload = {
"schema"
: 1,
"counts"
: counts,
"inventory"
: inventory}
35
rendered = json.dumps(payload, indent=2, sort_keys=
True
) +
"\n"
36
args.inventory.write_text(rendered, encoding=
"ascii"
)
37
if
findings:
38
for
finding
in
sorted(findings, key=
lambda
item: (item.path, item.line, item.kind)):
39
print(finding.render(), file=sys.stderr)
40
print(
41
f
"check_markdown_references.py: FAIL ({len(findings)} findings; {counts})"
,
42
file=sys.stderr,
43
)
44
return
1
45
print(f
"Markdown references clean ({counts})"
)
46
return
0
47
48
49
if
__name__ ==
"__main__"
:
50
sys.exit(
main
())
main
void main(void)
The application entry point Reset_Handler hands control to.
Definition
main.c:298
scripts
checks
check_markdown_references.py
Generated by
1.16.1