Skip to content

Conversation

@timabrmsn
Copy link
Contributor

@timabrmsn timabrmsn commented Jul 23, 2020

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-click project to fix the formatting on the option choices when there are lots of them or they're long (see high-risk-employee add --risk-tag for example problem).

Also, since it automatically documented the --profile and --debug options on every command group, I made a new option decorator to quiet those flags where it makes sense. So now if you do code42 <cmd_group> -h you won't get --debug or --profile descriptions in the help text, but it will still work to pass them in at any position.

@timabrmsn
Copy link
Contributor Author

cool, PR already accepted, so this should be fixed soon: click-contrib/sphinx-click#64

hidden=True,
help="The name of the Code42 CLI profile to use when executing this command.",
)
debug_option_quiet = click.option(
Copy link
Contributor

@alanag13 alanag13 Jul 27, 2020

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()
    pass

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💥

@timabrmsn timabrmsn merged commit e54db83 into master Jul 28, 2020
@timabrmsn timabrmsn deleted the chore/click_autodoc branch December 28, 2020 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants