-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpublic_api_report.sh
More file actions
executable file
·53 lines (41 loc) · 1.45 KB
/
Copy pathpublic_api_report.sh
File metadata and controls
executable file
·53 lines (41 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
set -euo pipefail
# Generates a lightweight public-symbol inventory via rustdoc JSON.
# Requires nightly rustdoc. The output is diagnostic and deliberately lives
# under target/ so it cannot overwrite the curated public API contract.
RUSTDOCFLAGS="-D warnings -Zunstable-options --output-format json" \
cargo +nightly doc --no-deps --lib --all-features -Z unstable-options
JSON="target/doc/jvmti_bindings.json"
OUT="${OUT:-target/public-api-inventory.md}"
export OUT
python - <<'PY'
import json
import os
from pathlib import Path
json_path = Path("target/doc/jvmti_bindings.json")
if not json_path.exists():
raise SystemExit("rustdoc json not found: " + str(json_path))
j = json.loads(json_path.read_text())
# Very lightweight report: list top-level exports by name.
# We keep this simple to avoid a heavy dependency on rustdoc internals.
crate_index = j.get("index", {})
items = []
for k, v in crate_index.items():
if v.get("crate_id") == 0 and v.get("visibility") == "public":
name = v.get("name")
if name:
items.append(name)
items = sorted(set(items))
out = Path(os.environ["OUT"])
out.parent.mkdir(parents=True, exist_ok=True)
lines = [
"# Generated Public API Symbol Inventory",
"",
"(Generated by scripts/public_api_report.sh)",
"",
"Public item names across all modules:",
]
lines.extend([f"1. {name}" for name in items])
out.write_text("\n".join(lines) + "\n")
print(f"Wrote {out}")
PY