click-contrib / sphinx-click

A Sphinx plugin to automatically document click-based applications
MIT License
212 stars 57 forks source link

Missing detection of envvars via auto_envvar_prefix-option #105

Closed PatrikHlobil closed 2 years ago

PatrikHlobil commented 2 years ago

Dear maintainers,

I first wish to thank you for your project. I love click and the abilility to autogenerate the CLI documentation.

As you show in your documentation, sphinx-click automatically detects explicitly passed environment variables like:

@greet.command()
@click.argument('user', envvar='USER')
def hello(user):
    """Greet a user."""
    click.echo('Hello %s' % user)

There is however no support for the detection of auto-generated envvars like in:

@greet.command(context_settings={"auto_envvar_prefix": "HELLO"},)
@click.argument('user')
def hello(user):
    """Greet a user."""
    click.echo('Hello %s' % user)

which can use the environment variable HELLO_USER for passing the user argument.

I looked at your code, but I am not familiar enough with the internals of click and sphinx to easily see how I could add this feature.

Best Patrik

stephenfin commented 2 years ago

TIL. I didn't know this was a thing but the docs prove it is. This would be a near enhancement if anyone wanted to work on this. If not, I'll find time eventually.