sphinx-doc / sphinx-argparse

A Sphinx extension to automatically document argparse commands and options
https://sphinx-argparse.readthedocs.org/
MIT License
32 stars 25 forks source link

Reusing `argparse-sphinx` within mkdocs #40

Closed tcompa closed 1 year ago

tcompa commented 1 year ago

This is a for-your-information issue, and I will close it right away.


Hi there, thanks for this nice tool. We are using sphinx-argparse to build the documentation of a simple CLI client (currently at https://fractal-analytics-platform.github.io/fractal/cli.html), and we appreciate its simplicity.

Together with @ychiucco we are now moving to mkdocs for a bunch of our Fractal repositories. Since we could not find a similar mkdocs-argparse package (while there exist mkdocs-click and mkdocs-typer), we tried to setup an example that leverages the sphinxarg.parser module (bundled in our repo with proper Copyright attribution - do let me know if any of this doesn't sound right!).

Our working solution is far from a clean one, and we are not planning to write a mkdocs-argparse package. I simply thought it would be useful to mention it here, in case others can find it useful. In mkdocs, we use the https://github.com/oprypin/mkdocs-gen-files plugin, and add these lines to the mkdocs.yml configuration file:

  - gen-files:
      scripts:
        - docs/gen_ref_pages.py

Then, in the gen_ref_pages.py script, we make use of sphinxarg.parser.parse_parser, and we add a bit of custom logic to prepare some simple markdown files (a very rough work-in-progress version of the script is available here). While being far from general/flexible, this solution covers our current needs - see screenshot here.