File: generate-command-docs.py

package info (click to toggle)
subuser 0.6.2-3
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 4,208 kB
  • sloc: python: 5,201; sh: 380; makefile: 73
file content (22 lines) | stat: -rwxr-xr-x 801 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/python3
import sys,subprocess
sys.path.append("../../logic")
import subuserlib.commands

builtInCommands = subuserlib.commands.getBuiltIn()

for command in builtInCommands:
  with open(command+".rst","w") as command_file:
    commandDocs = command + "\n"+("="*len(command))+"\n"
    print("Collecting help for:"+command)
    commandHelpOutput = subprocess.check_output(["../../logic/subuser",command,"--help"])
    commandHelpOutput= commandHelpOutput.decode()
    commandDocs += commandHelpOutput.replace("\n\n    $","\n::\n\n    $")
    command_file.write(commandDocs)

with open("index.rst",mode="w") as index:
  with open("index.rst.head",mode="r") as indexHead:
    index.write(indexHead.read())
  for command in builtInCommands:
    index.write("  "+command+"\n")
  index.write("\n")