Minor documentation fixes
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kevin Yap · committed by Kevin Yap · parent 39b8992 · Browse files · 8 files·+62 added−59 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+62 added−59 removed
- other:+62 added−59 removed
Provenance
- Commit
10977b9- Tree
4e52a49- Author
Kevin Yap <me@kevinyap.ca>- Committer
Kevin Yap <me@kevinyap.ca>- Parent
39b8992
8 files changed+62 added−59 removed
modified:docs/arguments.rst+7 added-7 removed
1 unmodified line2 =========3 4 .. currentmodule:: click5 6-Arguments work similarly to options, but are positional. They also only6+Arguments work similarly to options but are positional. They also only7 support a subset of the features of options due to their syntactical nature.8 Click will also not attempt to document arguments for you and wants you to9 document them manually in order to avoid ugly help pages.10 54 unmodified lines65 this, see the next sections.66 67 .. admonition:: Note on Non-Empty Variadic Arguments68 69- If you come from ``argparse`` you might be missing support for setting69+ If you come from ``argparse``, you might be missing support for setting70 ``nargs`` to ``+`` to indicate that at least one argument is required.71 72 This is supported by setting ``required=True``. However, this should73 not be used if you can avoid it as we believe scripts should gracefully41 unmodified lines115 116 File Path Arguments117 -------------------118 119-In the previous example the files were opened immediately. But what if120-we just want the filename? The naive way is to use the default string119+In the previous example, the files were opened immediately. But what if120+we just want the filename? The naïve way is to use the default string121 argument type. However, remember that click is Unicode-based, so the string122 will always be a Unicode value. Unfortunately, filenames can be Unicode or123 bytes depending on which operating system is being used. As such, the type124 is insufficient.125 126-Instead, you should be using the :class:`Path` type, which handles this127-complexity for you. Not only will it return either bytes or Unicode126+Instead, you should be using the :class:`Path` type, which automatically127+handles this ambiguity. Not only will it return either bytes or Unicode128 depending on what makes more sense, but it will also be able to do some129 basic checks for you such as existence checks.130 131 Example:81 unmodified lines213 Generally, this feature is not recommended because it can cause the user214 a lot of confusion.215 216 Argument-Like Options217-------------------------------217+---------------------218 219 Sometimes, you want to process arguments that look like options. For220 instance, imagine you have a file named ``-foo.txt``. If you pass this as221 an argument in this manner, click will treat it as an option.21 unmodified linesmodified:docs/documentation.rst+11 added-10 removed
3 unmodified lines4 .. currentmodule:: click5 6 Click makes it very easy to document your command line tools. First of7 all, it automatically generates help pages for you. While these are8-currently not customizable in layout, all of the text can be changed.8+currently not customizable in terms of their layout, all of the text9+can be changed.10 11 Help Texts12 ----------13 13-Commands and options accept help arguments. In the case of commands, the doc14-string of the function is automatically used if provided.14+Commands and options accept help arguments. In the case of commands, the15+docstring of the function is automatically used if provided.16 17 Simple example:18 19 .. click:example::19 unmodified lines39 40 Preventing Rewrapping41 ---------------------42 42-The default behavior of click is to rewrap text to work correctly for the43-width of the terminal. In some circumstances, this can become a problem.44-The main issue is showing code examples where newlines are significant.43+The default behavior of click is to rewrap text based on the width of the44+terminal. In some circumstances, this can become a problem. The main issue45+is when showing code examples, where newlines are significant.46 47 Rewrapping can be disabled on a per-paragraph basis by adding a line with48 solely the ``\b`` escape marker in it. This line will be removed from the49 help text and rewrapping will be disabled.85 unmodified lines135 ----------------------------136 137 .. versionadded:: 2.0138 138-The help parameter is very special in how it's implemented in click.139+The help parameter is implemented in click in a very special manner.140 Unlike regular parameters it's automatically added by click for any141 command and it performs automatic conflict resolution. By default it's141-called ``--help`` but this can be changed. If a command itself implements142-a parameter with the same name the default help parameter stops accepting142+called ``--help``, but this can be changed. If a command itself implements143+a parameter with the same name, the default help parameter stops accepting144 it. There is a context setting that can be used to override the names of145 the help parameters called :attr:`~Context.help_option_names`.146 147 This example changes the default parameters to ``-h`` and ``--help``147-instad of just ``--help``:148+instead of just ``--help``:149 150 .. click:example::151 152 CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])10 unmodified linesmodified:docs/index.rst+14 added-13 removed
1 Welcome to the Click Documentation2 ==================================3 4 Click is a Python package for creating beautiful command line interfaces5-in a composable way with as little amount of code as necessary. It's the6-"Command Line Interface Creation Kit". It's highly configurable but comes7-with good defaults out of the box.5+in a composable way with as little code as necessary. It's the "Command6+Line Interface Creation Kit". It's highly configurable but comes with7+sensible defaults out of the box.8 9-It aims at making writing command line tools fun and quick without causing10-user frustration at not being able to implement an intended CLI API.9+It aims to make the process of writing command line tools quick and fun10+while also preventing frustration caused by the inability to implement an11+intended CLI API.12 13 Click in three points:14 15 - arbitrary nesting of commands16 - automatic help page generation17 - supports lazy loading of subcommands at runtime18 18-What does it look like? A simple example can be this:19+What does it look like? Here is an example of a simple click program:20 21 .. click:example::22 23 import click9 unmodified lines33 34 if __name__ == '__main__':35 hello()36 36-And what it looks like:37+And what it looks like when run:38 39 .. click:run::40 41 invoke(hello, ['--count=3'], input='John\n')42 42-And it gives you nicely formatted help pages:43+It automatically generates nicely formatted help pages:44 45 .. click:run::46 47 invoke(hello, ['--help'])4 unmodified lines52 53 Documentation Contents54 ----------------------55 55-This part of the documentation guides you through all the usage patterns56-of the library.56+This part of the documentation guides you through all of the library's57+usage patterns.58 59 .. toctree::60 :maxdepth: 261 15 unmodified lines77 78 API Reference79 -------------80 80-If you are looking for information on a specific function, class or81+If you are looking for information on a specific function, class, or82 method, this part of the documentation is for you.83 84 .. toctree::85 :maxdepth: 286 87 api88 88-Other Documents89----------------89+Miscellaneous Pages90+-------------------91 92 .. toctree::93 :maxdepth: 294 3 unmodified linesmodified:docs/prompts.rst+6 added-5 removed
14 unmodified lines15 --------------16 17 Option prompts are integrated into the option interface. See18 :ref:`option-prompting` for more information. Internally, it19-automatically calls into :func:`prompt` or :func:`confirm` as necessary.19+automatically calls either :func:`prompt` or :func:`confirm` as necessary.20 21 Input Prompts22 -------------23 24 To manually ask for user input, you can use the :func:`prompt` function.25 By default, it accepts any Unicode string, but you can ask for any other26-type. For instance you can ask for a valid integer::26+type. For instance, you can ask for a valid integer::27 28 value = click.prompt('Please enter a valid integer', type=int)29 30-The type is also automatically detected if a default is provided. For31-instance, the following will only accept floats::30+Additionally, the type will be determined automatically if a default value is31+provided. For instance, the following will only accept floats::32 33 value = click.prompt('Please enter a number', default=42.0)34 35 Confirmation Prompts5 unmodified lines41 42 if click.confirm('Do you want to continue?'):43 click.echo('Well done!')44 45-There is also the option to make it automatically abort the execution::45+There is also the option to make the function automatically abort the46+execution of the program if it does not return ``True``::47 48 click.confirm('Do you want to continue?', abort=True)modified:docs/python3.rst+8 added-8 removed
1 unmodified line2 ================3 4 .. currentmodule:: click5 6-Click supports Python 3 but like all other command line utility libraries,6+Click supports Python 3, but like all other command line utility libraries,7 it suffers from the Unicode text model in Python 3. All examples in the8-documentation were written so that they run on both Python 2.x and8+documentation were written so that they could run on both Python 2.x and9 Python 3.3 or higher.10 11-At the moment the strong recommendation is to use Python 2 for these11+At the moment, it is strongly recommended is to use Python 2 for click12 utilities unless Python 3 is a hard requirement.13 14 .. _python3-limitations:15 41 unmodified lines57 58 Click attempts to minimize the differences between Python 2 and Python 359 by following the best practices for both languages.60 61-in Python 2, the following is true:61+In Python 2, the following is true:62 63 * ``sys.stdin``, ``sys.stdout``, and ``sys.stderr`` are opened in binary64 mode, but under some circumstances they support Unicode output. Click65 attempts to not subvert this but provides support for forcing streams5 unmodified lines71 * When dealing with files, click will never go through the Unicode APIs72 and will instead use the operating system's byte APIs to open the73 files.74 75-in Python 3, the following is true:75+In Python 3, the following is true:76 77 * ``sys.stdin``, ``sys.stdout`` and ``sys.stderr`` are by default78 text-based. When click needs a binary stream, it attempts to discover79 the underlying binary stream. See :ref:`python3-limitations` for how46 unmodified lines126 You are dealing with an environment where Python 3 thinks you are127 restricted to ASCII data. The solution to these problems is different128 depending on which locale your computer is running in.129 130-For instance if you have a German Linux machine you can fix the problem130+For instance, if you have a German Linux machine, you can fix the problem131 by exporting the locale to ``de_DE.utf-8``::132 133 export LC_ALL=de_DE.utf-8134 export LANG=de_DE.utf-8135 136 If you are on a US machine, ``en_EN.utf-8`` is the encoding of choice. On137-some newer Linux systems you can also try ``C.UTF-8`` as locale::137+some newer Linux systems, you could also try ``C.UTF-8`` as the locale::138 139 export LC_ALL=C.UTF-8140 export LANG=C.UTF-8141 142 You need to do this before you invoke your Python script. If you are143-curious about the reasons for this you can join the discussions in the143+curious about the reasons for this, you can join the discussions in the144 Python 3 bug tracker:145 146 * `ASCII is a bad filesystem default encoding147 <http://bugs.python.org/issue13643#msg149941>`_7 unmodified linesmodified:docs/quickstart.rst+3 added-3 removed
15 unmodified lines16 17 * `Building Command Line Applications with Click18 <https://www.youtube.com/watch?v=kNke39OZ2k0>`_19 20-Examples of Click applications can be found in the documentation as well21-as in the github repository together with readme files:20+Examples of click applications can be found in the documentation as well21+as in the GitHub repository together with readme files:22 23 * ``inout``: `File input and output24 <https://github.com/mitsuhiko/click/tree/master/examples/inout>`_25 * ``naval``: `Port of docopt naval example26 <https://github.com/mitsuhiko/click/tree/master/examples/naval>`_27 * ``aliases``: `Command alias example28 <https://github.com/mitsuhiko/click/tree/master/examples/aliases>`_29-* ``repo``: `Git/hg like command line interface29+* ``repo``: `Git-/Mercurial-like command line interface30 <https://github.com/mitsuhiko/click/tree/master/examples/repo>`_31 * ``complex``: `Complex example with plugin loading32 <https://github.com/mitsuhiko/click/tree/master/examples/complex>`_33 * ``validation``: `Custom parameter validation example130 unmodified linesmodified:docs/setuptools.rst+2 added-2 removed
65 unmodified lines66 67 Testing The Script68 ------------------69 70-To test the script you can make a new virtualenv and then install your70+To test the script, you can make a new virtualenv and then install your71 package::72 73 $ virtualenv venv74 $ . venv/bin/activate75 $ pip install --editable .76 77-Afterwards your command should be available:77+Afterwards, your command should be available:78 79 .. click:run::80 81 invoke(cli, prog_name='yourscript', prog_prefix='')modified:docs/why.rst+11 added-11 removed
27 unmodified lines28 nesting of commands by design and has some deficiencies when it comes to29 POSIX compliant argument handling.30 31 Click is designed to be fun to work with and at the same time not stand in32-your way. It's not overly flexible at the same time either. Currently33-for instance it does not allow you to customize the help pages too much.34-This is intentional because click is designed to allow you to nest command35-line utilities. The idea is that you can have a system that works36-together with another system by tacking two click instances together and37-they will continue working as they should.32+your way. It's not overly flexible either. Currently, for instance, it33+does not allow you to customize the help pages too much. This is intentional34+because click is designed to allow you to nest command line utilities. The35+idea is that you can have a system that works together with another system by36+tacking two click instances together and they will continue working as they37+should.38 39 Too much customizability would break this promise.40 41 Click was written to support the `Flask <http://flask.pocoo.org/>`_42 microframework ecosystem because no tool could provide it with the43 functionality it needed.44 45-To get an understanding of what click is all about I strongly recommend45+To get an understanding of what click is all about, I strongly recommend46 looking at the :ref:`complex-guide` chapter to see what it's useful for.47 48 Why not Argparse?49 -----------------16 unmodified lines66 67 Why not Docopt etc.?68 --------------------69 70-Docopt and many tools like it are cool in how they work but very few of70+Docopt and many tools like it are cool in how they work, but very few of71 these tools deal with nesting of commands and composability in a way like72 click. To the best of the developer's knowledge, click is the first73-Python library that tries to aim for composability of applications that74-goes beyond what the system itself supports.73+Python library that aims to create a level of composability of applications74+that goes beyond what the system itself supports.75 76-Docopt for instance acts by parsing your help pages and then parsing76+Docopt, for instance, acts by parsing your help pages and then parsing77 according to those rules. The side effect of this is that docopt is quite78 rigid in how it handles the command line interface. The upside of docopt79 is that it gives you strong control over your help page; the downside is80 that due to this it cannot rewrap your output for the current terminal72 unmodified lines