diff options
author | Martin Matusiak <numerodix@gmail.com> | 2014-03-09 12:56:29 +0100 |
---|---|---|
committer | Martin Matusiak <numerodix@gmail.com> | 2014-03-09 12:56:29 +0100 |
commit | 8bb3fce3382bfeb0f8befc9b474c4618fb5a6092 (patch) | |
tree | 3399cdb57bde1f4a4306e98f270a4543c00d6d30 | |
parent | 7c3d123b5a0211097268e10f14ea40d6addb2fa8 (diff) | |
download | ansicolor-8bb3fce3382bfeb0f8befc9b474c4618fb5a6092.tar.gz |
simplify readme, move getting started into docs/
-rw-r--r-- | README.rst | 58 | ||||
l--------- | docs/README.rst | 1 | ||||
-rw-r--r-- | docs/index.rst | 2 | ||||
-rw-r--r-- | docs/src/getting_started.rst | 56 |
4 files changed, 59 insertions, 58 deletions
@@ -31,59 +31,7 @@ Installation Getting started --------------- -To highlight using colors: - -.. literalinclude:: snippets/getting_started_1.py - -.. figure:: snippets/getting_started_1.png - - -This will emit ansi escapes into the string: one when starting a color, another -to reset the color back to the default: - -.. code:: python - - >>> from ansicolor import green - - >>> green("green") - '\x1b[0;0;32mgreen\x1b[0;0m' - - -If I want to be able to pass a color as an argument I can also use the -``colorize`` function: - -.. code:: python - - from ansicolor import Colors - from ansicolor import colorize - - print(colorize("I'm blue", Colors.Blue)) - - -I can also apply color on a portion of a string: - -.. code:: python - - from ansicolor import Colors - from ansicolor import wrap_string - - print(wrap_string("I'm blue, said the policeman.", 8, Colors.Blue)) - - -Sometimes I may have a string that contains markup and I'll want to do something -with it that concerns only the text, so I can strip the markup: - -.. code:: python - - >>> from ansicolor import red - >>> from ansicolor import strip_escapes - >>> from ansicolor import yellow - - >>> message = "My favorite colors are %s and %s" % (yellow("yellow"), red("red")) - >>> print("The length of this string is not: %d" % len(message)) - The length of this string is not: 67 - >>> print("The length of this string is: %d" % len(strip_escapes(message))) - The length of this string is: 37 +Read the `documentation` on Read the Docs! Going further @@ -97,7 +45,5 @@ Take a look at the ``demos`` to see what's possible. $ python -m ansicolor.demos --highlight $ python -m ansicolor.demos --diff -Also see the `API documentation`_. - -.. _`API documentation`: https://ansicolor.readthedocs.org/ +.. _`documentation`: https://ansicolor.readthedocs.org/ diff --git a/docs/README.rst b/docs/README.rst deleted file mode 120000 index 89a0106..0000000 --- a/docs/README.rst +++ /dev/null @@ -1 +0,0 @@ -../README.rst
\ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index e0e71d1..1955f4d 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,7 +9,7 @@ Welcome to ansicolor's documentation! .. toctree:: :maxdepth: 4 - README.rst + src/getting_started.rst ansicolor diff --git a/docs/src/getting_started.rst b/docs/src/getting_started.rst new file mode 100644 index 0000000..28ad000 --- /dev/null +++ b/docs/src/getting_started.rst @@ -0,0 +1,56 @@ +Getting started +=============== + +To highlight using colors: + +.. literalinclude:: ../snippets/getting_started_1.py + +.. figure:: ../snippets/getting_started_1.png + + +This will emit ansi escapes into the string: one when starting a color, another +to reset the color back to the default: + +.. code:: python + + >>> from ansicolor import green + + >>> green("green") + '\x1b[0;0;32mgreen\x1b[0;0m' + + +If I want to be able to pass a color as an argument I can also use the +``colorize`` function: + +.. code:: python + + from ansicolor import Colors + from ansicolor import colorize + + print(colorize("I'm blue", Colors.Blue)) + + +I can also apply color on a portion of a string: + +.. code:: python + + from ansicolor import Colors + from ansicolor import wrap_string + + print(wrap_string("I'm blue, said the policeman.", 8, Colors.Blue)) + + +Sometimes I may have a string that contains markup and I'll want to do something +with it that concerns only the text, so I can strip the markup: + +.. code:: python + + >>> from ansicolor import red + >>> from ansicolor import strip_escapes + >>> from ansicolor import yellow + + >>> message = "My favorite colors are %s and %s" % (yellow("yellow"), red("red")) + >>> print("The length of this string is not: %d" % len(message)) + The length of this string is not: 67 + >>> print("The length of this string is: %d" % len(strip_escapes(message))) + The length of this string is: 37 |