Skip to content
Myr

cleandoc for Command help, epilog, and short_help

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent 2c70a0c · Browse files · 3 files+34 added−20 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+34 added−20 removed

  • other:+34 added−20 removed

3 files+34 added−20 removed

modified:src/click/core.py+28 added-11 removed
1131 unmodified lines
1132 """Commands are the basic building block of command line interfaces in1133 Click. A basic command handles command line parsing and might dispatch1134 more parsing to commands nested below it.11351136 .. versionchanged:: 2.01137 Added the `context_settings` parameter.1138 .. versionchanged:: 8.01139 Added repr showing the command name1140 .. versionchanged:: 7.11141 Added the `no_args_is_help` parameter.11421136 :param name: the name of the command to use unless a group overrides it.1137 :param context_settings: an optional dictionary with defaults that are1138 passed to the context object.1139 :param callback: the callback to invoke. This is optional.
13 unmodified lines
1153 :param hidden: hide this command from help outputs.11541155 :param deprecated: issues a message indicating that1156 the command is deprecated.11571158 .. versionchanged:: 8.11159 Indentation in ``help`` is cleaned here instead of only in the1160 ``@command`` decorator. ``epilog`` and ``short_help`` are also1161 cleaned.11621163 .. versionchanged:: 8.01164 Added a ``repr`` showing the command name.11651166 .. versionchanged:: 7.11167 Added the ``no_args_is_help`` parameter.11681169 .. versionchanged:: 2.01170 Added the ``context_settings`` parameter.1171 """11721173 def __init__(1174 self,
18 unmodified lines
1193 #: should show up in the help page and execute. Eager parameters1194 #: will automatically be handled before non eager ones.1195 self.params: t.List["Parameter"] = params or []11961190 # if a form feed (page break) is found in the help text, truncate help1191 # text to the content preceding the first form feed1192 if help and "\f" in help:1193 help = help.split("\f", 1)[0]1197 if help:1198 help = inspect.cleandoc(help)11991200 # Discard help text after a first form feed (page break)1201 # character, to allow writing longer documentation in1202 # docstrings that does not show in help output.1203 if "\f" in help:1204 help = help.partition("\f")[0]12051206 if epilog:1207 epilog = inspect.cleandoc(epilog)12081209 if short_help:1210 short_help = inspect.cleandoc(short_help)12111212 self.help = help1213 self.epilog = epilog1214 self.options_metavar = options_metavar1215 self.short_help = short_help
1759 unmodified lines
modified:src/click/decorators.py+2 added-7 removed
135 unmodified lines
136 del f.__click_params__ # type: ignore137 except AttributeError:138 params = []139140 help = attrs.get("help")140 if attrs.get("help") is None:141 attrs["help"] = inspect.getdoc(f)142142 if help is None:143 help = inspect.getdoc(f)144 else:145 help = inspect.cleandoc(help)146147 attrs["help"] = help143 return cls(144 name=name or f.__name__.lower().replace("_", "-"),145 callback=f,146 params=params,
339 unmodified lines
modified:CHANGES.rst+4 added-2 removed
25 unmodified lines
26 of the other way around. :issue:`1963`27- Parameter decorators and ``@group`` handles ``cls=None`` the same as28 not passing ``cls``. ``@option`` handles ``help=None`` the same as29 not passing ``help``. :issue:`#1959`30- Help text passed to ``Option`` is processed the same way as using31 the ``@option`` decorator. :issue:`1985`30- Indentation in help text passed to ``Option`` and ``Command`` is31 cleaned the same as using the ``@option`` and ``@command``32 decorators does. A command's ``epilog`` and ``short_help`` are also33 processed. :issue:`1985`343536Version 8.0.437-------------
948 unmodified lines