OptionSection#

class lsst.daf.butler.cli.utils.OptionSection(sectionName: str, sectionText: str)#

Bases: MWOption

Implements an Option that prints a section label in the help text and does not pass any value to the command function.

This class does a bit of hackery to add a section label to a click command help output: first, expose_value is set to False so that no value is passed to the command function. Second, this class overrides click.Option.get_help_record to return the section label string without any prefix so that it stands out as a section label.

This class overrides the hidden attribute because our documentation build tool, sphinx-click, implements its own get_help_record function which builds the record from other option values (e.g. name, opts), which breaks the hack we use to make get_help_record only return the sectionText. Fortunately, Click gets the value of hidden inside the Option’s get_help_record, and sphinx-click calls opt.hidden before entering its _get_help_record function. So, making the hidden property return True hides this option from sphinx-click, while allowing the section text to be returned by our get_help_record method when using Click.

The intention for this implementation is to do minimally invasive overrides of the click classes so as to be robust and easy to fix if the click internals change.

Parameters#

sectionNamestr

The parameter declaration for this option. It is not shown to the user, it must be unique within the command. If using the section decorator to add a section to a command’s options, the section name is auto-generated.

sectionTextstr

The text to print in the section identifier.

Attributes Summary

Methods Summary

Attributes Documentation

hidden#

Methods Documentation

get_help_record(ctx: Context | None) tuple[str, str]#