Ive sort of managed to implement something to this effect in python, and from another comment made me consider yanking it out to its own library.
I made a process where args are now in a toml file, with some various data for different operations, like whether its available in the CLI or API library, its arg flags, help text required value type, etc. From that, i can generate argparse args, documentation, code for other things, etc. Right now im generating args, docs, and a js code block from the same structure.
Heres the toml file: https://gitlab.com/accidentallythecable-public/prover-suite/...
And some docs that were generated from that: https://gitlab.com/accidentallythecable-public/prover-suite/...
Maybe it will give you some ideas on yours