Documentation improvements
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 dfb5e97 · Browse files · 1 file·+10 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+10 added−10 removed
- other:+10 added−10 removed
Provenance
- Commit
b67ec8f- Tree
ab208b3- Author
Kevin Yap <me@kevinyap.ca>- Committer
Kevin Yap <me@kevinyap.ca>- Parent
dfb5e97
1 file changed+10 added−10 removed
modified:docs/utils.rst+10 added-10 removed
10 unmodified lines11 Printing to Stdout12 ------------------13 14 The most obvious helper is the :func:`echo` function, which in many ways15-works like the Python print statement or function. The main difference is15+works like the Python ``print`` statement or function. The main difference is16 that it works the same in Python 2 and 3, it intelligently detects17-misconfigured output streams, and will never fail (except in Python 3; for17+misconfigured output streams, and it will never fail (except in Python 3; for18 more information see :ref:`python3-limitations`).19 20 Example::21 1 unmodified line23 24 click.echo('Hello World!')25 26 Most importantly, it can print both Unicode and binary data, unlike the27-builtin ``print`` function in Python 3, which cannot output any bytes. It28-will, however, emit a trailing newline by default which needs to be29-supressed by passing ``nl=False``::27+built-in ``print`` function in Python 3, which cannot output any bytes. It28+will, however, emit a trailing newline by default, which needs to be29+suppressed by passing ``nl=False``::30 31 click.echo(b'\xe2\x98\x83', nl=False)32 33 10 unmodified lines44 is installed, then ANSI codes are intelligently handled.45 46 Primarily this means that:47 48-- click's echo function will automatically strip ANSI color codes if the49- stream is not connected to a terminal.50-- the echo function will transparently connect to the terminal on48+- click's :func:`echo` function will automatically strip ANSI color codes49+ if the stream is not connected to a terminal.50+- the :func:`echo` function will transparently connect to the terminal on51 Windows and translate ANSI codes to terminal API calls. This means52 that colors will work on Windows the same way they do on other53 operating systems.54 166 unmodified lines221 ------------------222 223 Because filenames might not be Unicode, formatting them can be a bit224 tricky. Generally, this is easier in Python 2 than on 3, as you can just225-write the bytes to stdout with the print function, but in Python 3, you will226-always need to operate in Unicode.225+write the bytes to stdout with the ``print`` function, but in Python 3, you226+will always need to operate in Unicode.227 228 The way this works with click is through the :func:`format_filename`229 function. It does a best-effort conversion of the filename to Unicode and230 will never fail. This makes it possible to use these filenames in the106 unmodified lines