OptionSection#
- class lsst.daf.butler.cli.utils.OptionSection(sectionName: str, sectionText: str)#
Bases:
MWOptionImplements 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_valueis set toFalseso that no value is passed to the command function. Second, this class overridesclick.Option.get_help_recordto 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_recordfunction which builds the record from other option values (e.g.name,opts), which breaks the hack we use to makeget_help_recordonly return thesectionText. Fortunately, Click gets the value ofhiddeninside theOption’sget_help_record, andsphinx-clickcallsopt.hiddenbefore entering its_get_help_recordfunction. So, making the hidden property return True hides this option from sphinx-click, while allowing the section text to be returned by ourget_help_recordmethod 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#
- sectionName
str The parameter declaration for this option. It is not shown to the user, it must be unique within the command. If using the
sectiondecorator to add a section to a command’s options, the section name is auto-generated.- sectionText
str The text to print in the section identifier.
Attributes Summary
Methods Summary
get_help_record(ctx)Attributes Documentation
Methods Documentation
- get_help_record(ctx: Context | None) tuple[str, str]#
- sectionName