Skip to content

Commit 66144db

Browse files
committed
Additional documentation cleanup.
1 parent 2741d6e commit 66144db

6 files changed

+88
-87
lines changed

docs/changelog.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ Version 1.9.1
139139

140140
Released June 2019
141141

142-
* The ``__version__`` attribute of the installed webcolors module, although not
143-
documented or referenced anywhere, was accidentally not updated in the 1.9
144-
release. It has now been updated (and now indicates 1.9.1).
142+
* The ``__version__`` attribute of the installed ``webcolors`` module, although
143+
not documented or referenced anywhere, was accidentally not updated in the
144+
1.9 release. It has now been updated (and now indicates 1.9.1).
145145

146146

147147
Version 1.9
@@ -154,7 +154,7 @@ Released June 2019
154154

155155
* When asked to provide a color name, using the CSS3/SVG set of names, for the
156156
hexadecimal value ``#808080``, the integer triplet ``rgb(128, 128, 128)``, or
157-
the percentage triplet ``rgb(50%, 50%, 50%)``, webcolors now always returns
157+
the percentage triplet ``rgb(50%, 50%, 50%)``, ``webcolors`` now always returns
158158
``u'gray'``, never ``u'grey'``. Previously, the behavior could be
159159
inconsistent as it depended on the Python version in use; ``u'gray'`` was
160160
picked because it was the spelling variant used in HTML 4, CSS1, and CSS2.
@@ -215,7 +215,7 @@ Version 1.5
215215

216216
Released March 2015
217217

218-
* Python 3 support: webcolors now supports Python 3.3.
218+
* Python 3 support: ``webcolors`` now supports Python 3.3.
219219

220220
* Added :ref:`HTML5 color algorithms <html5-algorithms>`.
221221

docs/colors.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ of `the HTML5 specification's section on colors`_.
149149
What this module supports
150150
-------------------------
151151

152-
The webcolors module supports the following methods of specifying sRGB colors,
153-
and conversions between them:
152+
The ``webcolors`` module supports the following methods of specifying sRGB
153+
colors, and conversions between them:
154154

155155
* Six-digit hexadecimal
156156

@@ -162,7 +162,7 @@ and conversions between them:
162162

163163
* The defined named colors of HTML 4, CSS2, CSS2.1, and CSS3
164164

165-
The webcolors module **does not support**:
165+
The ``webcolors`` module **does not support**:
166166

167167
* The CSS1 named colors, which did not have defined values
168168

docs/conformance.rst

+23-22
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
Conformance and testing
55
=======================
66

7-
Much of the behavior of webcolors is dictated by the relevant web standards,
8-
which define the acceptable color formats, how to determine valid values for
9-
each format and the values corresponding to defined color names. Maintaining
10-
correct conversions and conformance to those standards is crucial.
7+
Much of the behavior of ``webcolors`` is dictated by the relevant web
8+
standards, which define the acceptable color formats, how to determine valid
9+
values for each format and the values corresponding to defined color
10+
names. Maintaining correct conversions and conformance to those standards is
11+
crucial.
1112

12-
The source distribution of webcolors (the ``.tar.gz`` file you can download
13+
The source distribution of ``webcolors`` (the ``.tar.gz`` file you can download
1314
from the Python Package Index) includes a ``tests/`` directory containing a
1415
normal test suite as well as supplemental test files which perform more
1516
comprehensive verification.
@@ -18,8 +19,8 @@ comprehensive verification.
1819
The normal test suite
1920
---------------------
2021

21-
The normal test suite for webcolors aims for 100% coverage of code paths, but
22-
does *not* aim for 100% coverage of possible color value inputs and
22+
The normal test suite for ``webcolors`` aims for 100% coverage of code paths,
23+
but does *not* aim for 100% coverage of possible color value inputs and
2324
outputs. Instead, it uses a small number of test values to routinely exercise
2425
various functions.
2526

@@ -51,9 +52,9 @@ the results of test runs online `at GitHub
5152
<https://github.com/ubernostrum/webcolors/actions/workflows/ci.yml/>`_.
5253

5354
However, the normal test suite cannot guarantee that the color definitions
54-
included in webcolors correspond to those in the relevant standards, and cannot
55-
provide guarantees of correct conversions for all possible values. For that,
56-
additional tests are required.
55+
included in ``webcolors`` correspond to those in the relevant standards, and
56+
cannot provide guarantees of correct conversions for all possible values. For
57+
that, additional tests are required.
5758

5859

5960
.. _full-verification:
@@ -64,16 +65,16 @@ Full verification tests
6465
These tests are contained in two files which are not executed during normal
6566
test runs: ``tests/definitions.py`` and ``tests/full_colors.py``. They are not
6667
run as part of the normal test suite, but are run prior to each release of
67-
webcolors.
68+
``webcolors``.
6869

6970

7071
Verifying color definitions
7172
~~~~~~~~~~~~~~~~~~~~~~~~~~~
7273

7374
The ``definitions.py`` test file verifies that the color definitions in
74-
webcolors are correct. It does this by downloading the relevant standards
75+
``webcolors`` are correct. It does this by downloading the relevant standards
7576
documents as HTML, parsing out the color definitions in them, and comparing
76-
them to the definitions in webcolors. That consists of:
77+
them to the definitions in ``webcolors``. That consists of:
7778

7879
* Parsing out the names and hexadecimal values of the 16 named colors in the
7980
HTML 4 standard, and checking that the names and values in
@@ -102,7 +103,7 @@ For conversions between hexadecimal and integer ``rgb()``, it generates all
102103
16,777,216 possible color values for each format in order (starting at
103104
``#000000`` and ``(0,0,0)`` and incrementing), and verifies that each one
104105
converts to the corresponding value in the other format. Thus, it is possible
105-
to be confident that webcolors provides correct conversions between all
106+
to be confident that ``webcolors`` provides correct conversions between all
106107
possible color values in those formats.
107108

108109
Testing the correctness of conversion to and from percentage ``rgb()``,
@@ -124,7 +125,7 @@ however, is more difficult, and a full test is not provided, for two reasons:
124125
uncountably infinite, testing all legal values is not possible on current
125126
hardware in any reasonable amount of time.
126127

127-
Since precise correctness and completeness are not achievable, webcolors
128+
Since precise correctness and completeness are not achievable, ``webcolors``
128129
instead aims to achieve *consistency* in conversions. Specifically, the
129130
``full_colors.py`` test generates all 16,777,216 integer ``rgb()`` triplets,
130131
and for each such triplet `t` verifies that the following assertion holds:
@@ -137,11 +138,11 @@ and for each such triplet `t` verifies that the following assertion holds:
137138
Running the tests
138139
-----------------
139140

140-
The standard test runner for webcolors is `nox <https://nox.thea.codes/>`_,
141+
The standard test runner for ``webcolors`` is `nox <https://nox.thea.codes/>`_,
141142
which supports testing against multiple Python versions and executing a variety
142-
of different test tasks. The source distribution of webcolors includes its
143+
of different test tasks. The source distribution of ``webcolors`` includes its
143144
``noxfile.py`` file. To run the tests, install nox (``pip install nox``), then
144-
download and unpack a git checkout or source package of webcolors.
145+
download and unpack a git checkout or source package of ``webcolors``.
145146

146147
To run the normal test suite against the complete set of supported Python
147148
versions:
@@ -160,8 +161,8 @@ versions:
160161
py -m pip install nox
161162
py -m nox
162163
163-
This requires that you have each supported version of Python (for webcolors
164-
|release|, this is 3.7, 3.8, 3.9, 3.10, and 3.11) available. To test only
164+
This requires that you have each supported version of Python (for ``webcolors``
165+
|release|, this is 3.8, 3.9, 3.10, 3.11, and 3.12) available. To test only
165166
against a specific version of Python, use the ``--python`` flag and pass the
166167
version to test. For example, to test on Python 3.10:
167168

@@ -178,8 +179,8 @@ version to test. For example, to test on Python 3.10:
178179
py -m nox --python "3.10"
179180
180181
To run the full verification tests for definition correctness and conversions,
181-
specify the "release" test keyword instead (so named because these tests
182-
are usually run only prior to a new release of webcolors):
182+
specify the "release" test keyword instead (so named because these tests are
183+
usually run only prior to a new release of ``webcolors``):
183184

184185
.. tab:: macOS/Linux/other Unix
185186

docs/contents.rst

+17-16
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Module contents
77
===============
88

9-
The contents of the webcolors module fall into five categories:
9+
The contents of the ``webcolors`` module fall into five categories:
1010

1111
1. A set of (optional) data types for representing color values.
1212

@@ -21,7 +21,7 @@ The contents of the webcolors module fall into five categories:
2121

2222
See :ref:`the documentation regarding conventions <conventions>` for
2323
information regarding the types and representation of various color formats in
24-
webcolors.
24+
``webcolors``.
2525

2626
All conversion functions which involve color names take an optional argument to
2727
determine the specification from which to draw color names. See :ref:`the set
@@ -34,26 +34,27 @@ raise :exc:`ValueError`.
3434

3535
.. admonition:: **Imports and submodules**
3636

37-
The public, supported API of webcolors is exported from its top-level
37+
The public, supported API of ``webcolors`` is exported from its top-level
3838
module, ``webcolors``. Although the codebase is internally organized into
3939
several submodules for easier maintenance, the existence, names, and
40-
organization of these submodules is *not* part of webcolors' supported API
41-
and cannot be relied upon.
40+
organization of these submodules is *not* part of ``webcolors``' supported
41+
API and cannot be relied upon.
4242

43-
For example: although :func:`normalize_hex` is actually implemented
44-
in a submodule named ``webcolors._normalization``, it must always be
45-
referred to as ``webcolors.normalize_hex``, **never** as
43+
For example: although :func:`normalize_hex` is actually implemented in a
44+
submodule named ``webcolors._normalization``, it must always be referred to
45+
as ``webcolors.normalize_hex``, **never** as
4646
``webcolors._normalization.normalize_hex``.
4747

4848

4949
Data types
5050
----------
5151

5252
Integer and percentage ``rgb()`` triplets, and HTML5 simple colors, can be
53-
passed to functions in webcolors as plain 3-:class:`tuple` of the appropriate
54-
data type. But the following :class:`~typing.NamedTuple` instances are also
55-
provided to represent these types more richly, and functions in webcolors which
56-
return triplets or simple colors will return instances of these:
53+
passed to functions in ``webcolors`` as plain 3-:class:`tuple` of the
54+
appropriate data type. But the following :class:`~typing.NamedTuple` instances
55+
are also provided to represent these types more richly, and functions in
56+
``webcolors`` which return triplets or simple colors will return instances of
57+
these:
5758

5859
.. autoclass:: IntegerRGB
5960
.. autoclass:: PercentRGB
@@ -68,8 +69,8 @@ defined, and used throughout this module:
6869
Constants
6970
---------
7071

71-
Several sets of constants are provided in webcolors, for use when converting or
72-
identifying colors or specifications.
72+
Several sets of constants are provided in ``webcolors``, for use when
73+
converting or identifying colors or specifications.
7374

7475
.. _spec-constants:
7576

@@ -196,15 +197,15 @@ Conversions from hexadecimal color values to other formats
196197
.. autofunction:: hex_to_rgb_percent
197198

198199

199-
Conversions from integer `rgb()` triplets to other formats
200+
Conversions from integer ``rgb()`` triplets to other formats
200201
------------------------------------------------------------
201202

202203
.. autofunction:: rgb_to_name
203204
.. autofunction:: rgb_to_hex
204205
.. autofunction:: rgb_to_rgb_percent
205206

206207

207-
Conversions from percentage `rgb()` triplets to other formats
208+
Conversions from percentage ``rgb()`` triplets to other formats
208209
---------------------------------------------------------------
209210

210211
.. autofunction:: rgb_percent_to_name

docs/conventions.rst

+19-18
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Normalization and conventions
66

77
Since the various formats used to specify colors in web documents do not always
88
map cleanly to Python data types, and some variation is permitted in how to use
9-
each format in a web document, webcolors applies a set of conventions for
9+
each format in a web document, ``webcolors`` applies a set of conventions for
1010
representing color names and values, and for normalizing them.
1111

1212

@@ -15,17 +15,17 @@ representing color names and values, and for normalizing them.
1515
Python string types
1616
-------------------
1717

18-
As Python 2 is no longer supported by the Python core team, webcolors now
18+
As Python 2 is no longer supported by the Python core team, ``webcolors`` now
1919
supports only Python 3, where the string type is a Unicode string. Python 3
2020
does still have the :class:`bytes` type, but all string arguments to functions
21-
in webcolors must be :class:`str` and never :class:`bytes`.
21+
in ``webcolors`` must be :class:`str` and never :class:`bytes`.
2222

2323

2424
Hexadecimal color values
2525
------------------------
2626

27-
For colors specified via hexadecimal values, webcolors will accept strings in
28-
the following formats:
27+
For colors specified via hexadecimal values, ``webcolors`` will accept strings
28+
in the following formats:
2929

3030
* The character ``#`` followed by three hexadecimal digits, where digits A-F
3131
may be upper- or lowercase.
@@ -37,8 +37,8 @@ the following formats:
3737

3838
For output which consists of a color specified via hexadecimal values, and for
3939
functions which perform intermediate conversion to hexadecimal before returning
40-
a result in another format, webcolors always normalizes such values to a string
41-
in the following format:
40+
a result in another format, ``webcolors`` always normalizes such values to a
41+
string in the following format:
4242

4343
* The character ``#`` followed by six hexadecimal digits, with digits A-F
4444
forced to lowercase (what HTML5 designates a "valid lowercase simple color").
@@ -90,15 +90,15 @@ normalization manually if desired.
9090
Color names
9191
-----------
9292

93-
For colors specified via predefined names, webcolors will accept strings
93+
For colors specified via predefined names, ``webcolors`` will accept strings
9494
containing names case-insensitively, so long as they contain no spaces or
9595
non-alphabetic characters. Thus, for example, ``"AliceBlue"`` and
9696
``"aliceblue"`` are both accepted, and both will refer to the same color:
9797
``rgb(240, 248, 255)``.
9898

9999
For output which consists of a color name, and for functions which perform
100100
intermediate conversion to a predefined name before returning a result in
101-
another format, webcolors always normalizes such values to be entirely
101+
another format, ``webcolors`` always normalizes such values to be entirely
102102
lowercase.
103103

104104
.. note:: **Spelling variants**
@@ -111,20 +111,21 @@ lowercase.
111111
``"lightslategray"``/``"lightslategrey"``, ``"slategray"``/``"slategrey"``.
112112

113113
Reversing from the hexadecimal value, integer tuple, or percent tuple to a
114-
name, for these colors, requires picking one spelling, and webcolors chooses
115-
the ``"gray"`` spellings for consistency with HTML 4, CSS1, and CSS2.
114+
name, for these colors, requires picking one spelling, and ``webcolors``
115+
chooses the ``"gray"`` spellings for consistency with HTML 4, CSS1, and
116+
CSS2.
116117

117118

118119

119120
Identifying sets of named colors
120121
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121122

122-
For purposes of identifying the specification from which to draw the
123-
selection of defined color names, webcolors uses strings naming the
124-
specifications, and provides :ref:`a set of constants containing the
125-
correct values <spec-constants>`.
123+
For purposes of identifying the specification from which to draw the selection
124+
of defined color names, ``webcolors`` uses strings naming the specifications,
125+
and provides :ref:`a set of constants containing the correct values
126+
<spec-constants>`.
126127

127128
Note that the CSS1 named colors are not supported here, as CSS1 merely
128-
"suggested" a set of color names, and declined to provide values for
129-
them. The CSS2 "system colors" are also not represented here, as they
130-
had no fixed defined values and are now deprecated.
129+
"suggested" a set of color names, and declined to provide values for them. The
130+
CSS2 "system colors" are also not represented here, as they had no fixed
131+
defined values and are now deprecated.

0 commit comments

Comments
 (0)