Fix docs and changelog
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kevin Deldycke · committed by Kevin Deldycke · parent 5aa8ac4 · Browse files · 11 files·+33 added−21 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
11 files+33 added−21 removed
- other:+33 added−21 removed
Provenance
- Commit
0f4738d- Tree
c6aa87f- Author
Kevin Deldycke <kevin@deldycke.com>- Committer
Kevin Deldycke <kevin@deldycke.com>- Parent
5aa8ac4
11 files changed+33 added−21 removed
modified:docs/arguments.md+1 added-1 removed
8 unmodified lines9101112131314151617172 unmodified linesExpand all8 unmodified lines
* Are positional in nature.* Similar to a limited version of {ref}`options <options>` that can take an arbitrary number of inputs* Can take an optional `help` string shown in the ``Positional arguments``* Can take an optional `help` string shown in the `Positional arguments` section of the help page, or be {ref}`documented in the command docstring <documenting-arguments>`.
Useful and often used kwargs are:172 unmodified linesExpand allmodified:docs/documentation.md+2 added-2 removed
13 unmodified lines14 ```{eval-rst}15 .. click:example::16 17 @click.command()18- @click.argument('name', help='The name to print')18+ @click.argument('name', help='The name to print.')19 @click.option('--count', default=1, help='number of greetings')20 def hello(name: str, count: int):21 """This script prints hello and a name one or more times."""22 for x in range(count):90 unmodified lines113 114 ## Documenting Arguments115 116 {class}`click.argument` accepts an optional `help` parameter that is shown in117-the ``Positional arguments`` section of the help page. You can still document117+the `Positional arguments` section of the help page. You can still document118 arguments in the command docstring, especially when you want to describe them119 in the main help text by name.120 121 A brief example:222 unmodified linesmodified:docs/option-decorators.md+2 added
82 unmodified lines83 84 ## Version Option85 86 {func}`version_option` adds a `--version` option which immediately prints the version number and exits the program.87+88+The message and values it can show are intentionally limited, and its feature set is frozen. If you need values it does not expose, such as the Python version or git metadata, use {func}`custom_version_option` and produce the output yourself in a callback.modified:docs/shell-completion.md+2 added-2 removed
3 unmodified lines4 5 ```{currentmodule} click.shell_completion6 ```7 8-Click provides tab completion support for Bash (version 4.4 and up), Zsh, and Fish. It is possible to add support for9-other shells too, and suggestions can be customized at multiple levels.8+Click provides tab completion support for Bash (version 4.4 and up), Zsh, Fish, and PowerShell. It is possible to add9+support for other shells too, and suggestions can be customized at multiple levels.10 11 Shell completion suggests command names, option names, and values for choice, file, and path parameter types. Options12 are only listed if at least a dash has been entered. Hidden commands and options are not shown.13 262 unmodified linesmodified:docs/utils.md+8 added-5 removed
54 unmodified lines55 The {func}`echo` function supports ANSI colors and styles. It will56 automatically strip ANSI color codes if the stream is not connected to a57 terminal.58 59-:::{admonition} Older Windows Support59+```{admonition} Older Windows Support60 :class: note61 62-Recent Windows 11 supports ANSI styling by default, in both Terminal and cmd.exe.63-If you need to support color output on older versions of Windows, install62+Recent versions of Windows 11 support ANSI styling by default, in both63+Windows Terminal and cmd.exe. If you need to support color output on older64+versions of Windows, install65 [colorama](https://pypi.org/project/colorama/) and call `colorama.init()`.65-:::66+```67 68 For styling a string, the {func}`style` function can be used:69 70 ```python53 unmodified lines124 for idx in range(50000):125 print(idx, file=pager)126 ```127 127-```{hint} Why print instead of echo?128+```{admonition} Why print() instead of echo()?129+:class: hint130+131 The pager object deals with ANSI color and style codes itself: they are kept or132 stripped depending on what the pager supports, exactly as {func}`echo` would do.133 Any code that writes to a file, including plain {func}`print`, can therefore be134 used with it.255 unmodified linesmodified:src/click/_compat.py+1 added-1 removed
511 unmodified lines512 return not isatty(stream) and not _is_jupyter_kernel_output(stream)513 return not color514 515 516-# double check is needed so mypy does not analyze this on Linux516+# Double check is needed so mypy does not analyze this on Linux.517 if sys.platform.startswith("win") and WIN:518 from ._winconsole import _get_windows_console_stream519 520 def _get_argv_encoding() -> str:70 unmodified linesmodified:src/click/core.py+1 added-1 removed
3660 unmodified lines3661 All parameters are passed onwards to the constructor of :class:`Parameter`.3662 3663 :param help: the help string.3664 3665- .. versionchanged:: 8.53665+ .. versionchanged:: 8.5.03666 Added the ``help`` parameter.3667 """3668 3669 param_type_name = "argument"123 unmodified linesmodified:src/click/shell_completion.py+2 added-2 removed
519 unmodified lines520 521 class PowerShellComplete(ShellComplete):522 """Shell completion for PowerShell (Windows PowerShell 5.1+ and pwsh 7+).523 524- .. versionadded:: 8.5524+ .. versionadded:: 8.5.0525 """526 527 name: t.ClassVar[str] = "powershell"528 source_template: t.ClassVar[str] = _SOURCE_POWERSHELL93 unmodified lines622 623 lex = shlex.shlex(string, posix=True)624 lex.whitespace_split = True625 lex.commenters = ""626- out = [] # type: list[str]626+ out: list[str] = []627 628 try:629 out.extend(lex)630 except ValueError:171 unmodified linesmodified:src/click/termui.py+2 added-2 removed
710 unmodified lines711 :param reset: by default a reset-all code is added at the end of the712 string which means that styles do not carry over. This713 can be disabled to compose styles.714 715- .. versionchanged:: 8.5715+ .. versionchanged:: 8.5.0716 All invalid color values raise :exc:`ValueError`. 256-color index717- ``0`` is not ignored717+ ``0`` is no longer ignored.718 719 .. versionchanged:: 8.0720 A non-string ``message`` is converted to a string.721 282 unmodified linesmodified:src/click/utils.py+1 added-1 removed
277 unmodified lines278 :param color: Force showing or hiding colors and other styles. By279 default Click will remove color if the output does not look like280 an interactive terminal.281 282- .. versionchanged:: 8.5282+ .. versionchanged:: 8.5.0283 Colorama is no longer used for color on Windows.284 285 .. versionchanged:: 6.0286 Support Unicode output on the Windows console. Click does not402 unmodified linesmodified:CHANGES.md+11 added-4 removed
3 unmodified lines4 5 - Add built-in shell completion support for PowerShell (Windows PowerShell6 5.1+ and pwsh 7+) alongside the existing `bash`, `zsh`, and `fish`7 completers. Use `_FOO_BAR_COMPLETE=powershell_source foo-bar` to generate8- the completion script.8+ the completion script. {issue}`2672` {pr}`3637`9 - Supported versions of Windows enable ANSI terminal styles by default.10 Colorama is no longer a dependency and is not used. {issue}`2986` {pr}`3505`11 - {class}`Argument` accepts a `help` parameter, and help output includes12 a `Positional arguments` section when argument help is available. {issue}`2983` {pr}`3473`1 unmodified line14 prompt when the output stream does not support them, matching `echo()`.15 This stripping was lost in `8.4.0` when {pr}`2969` began writing the16 prompt with `input()` directly. {issue}`3572` {pr}`3653`17 - Fix test failures when using pytest >= 9.1. {pr}`3656`18+- {class}`Path` with `allow_dash=True` no longer triggers a `BytesWarning`,19+ an error under `python -bb`, when checking a value against the `-`20+ convention. {issue}`2877` {pr}`3642`21 - Add {func}`custom_version_option`, a `--version` option whose output is22 produced by a callback, covering cases {func}`version_option` intentionally23 does not. The feature set of {func}`version_option` is now frozen; see24 [discussion #3527](https://github.com/pallets/click/discussions/3527). {pr}`3581`25 - `style()` and `secho()` no longer silently drop the 256-color index `0`23- (black) passed as `fg` or `bg`, and now validate color arguments. {pr}`3677`26+ (black) passed as `fg` or `bg`, and now validate color arguments. Invalid27+ colors raise a `ValueError` instead of a `TypeError`. {pr}`3677`28 - The automatic help option stores its value under the reserved name29 `_click_default_help` instead of `help`, so a parameter named `help` no30 longer breaks parsing. The new name is visible in31 {meth}`Command.to_info_dict` output. Parameters that overwrite each other's1 unmodified line33 parameter, or any parameter claiming the reserved name. Options may still34 share a name to compete for the same value (feature switches).35 {issue}`2819` {pr}`3678`36 - `unstyle` and the ANSI handling behind help-text wrapping now strip the full33- CSI escape-sequence grammar.37+ CSI escape-sequence grammar. {pr}`3681`38 - Streamline `Option` flag handling: the flag-kind, type, lazy-default and39 validation steps in `Option.__init__` move into focused helpers, and40 `flag_value` and `default` keep their unset sentinel at construction41 (resolved lazily on read) so `is UNSET` reliably tells a user-supplied value38- from an auto-derived one. Behavior is unchanged. {pr}`3641`42+ from an auto-derived one. Runtime behavior is unchanged, but43+ {meth}`Parameter.to_info_dict` now resolves `default=True` on a feature44+ switch to its `flag_value`, matching what the function receives at call45+ time. {pr}`3641`46 - {func}`get_binary_stream` and {func}`get_text_stream` are deprecated and47 will be removed in Click 9.0. {issue}`3481` {pr}`3695`48 - The following `click.utils` names were never intentionally public and are49 now private (`_`-prefixed). The old names remain available with a1581 unmodified lines