Doc Update Resolving Issue #2206 (#2726)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Adam Englander · committed by GitHub · parents 74ab60a, 920d0d7 · Browse files · 3 files·+21 added−15 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+21 added−15 removed
- other:+21 added−15 removed
Provenance
- Commit
e88c112- Tree
00a0c67- Author
Adam Englander <adamenglander@yahoo.com>- Committer
GitHub <noreply@github.com>- Parent 1
74ab60a- Parent 2
920d0d7
3 files changed+21 added−15 removed
modified:docs/setuptools.rst+6 added-4 removed
79 unmodified lines80 ],81 },82 )83 84-The magic is in the ``entry_points`` parameter. Below85-``console_scripts``, each line identifies one console script. The first86-part before the equals sign (``=``) is the name of the script that should87-be generated, the second part is the import path followed by a colon84+The magic is in the ``entry_points`` parameter. Read the full85+`entry_points <https://packaging.python.org/en/latest/specifications/entry-points/>`_86+specification for more details. Below ``console_scripts``, each87+line identifies one console script. The first part before the88+equals sign (``=``) is the name of the script that should be89+generated, the second part is the import path followed by a colon90 (``:``) with the Click command.91 92 That's it.93 62 unmodified linesmodified:docs/shell-completion.rst+14 added-10 removed
26 unmodified lines27 through an entry point, not through the ``python`` command. See28 :doc:`/setuptools`. Once the executable is installed, calling it with29 a special environment variable will put Click in completion mode.30 31-In order for completion to be used, the user needs to register a special32-function with their shell. The script is different for every shell, and33-Click will output it when called with ``_{PROG_NAME}_COMPLETE`` set to34-``{shell}_source``. ``{PROG_NAME}`` is the executable name in uppercase35-with dashes replaced by underscores. The built-in shells are ``bash``,36-``zsh``, and ``fish``.31+To enable shell completion, the user needs to register a special32+function with their shell. The exact script varies depending on the33+shell you are using. Click will output it when called with34+``_{FOO_BAR}_COMPLETE`` set to ``{shell}_source``. ``{FOO_BAR}`` is35+the executable name in uppercase with dashes replaced by underscores.36+It is conventional but not strictly required for environment variable37+names to be in upper case. This convention helps distinguish environment38+variables from regular shell variables and commands, making scripts39+and configuration files more readable and easier to maintain. The40+built-in shells are ``bash``, ``zsh``, and ``fish``.41 42 Provide your users with the following instructions customized to your43 program name. This uses ``foo-bar`` as an example.44 152 unmodified lines197 require implementing some smaller parts.198 199 First, you'll need to figure out how your shell's completion system200 works and write a script to integrate it with Click. It must invoke your197-program with the environment variable ``_{PROG_NAME}_COMPLETE`` set to201+program with the environment variable ``_{FOO_BAR}_COMPLETE`` set to202 ``{shell}_complete`` and pass the complete args and incomplete value.203 How it passes those values, and the format of the completion response204 from Click is up to you.205 4 unmodified lines210 - ``complete_func`` - A safe name for the completion function defined211 in the script.212 - ``complete_var`` - The environment variable name for passing the213 ``{shell}_complete`` instruction.210-- ``prog_name`` - The name of the executable being completed.214+- ``foo_bar`` - The name of the executable being completed.215 216 The example code is for a made up shell "My Shell" or "mysh" for short.217 218 .. code-block:: python2 unmodified lines221 from click.shell_completion import ShellComplete222 223 _mysh_source = """\224 %(complete_func)s {221- response=$(%(complete_var)s=mysh_complete %(prog_name)s)225+ response=$(%(complete_var)s=mysh_complete %(foo_bar)s)226 # parse response and set completions somehow227 }224- call-on-complete %(prog_name)s %(complete_func)s228+ call-on-complete %(foo_bar)s %(complete_func)s229 """230 231 @add_completion_class232 class MyshComplete(ShellComplete):59 unmodified linesmodified:CONTRIBUTING.rst+1 added-1 removed
142 unmodified lines143 144 .. code-block:: text145 146 $ git fetch origin147- $ git checkout -b your-branch-name origin/8.0.x147+ $ git checkout -b your-branch-name origin/8.1.x148 149 If you're submitting a feature addition or change, branch off of the150 "main" branch.151 71 unmodified lines