click-contrib/click-option-group

sphinx-click support

SurealCereal opened this issue · 7 comments

First, thanks so much for making click usable for my use case. Grouping functionality was exactly what was missing since migrating from the now somewhat abandoned docopt library.

I am using sphinx-click for producing documentation in HTML and markdown format. It works well, except RequiredMutuallyExclusiveOptionGroup are output in a strange way, for example:
image

--fake-xwweowenatfqasqhrcdsvpnbxvqgvo
<fake_xwweowenatfqasqhrcdsvpnbxvqgvo>

sphinx-click does not explicitly support click-option-group (there is certainly no code referencing any of the new classes). _helpers.py contains get_fake_option_name() which is where this entry is produced, called by _core.py:

# Add the fake invisible option to use for print nice title help for grouped options
self._add_title_fake_option(func)

Is there some way to work around this behavior?

@SurealCereal

It seems, sphinx-click ignores get_help_record method of Option class and re-implements it in ext:
https://github.com/click-contrib/sphinx-click/blob/7a7240b54911e7de1f67d514165ddd01f9575967/sphinx_click/ext.py#L31

Unfortunately, this means that we cannot customize this behavior in sphinx-click ext and we lose any custom help formatting for the options in sphinx docs. We could create an issue in sphinx-click about it.

Understood, thanks for the explanation. I'll create an issue in sphinx-click, and point them to this issue there.

Created: click-contrib/sphinx-click#60

@SurealCereal

Is there a way to hide/disable output for this element, or support it?

Will I answer here if you don't mind?

I can add hidden=True for fake options. In this case the group names and description will not be rendered in sphinx and also all its options will not be rendered with indentation. This does not affect --help in cli.

We can make it as a temporary workaround until we find a better solution.

@SurealCereal

Is there a way to hide/disable output for this element, or support it?

Will I answer here if you don't mind?

I can add hidden=True for fake options. In this case the group names and description will not be rendered in sphinx and also all its options will not be rendered with indentation. This does not affect --help in cli.

We can make it as a temporary workaround until we find a better solution.

Cool, thanks so much for the quick solution. I'll try it out as soon as that PR is merged.

Looks good. No more "fake" options, thanks!

You are welcome.

No more "fake" options

Yes, as well as groups, but it is better than "fake" options anyway. :)
I hope someday it will be improved.