-
Notifications
You must be signed in to change notification settings - Fork 13
Chore/click autodoc #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chore/click autodoc #118
Conversation
|
cool, PR already accepted, so this should be fixed soon: click-contrib/sphinx-click#64 |
# Conflicts: # docs/index.md
src/code42cli/options.py
Outdated
| hidden=True, | ||
| help="The name of the Code42 CLI profile to use when executing this command.", | ||
| ) | ||
| debug_option_quiet = click.option( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having to duplicate these definitions, I think we could make each of these options take a boolean as a parameter to indicate whether or not they are hidden. The default could be true since that's what we would want most of the time. Something like:
def profile_option(hidden=True):
opt = click.option(
"--profile",
expose_value=False,
callback=set_profile,
hidden=hidden,
help="The name of the Code42 CLI profile to use when executing this command.",
)
return opt
def sdk_options(func):
f = profile_option(True)(func)
...
return f
def quiet_sdk_options(func):
f = profile_option(False)(func)
...
return f
@sdk_options
def some_command()
passThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, and went a step further and make @sdk_options take the argument instead of two separate decorators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💥
This pulls in the sphinx-click extension to auto-generate documentation for commands.
Built docs for this branch are here: https://code42cli.readthedocs.io/en/chore-click_autodoc/commands.html
I opened a PR with the
sphinx-clickproject to fix the formatting on the option choices when there are lots of them or they're long (seehigh-risk-employee add --risk-tagfor example problem).Also, since it automatically documented the
--profileand--debugoptions on every command group, I made a new option decorator to quiet those flags where it makes sense. So now if you docode42 <cmd_group> -hyou won't get--debugor--profiledescriptions in the help text, but it will still work to pass them in at any position.