aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Touhey <thomas@touhey.fr>2019-05-10 12:49:04 +0200
committerThomas Touhey <thomas@touhey.fr>2019-05-10 12:49:04 +0200
commit14901ebf4da4e8c790d90d971216d867064cb25f (patch)
treee4294d81c867b19bd82820d7a24bdba5815090df
parentaa910dfe205af86c5359002f452dac6d099ad08a (diff)
Added docs
-rw-r--r--.gitignore2
-rw-r--r--MANIFEST.in5
-rw-r--r--docs/Makefile28
-rw-r--r--docs/_static/.gitkeep0
-rw-r--r--docs/_templates/.gitkeep0
-rw-r--r--docs/conf.py55
-rw-r--r--docs/index.rst11
-rw-r--r--docs/make.bat35
-rwxr-xr-xtests/test_text.py1
-rwxr-xr-xthcolor/_color.py2
10 files changed, 138 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 11aeb50..fceabbb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,5 @@ __pycache__
/venv
/README.html
/.pytest_cache
+
+/docs/_build
diff --git a/MANIFEST.in b/MANIFEST.in
index 0a3c3cc..c0eb105 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -3,3 +3,8 @@ include LICENSE.txt
include MANIFEST.in
include setup.py
include setup.cfg
+
+include docs/*.rst
+include docs/conf.py
+include docs/Makefile
+include docs/make.bat
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..1db33f2
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,28 @@
+# Minimal makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+SOURCEDIR = .
+BUILDDIR = _build
+
+WEBROOT := thcolor.touhey.pro:thcolor_doc
+
+# Put it first so that "make" without argument is like "make help".
+help:
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+
+.PHONY: help Makefile
+
+# Catch-all target: route all unknown targets to Sphinx using the new
+# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
+%: Makefile
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+
+# Send the website content (Linux-only).
+show: html
+ find _build/html -type f -exec chmod 644 {} \;
+ rsync -Prlt --delete _build/html/ "$(WEBROOT)"
+
+.PHONY: show
diff --git a/docs/_static/.gitkeep b/docs/_static/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/docs/_static/.gitkeep
diff --git a/docs/_templates/.gitkeep b/docs/_templates/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/docs/_templates/.gitkeep
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..2a38ddf
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,55 @@
+# Configuration file for the Sphinx documentation builder.
+#
+# This file only contains a selection of the most common options. For a full
+# list see the documentation:
+# http://www.sphinx-doc.org/en/master/config
+
+# -- Path setup --------------------------------------------------------------
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#
+# import os
+# import sys
+# sys.path.insert(0, os.path.abspath('.'))
+
+
+# -- Project information -----------------------------------------------------
+
+project = 'thcolor'
+copyright = '2019, Thomas Touhey'
+author = 'Thomas Touhey'
+
+# The full version, including alpha/beta/rc tags
+release = '0.2.2'
+
+
+# -- General configuration ---------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+# This pattern also affects html_static_path and html_extra_path.
+exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
+
+
+# -- Options for HTML output -------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+#
+html_theme = 'sphinx_rtd_theme'
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..d471980
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,11 @@
+Welcome to thcolor's documentation!
+===================================
+
+thcolor is a module for managing color and parsing color textual
+representations.
+
+.. toctree::
+ :maxdepth: 2
+ :caption: Contents:
+
+
diff --git a/docs/make.bat b/docs/make.bat
new file mode 100644
index 0000000..27f573b
--- /dev/null
+++ b/docs/make.bat
@@ -0,0 +1,35 @@
+@ECHO OFF
+
+pushd %~dp0
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+ set SPHINXBUILD=sphinx-build
+)
+set SOURCEDIR=.
+set BUILDDIR=_build
+
+if "%1" == "" goto help
+
+%SPHINXBUILD% >NUL 2>NUL
+if errorlevel 9009 (
+ echo.
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
+ echo.installed, then set the SPHINXBUILD environment variable to point
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
+ echo.may add the Sphinx directory to PATH.
+ echo.
+ echo.If you don't have Sphinx installed, grab it from
+ echo.http://sphinx-doc.org/
+ exit /b 1
+)
+
+%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
+goto end
+
+:help
+%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
+
+:end
+popd
diff --git a/tests/test_text.py b/tests/test_text.py
index c29bb25..22bfb2a 100755
--- a/tests/test_text.py
+++ b/tests/test_text.py
@@ -30,6 +30,7 @@ def _deg(value):
('gray(100 / 55 %)', (100, 100, 100, 0.55)),
('gray(red( #123456 )/0.2/)', ( 18, 18, 18, 0.20)),
('B20 50% 32%', (137, 128, 173, 1.00)),
+ ('ncol(B20 / 50% 32%)', (137, 128, 173, 1.00)),
))
def test_rgba(test_input, expected):
assert Color.from_text(test_input).rgba() == expected
diff --git a/thcolor/_color.py b/thcolor/_color.py
index 44672aa..9e62072 100755
--- a/thcolor/_color.py
+++ b/thcolor/_color.py
@@ -41,7 +41,7 @@ _ColorPattern = _re.compile(r"""
(?P<agl_typ>deg|grad|rad|turn))
| ((?P<per>[0-9]+(\.[0-9]*)? | \.[0-9]+) \s* \%)
| (?P<num>[0-9]+(\.[0-9]*)? | \.[0-9]+)
- | (?P<ncol>[RYGCBM] [0-9]{0,2})
+ | (?P<ncol>[RYGCBM] [0-9]{0,2} (\.[0-9]*)?)
| (\# (?P<hex>[0-9a-f]{3} | [0-9a-f]{4} | [0-9a-f]{6} | [0-9a-f]{8}))
| ((?P<name>[a-z]([a-z0-9\s_-]*[a-z0-9_-])?)
( \s* \( \s* (?P<arg> (?0)? ) \s* \) )?)