summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMartin Matusiak <numerodix@gmail.com>2014-03-09 12:56:29 +0100
committerMartin Matusiak <numerodix@gmail.com>2014-03-09 12:56:29 +0100
commit8bb3fce3382bfeb0f8befc9b474c4618fb5a6092 (patch)
tree3399cdb57bde1f4a4306e98f270a4543c00d6d30 /docs
parent7c3d123b5a0211097268e10f14ea40d6addb2fa8 (diff)
downloadansicolor-8bb3fce3382bfeb0f8befc9b474c4618fb5a6092.tar.gz
simplify readme, move getting started into docs/
Diffstat (limited to 'docs')
l---------docs/README.rst1
-rw-r--r--docs/index.rst2
-rw-r--r--docs/src/getting_started.rst56
3 files changed, 57 insertions, 2 deletions
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