diff options
author | Thomas Touhey <thomas@touhey.fr> | 2022-01-01 22:04:40 +0100 |
---|---|---|
committer | Thomas Touhey <thomas@touhey.fr> | 2022-01-01 22:04:40 +0100 |
commit | 4a947057b709c6536f6a940645254bf0feadcd8c (patch) | |
tree | 334b2a88f44c4470be4b2fc8997725eda09bed63 | |
parent | e12ebaf20f09b4243b3d96cf5cbcbf73dd719a34 (diff) |
Improved the documentation, is ready for 0.4 release0.4
-rw-r--r-- | MANIFEST.in | 4 | ||||
-rw-r--r-- | docs/api/colors.rst | 2 | ||||
-rw-r--r-- | docs/api/decoders.rst | 3 | ||||
-rw-r--r-- | setup.cfg | 2 | ||||
-rwxr-xr-x | tests/test_decoders.py | 4 | ||||
-rw-r--r-- | thcolor/decoders.py | 29 |
6 files changed, 33 insertions, 11 deletions
diff --git a/MANIFEST.in b/MANIFEST.in index c0eb105..cd7c82e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,8 +3,12 @@ include LICENSE.txt include MANIFEST.in include setup.py include setup.cfg +include requirements.txt +include docs/*.txt include docs/*.rst +include docs/**/*.rst +include docs/*.png include docs/conf.py include docs/Makefile include docs/make.bat diff --git a/docs/api/colors.rst b/docs/api/colors.rst index 7db7dd5..ac6e814 100644 --- a/docs/api/colors.rst +++ b/docs/api/colors.rst @@ -32,7 +32,7 @@ Subclasses are the following: .. autoclass:: SRGBColor :members: red, green, blue, alpha, frombytes, - fromnetscapecolorname, tobytes + fromnetscapecolorname, asbytes .. autoclass:: XYZColor :members: x, y, z, alpha diff --git a/docs/api/decoders.rst b/docs/api/decoders.rst index 9825c8c..abab8e7 100644 --- a/docs/api/decoders.rst +++ b/docs/api/decoders.rst @@ -16,3 +16,6 @@ For convenience, the following class is defined to define color decoders: .. autoclass:: alias .. autofunction:: fallback + +See :ref:`defining-decoders` for more information about how to use these +classes. @@ -22,7 +22,7 @@ classifiers = [options] zip_safe = False include_package_data = True -packages = thcolor, thcolor.builtin +packages = thcolor python_requires = >= 3.6 [options.package_data] diff --git a/tests/test_decoders.py b/tests/test_decoders.py index 9a15d46..747beb4 100755 --- a/tests/test_decoders.py +++ b/tests/test_decoders.py @@ -196,6 +196,10 @@ class TestNetscapeDecoder: @pytest.mark.parametrize('test_input,expected', ( ('chucknorris', SRGBColor.frombytes(192, 0, 0, 1.00)), + ( + '6db6ec49efd278cd0bc92d1e5e072d680', + SRGBColor.frombytes(110, 205, 224), + ), )) def test_netscape_colors(self, decoder, test_input, expected): """ Test decoding using Netscape colors. """ diff --git a/thcolor/decoders.py b/thcolor/decoders.py index 0e9d850..cc74101 100644 --- a/thcolor/decoders.py +++ b/thcolor/decoders.py @@ -393,7 +393,7 @@ _colorexpressionpattern = _re.compile( | [0-9a-f]{6} | [0-9a-f]{8} ) ) - | (?P<name> [a-z_-]([a-z0-9_-]*[a-z0-9_-])?) + | (?P<name> [a-z0-9_-]+) | ) \s* (?P<sep>,|/|\s|\(|\)|$) ) @@ -624,14 +624,25 @@ class ColorDecoder(_Mapping): The properties defined at class definition time are the following: - * ``__mapping__``: defines the base mapping that is copied at the - instanciation of each class. - * ``__ncol_support__``: defines whether natural colors (NCol) are - supported while decoding or not. - * ``__extended_hex_support__``: defines whether 4 or 8-digit - hexadecimal colors (starting with a '#') are allowed or not. - * ``__defaults_to_netscape_color``: defines whether color decoding - defaults to Netscape color parsing or not. + ``__mapping__`` + + Defines the base mapping that is copied at the + instanciation of each class. + + ``__ncol_support__`` + + Defines whether natural colors (NCol) are + supported while decoding or not. + + ``__extended_hex_support__`` + + Defines whether 4 or 8-digit + hexadecimal colors (starting with a '#') are allowed or not. + + ``__defaults_to_netscape_color`` + + Defines whether color decoding + defaults to Netscape color parsing or not. These properties cannot be changed at runtime, although they might be in a future version of thcolor. |