Repository navigation
Expand file tree
/
Copy pathgenerate_cli_docs.py
More file actions
62 lines (52 loc) · 1.59 KB
/
Copy pathgenerate_cli_docs.py
File metadata and controls
62 lines (52 loc) · 1.59 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
54
55
56
57
58
59
60
61
62
import subprocess
import sys
from pathlib import Path
COMMANDS = [
("plotter_pipeline.py", "Full photo/webcam to G-code pipeline"),
("webcam_capture.py", "Capture one image from a webcam"),
("picamera_capture.py", "Capture one image from a Raspberry Pi camera"),
("preprocess_portrait.py", "Preprocess a portrait photo"),
("bitmaptracer.py", "Trace a bitmap line drawing to SVG or G-code"),
("serial_gcode_sender.py", "Stream G-code to a serial printer"),
("embedded_button_runner.py", "Run the pipeline from a Raspberry Pi GPIO button"),
]
def get_help(script_name):
result = subprocess.run(
[sys.executable, script_name, "--help"],
cwd=Path(__file__).parent,
text=True,
capture_output=True,
check=True,
)
return result.stdout.strip()
def main():
lines = [
"# CLI Reference",
"",
"This file is generated from the current argparse help output.",
"",
"Regenerate it with:",
"",
"```powershell",
"python generate_cli_docs.py",
"```",
"",
]
for script_name, description in COMMANDS:
lines.extend(
[
f"## `{script_name}`",
"",
description,
"",
"```text",
get_help(script_name),
"```",
"",
]
)
output_path = Path(__file__).with_name("CLI.md")
output_path.write_text("\n".join(lines), encoding="utf-8")
print(f"Wrote {output_path}")
if __name__ == "__main__":
main()