summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2020-01-09 22:45:53 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2020-01-09 22:45:53 -0500
commit591bd29cb4a3bcb9b1f40ffc1f30429c6501ebdb (patch)
tree46c1e3af762c9cb222c6ae90bf0446d6eca4b388 /docs
parent10b844809e3a9500274dc4af4e780708975ba905 (diff)
parentd4556962799e68ea4d54ff86186428d17edcaef9 (diff)
downloadcmd2-git-591bd29cb4a3bcb9b1f40ffc1f30429c6501ebdb.tar.gz
Merge branch 'master' into generating_output_docs
# Conflicts: # docs/features/generating_output.rst # docs/features/settings.rst
Diffstat (limited to 'docs')
-rw-r--r--docs/api/utility_functions.rst8
-rw-r--r--docs/conf.py2
-rw-r--r--docs/copyright.rst5
-rw-r--r--docs/features/generating_output.rst34
-rw-r--r--docs/features/settings.rst6
5 files changed, 42 insertions, 13 deletions
diff --git a/docs/api/utility_functions.rst b/docs/api/utility_functions.rst
index 86fb656c..e083cafe 100644
--- a/docs/api/utility_functions.rst
+++ b/docs/api/utility_functions.rst
@@ -9,7 +9,13 @@ Utility Functions
.. autofunction:: cmd2.decorators.categorize
-.. autofunction:: cmd2.utils.center_text
+.. autofunction:: cmd2.utils.align_text
+
+.. autofunction:: cmd2.utils.align_left
+
+.. autofunction:: cmd2.utils.align_center
+
+.. autofunction:: cmd2.utils.align_right
.. autofunction:: cmd2.utils.strip_quotes
diff --git a/docs/conf.py b/docs/conf.py
index 5463d0bb..7a8da9d1 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -56,7 +56,7 @@ master_doc = 'index'
# General information about the project.
project = 'cmd2'
-copyright = '2010-2019, cmd2 contributors'
+copyright = '2010-2020, cmd2 contributors'
author = 'cmd2 contributors'
# The version info for the project you're documenting, acts as replacement for
diff --git a/docs/copyright.rst b/docs/copyright.rst
index b7183e62..30cf255c 100644
--- a/docs/copyright.rst
+++ b/docs/copyright.rst
@@ -1,7 +1,6 @@
Copyright
=========
-The ``cmd2`` documentation is Copyright 2010-2019 by the `cmd2 contributors
+The ``cmd2`` documentation is Copyright 2010-2020 by the `cmd2 contributors
<https://github.com/python-cmd2/cmd2/graphs/contributors>`_ and is licensed
-under a `Creative Commons Attribution 4.0 International License
-<http://creativecommons.org/licenses/by/4.0/>`_.
+under an `MIT License <https://github.com/python-cmd2/cmd2/blob/master/LICENSE>`_.
diff --git a/docs/features/generating_output.rst b/docs/features/generating_output.rst
index 34416092..78ff7657 100644
--- a/docs/features/generating_output.rst
+++ b/docs/features/generating_output.rst
@@ -36,7 +36,7 @@ conveniences.
If you want to show an error message, put it in
``self.broken_pipe_warning`` when you initialize ``Cmd2.cmd``.
- 2. It examines and honors the :ref:`features/settings:allow_ansi` setting.
+ 2. It examines and honors the :ref:`features/settings:allow_style` setting.
See :ref:`features/generating_output:Colored Output` below for more details.
Here's a simple command that shows this method in action::
@@ -48,6 +48,30 @@ Here's a simple command that shows this method in action::
Colored Output
--------------
+The output methods in the previous section all honor the ``allow_style``
+setting, which has three possible values:
+
+Never
+ poutput(), pfeedback(), and ppaged() strip all ANSI style sequences
+ which instruct the terminal to colorize output
+
+Terminal
+ (the default value) poutput(), pfeedback(), and ppaged() do not strip any
+ ANSI style sequences when the output is a terminal, but if the output is a
+ pipe or a file the style sequences are stripped. If you want colorized
+ output you must add ANSI style sequences using either cmd2's internal ansi
+ module or another color library such as `plumbum.colors`, `colorama`, or
+ `colored`.
+
+Always
+ poutput(), pfeedback(), and ppaged() never strip ANSI style sequences,
+ regardless of the output destination
+
+Colored and otherwise styled output can be generated using the `ansi.style()`
+function:
+
+.. automethod:: cmd2.ansi.style
+ :noindex:
You may want to generate output in different colors, which is typically done by
adding `ANSI escape sequences
@@ -68,7 +92,7 @@ output, setting the window title in the terminal, and removing ANSI escape
codes from a string. These functions are all documentated in
:mod:`cmd2.ansi`.
-:mod:`cmd2.cmd2.Cmd` includes an :ref:`features/settings:allow_ansi` setting,
+:mod:`cmd2.cmd2.Cmd` includes an :ref:`features/settings:allow_style` setting,
which controls whether ANSI escape sequences that instruct the terminal to
colorize output are stripped from the output. The recommended approach is to
construct your application so that it generates colorized output, and then
@@ -76,7 +100,7 @@ allow your users to use this setting to remove the colorization if they do not
want it.
Output generated by any of these
-methods will honor the :ref:`features/settings:allow_ansi` setting:
+methods will honor the :ref:`features/settings:allow_style` setting:
- :meth:`~.cmd2.Cmd.poutput`
- :meth:`~.cmd2.Cmd.perror`
@@ -144,7 +168,7 @@ Centering Text
--------------
If you would like to generate output which is centered in the user's terminal,
-the :meth:`cmd2.utils.center_text` method can help. Pass it a string and it
+the :meth:`cmd2.utils.align_center` method can help. Pass it a string and it
will figure out the width of the terminal and return you a new string,
appropriately padded so it will be centered.
@@ -158,7 +182,7 @@ are categories of Unicode characters that occupy 2 cells, and other that occupy
0. To further complicate matters, you might have included ANSI escape sequences
in the output to generate colors on the terminal.
-The :meth:`cmd2.ansi.ansi_safe_wcswidth` function solves both of these
+The :meth:`cmd2.ansi.style_aware_wcswidth` function solves both of these
problems. Pass it a string, and regardless of which Unicode characters and ANSI
escape sequences it contains, it will tell you how many characters on the
screen that string will consume when printed.
diff --git a/docs/features/settings.rst b/docs/features/settings.rst
index 88d76dc8..5e2280cd 100644
--- a/docs/features/settings.rst
+++ b/docs/features/settings.rst
@@ -20,10 +20,10 @@ Commands`. Users can use the :ref:`features/builtin_commands:set` command to
show all settings and to modify the value of any setting.
-allow_ansi
-~~~~~~~~~~
+allow_style
+~~~~~~~~~~~
-The ``allow_ansi`` setting controls the behavior of ANSI escape sequences
+The ``allow_style`` setting controls the behavior of ANSI escape sequences
in output generated with any of the following methods:
- ``poutput()``