mkdocs / mkdocs-click

An MkDocs extension to generate documentation for Click command line applications
https://pypi.org/project/mkdocs-click
Apache License 2.0
105 stars 15 forks source link

Allow options to contain multiple words #60

Closed Hnasar closed 10 months ago

Hnasar commented 1 year ago

This PR is based on and supersedes the one in #44. I added more explanation, a test, and fixed a small bug with trailing whitespace.


When documenting subcommands, sometimes mkdocs-click will only show the subcommand name. :prog_name: seems to be the right option to ensure the actuall command is shown, but due to an overly-strict regex, it used to ignore everything after the first whitespace. With this change, prog_name and other commands can contain multiple words in their values.

For example

::: mkdocs-click
    :module: foo.utils.bridge
    :prog_name: foo-utils bridge
    :command: cli

now properly renders as

foo-utils bridge [OPTIONS]

instead of

foo-utils [OPTIONS]

or

bridge [OPTIONS]

(^^ if prog_name wasn't specified at all)

Co-Authored-By: Bar Hochman bhochman@paloaltonetworks.com