click-contrib / sphinx-click

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

Missing show_default detection via context_settings. #114

Closed u-shiori closed 3 months ago

u-shiori commented 1 year ago

Hi, maintainers.

The current sphinx-click does not reflect the value of show_default set in context_settings.

When implemented using context_settings as shown here,

@click.command(context_settings={"show_default": True})
@click.option('--no-set', default=0)
def foobar():
    """A sample command."""
    pass

ctx = click.Context(foobar, info_name='foobar', show_default=True)
output = list(ext._format_command(ctx, nested='short'))
print("\n".join(output))

I originally want output like: (defaults are shown)

A sample command.

.. program:: foobar
.. code-block:: shell

    foobar [OPTIONS]

.. rubric:: Options

.. option:: --no-set <no_set>

    :default: ``0``

but currently, it returns results like: (defaults are not shown)

A sample command.

.. program:: foobar
.. code-block:: shell

    foobar [OPTIONS]

.. rubric:: Options

.. option:: --no-set <no_set>

Note

u-shiori commented 1 year ago

I would like to submit a PR.