Commits

James Bennett  committed fd9ece0

Add initial conversion of documentation to Sphinx.

  • Participants
  • Parent commits 5b5991d

Comments (0)

Files changed (5)

 *.pyc
 dist
 MANIFEST
+_build
+_static

File docs/Makefile

+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html      to make standalone HTML files"
+	@echo "  dirhtml   to make HTML files named index.html in directories"
+	@echo "  pickle    to make pickle files"
+	@echo "  json      to make JSON files"
+	@echo "  htmlhelp  to make HTML files and a HTML help project"
+	@echo "  qthelp    to make HTML files and a qthelp project"
+	@echo "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  changes   to make an overview of all changed/added/deprecated items"
+	@echo "  linkcheck to check all external links for integrity"
+	@echo "  doctest   to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	-rm -rf _build/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html
+	@echo
+	@echo "Build finished. The HTML pages are in _build/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) _build/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in _build/dirhtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) _build/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in _build/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) _build/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in _build/qthelp, like this:"
+	@echo "# qcollectiongenerator _build/qthelp/webcolors.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile _build/qthelp/webcolors.qhc"
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in _build/latex."
+	@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
+	      "run these through (pdf)latex."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes
+	@echo
+	@echo "The overview file is in _build/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in _build/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) _build/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in _build/doctest/output.txt."

File docs/conf.py

+# -*- coding: utf-8 -*-
+#
+# webcolors documentation build configuration file, created by
+# sphinx-quickstart on Sun Aug 30 01:02:30 2009.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# 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.
+#sys.path.append(os.path.abspath('.'))
+
+# -- 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']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'webcolors'
+copyright = u'2009, James Bennett'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '1.3'
+# The full version, including alpha/beta/rc tags.
+release = '1.3.1'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directory, that shouldn't be searched
+# for source files.
+exclude_trees = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# 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']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_use_modindex = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'webcolorsdoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'webcolors.tex', u'webcolors Documentation',
+   u'James Bennett', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_use_modindex = True

File docs/index.rst

+.. webcolors documentation master file, created by
+   sphinx-quickstart on Sun Aug 30 01:02:30 2009.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+.. module:: webcolors
+
+
+webcolors
+=========
+
+This module provides a simple library for working with the color names
+and color codes defined by the HTML and CSS specifications.
+
+
+An overview of HTML and CSS colors
+----------------------------------
+
+Colors on the Web are specified in `the sRGB color space`_, where each
+color is made up of a red component, a green component and a blue
+component. This is useful because it maps (fairly) cleanly to the red,
+green and blue components of pixels on a computer display, and to the
+cone cells of a human eye, which come in three sets roughly
+corresponding to the wavelengths of light associated with red, green
+and blue.
+
+`The HTML 4 standard`_ defines two ways to specify sRGB colors:
+
+* A hash mark ('#') followed by three pairs of hexdecimal digits,
+  specifying values for red, green and blue components in that order;
+  for example, ``#0099cc``. Since each pair of hexadecimal digits can
+  express 256 different values, this allows up to 256**3 or 16,777,216
+  unique colors to be specified (though, due to differences in display
+  technology, not all of these colors may be clearly distinguished on
+  any given physical display).
+
+* A set of predefined color names which correspond to specific
+  hexadecimal values; for example, ``white``. HTML 4 defines sixteen
+  such colors.
+
+`The CSS 2 standard`_ allows any valid HTML 4 color specification, and
+adds three new ways to specify sRGB colors:
+
+* A hash mark followed by three hexadecimal digits, which is expanded
+  into three hexadecimal pairs by repeating each digit; thus ``#09c``
+  is equivalent to ``#0099cc``.
+
+* The string 'rgb', followed by parentheses, between which are three
+  numeric values each between 0 and 255, inclusive, which are taken to
+  be the values of the red, green and blue components in that order;
+  for example, ``rgb(0, 153, 204)``.
+
+* The same as above, except using percentages instead of numeric
+  values; for example, ``rgb(0%, 60%, 80%)``.
+
+`The CSS 2.1 revision`_ does not add any new methods of specifying
+sRGB colors, but does add one additional named color.
+
+`The CSS 3 color module`_ (currently a W3C Candidate Recommendation)
+adds one new way to specify sRGB colors:
+
+* A hue-saturation-lightness triple (HSL), using the construct
+  ``hsl()``.
+
+It also adds support for variable opacity of colors, by allowing the
+specification of alpha-channel information, through the ``rgba()`` and
+``hsla()`` constructs, which are identical to ``rgb()`` and ``hsl()``
+with one exception: a fourth value is supplied, indicating the level
+of opacity from ``0.0`` (completely transparent) to ``1.0``
+(completely opaque). Though not technically a color, the keyword
+``transparent`` is also made available in lieu of a color value, and
+corresponds to ``rgba(0,0,0,0)``.
+
+Additionally, CSS3 defines a new set of color names; this set is taken
+directly from the named colors defined for SVG (Scalable Vector
+Graphics) markup, and is a proper superset of the named colors defined
+in CSS 2.1. This set also has significant overlap with traditional X11
+color sets as defined by the ``rgb.txt`` file on many Unix and
+Unix-like operating systems, though the correspondence is not exact;
+the set of X11 colors is not standardized, and the set of CSS3 colors
+contains some definitions which diverge significantly from customary
+X11 definitions (for example, CSS3's ``green`` is not equivalent to
+X11's ``green``; the value which X11 designates ``green`` is
+designated ``lime`` in CSS3).
+
+.. _the sRGB color space: http://www.w3.org/Graphics/Color/sRGB
+.. _The HTML 4 standard: http://www.w3.org/TR/html401/types.html#h-6.5
+.. _The CSS 2 standard: http://www.w3.org/TR/REC-CSS2/syndata.html#value-def-color
+.. _The CSS 2.1 revision: http://www.w3.org/TR/CSS21/
+.. _The CSS 3 color module: http://www.w3.org/TR/css3-color/
+
+What this module supports
+-------------------------
+
+The mappings and functions within this module support the following
+methods of specifying sRGB colors, and conversions between them:
+
+* Six-digit hexadecimal.
+
+* Three-digit hexadecimal.
+
+* Integer ``rgb()`` triplet.
+
+* Percentage ``rgb()`` triplet.
+
+* Varying selections of predefined color names (see below).
+
+This module does not support ``hsl()`` triplets, nor does it support
+opacity/alpha-channel information via ``rgba()`` or ``hsla()``.
+
+If you need to convert between RGB-specified colors and HSL-specified
+colors, or colors specified via other means, consult `the colorsys
+module`_ in the Python standard library, which can perform conversions
+amongst several common color spaces.
+
+.. _the colorsys module: http://docs.python.org/library/colorsys.html
+
+Normalization
+~~~~~~~~~~~~~
+
+For colors specified via hexadecimal values, this module will accept
+input in the following formats:
+
+* A hash mark (#) followed by three hexadecimal digits, where letters
+  may be upper- or lower-case.
+
+* A hash mark (#) followed by six hexadecimal digits, where letters
+  may be upper- or lower-case.
+
+For output which consists of a color specified via hexadecimal values,
+and for functions which perform intermediate conversion to hexadecimal
+before returning a result in another format, this module always
+normalizes such values to the following format:
+
+* A hash mark (#) followed by six hexadecimal digits, with letters
+  forced to lower-case.
+
+The function ``normalize_hex()`` in this module can be used to perform
+this normalization manually if desired; see its documentation for an
+explanation of the normalization process.
+
+For colors specified via predefined names, this module will accept
+input in the following formats:
+
+* An entirely lower-case name, such as ``aliceblue``.
+
+* A name using initial capitals, such as ``AliceBlue``.
+
+For output which consists of a color specified via a predefined name,
+and for functions which perform intermediate conversion to a
+predefined name before returning a result in another format, this
+module always normalizes such values to be entirely lower-case.
+
+
+Module contents
+---------------
+
+.. function:: normalize_hex(hex_value)
+
+   Normalize a hexadecimal color value to the following form and
+   return the result::
+
+       #[a-f0-9]{6}
+
+   In other words, the following transformations are applied as
+   needed:
+
+   * If the value contains only three hexadecimal digits, it is
+     expanded to six.
+
+   * The value is normalized to lower-case.
+
+   If the supplied value cannot be interpreted as a hexadecimal color
+   value, ``ValueError`` is raised.
+
+   :param hex_value: The hexadecimal color value to normalize.
+
+
+Constants
+~~~~~~~~~
+
+.. data:: html4_names_to_hex
+
+   A dictionary whose keys are the names of the defined colors in HTML
+   4 (normalized to lowercase), and whose values are the corresponding
+   (normalized) hexadecimal color values.
+
+.. data:: html4_hex_to_names
+
+   A dictionary whose keys are (normalized) hexadecimal color values
+   of the named HTML 4 colors, and whose values are the corresponding
+   (normalized to lowercase) names.
+
+.. data:: css2_names_to_hex
+
+   A dictionary whose keys are the names of the defined colors in CSS
+   2 (normalized to lowercase), and whose values are the corresponding
+   (normalized) hexadecimal color values.
+
+   Because CSS 2 defines the same set of colors as HTML 4, this is
+   simply an alias for :data:`html4_names_to_hex`.
+
+.. data:: css2_hex_to_names
+
+   A dictionary whose keys are (normalized) hexadecimal color values
+   of the named CSS 2 colors, and whose values are the corresponding
+   (normalized to lowercase) names.
+
+   Because CSS 2 defines the same set of colors as HTML 4, this is
+   simply an alias for :data:`html4_hex_to_names`.
+
+.. data:: css21_names_to_hex
+
+   A dictionary whose keys are the names of the defined colors in CSS
+   2.1 (normalized to lowercase), and whose values are the
+   corresponding (normalized) hexadecimal color values.
+
+.. data:: css21_hex_to_names
+
+   A dictionary whose keys are the (normalized) hexadecimal color
+   values of the named CSS 2.1 colors, and whose values are the
+   corresponding (normalized to lowercase) names.
+
+.. data:: css3_names_to_hex
+
+   A dictionary whose keys are the names of the defined colors in the
+   CSS 3 color module (normalized to lowercase), and whose values are
+   the corresponding (normalized) hexadecimal color values.
+
+.. data:: css3_hex_to_names
+
+   A dictionary whose keys are the (normalized) hexadecimal color
+   values of the named CSS 3 colors, and whose values are the
+   corresponding (normalized to lowercase) names.
+
+
+Conversions from color names to other formats
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. function:: name_to_hex(name, spec='css3')
+
+   Convert a color name to a normalized hexadecimal color value.
+
+   The color name will be normalized to lower-case before being looked
+   up, and when no color of that name exists in the given
+   specification, ``ValueError`` is raised.
+
+   Examples::
+
+       >>> name_to_rgb('navy')
+       (0, 0, 128)
+       >>> name_to_rgb('cadetblue')
+       (95, 158, 160)
+       >>> name_to_rgb('cadetblue', spec='html4')
+       Traceback (most recent call last):
+           ...
+       ValueError: 'cadetblue' is not defined as a named color in html4.
+
+   :param name: The color name to convert.
+   :param spec: The specification from which to draw the list of color
+      names; valid values are ``html4``, ``css2``, ``css21`` and
+      ``css3``. Default is ``css3``.
+
+.. function:: name_to_rgb(name, spec='css3')
+
+   Convert a color name to a 3-tuple of integers suitable for use in
+   an ``rgb()`` triplet specifying that color.
+
+   The color name will be normalized to lower-case before being looked
+   up, and when no color of that name exists in the given
+   specification, ``ValueError`` is raised.
+
+   Examples::
+
+       >>> name_to_rgb_percent('white')
+       ('100%', '100%', '100%')
+       >>> name_to_rgb_percent('navy')
+       ('0%', '0%', '50%')
+       >>> name_to_rgb_percent('goldenrod')
+       ('85.49%', '64.71%', '12.5%')
+
+   :param name: The color name to convert.
+   :param spec: The specification from which to draw the list of color
+      names; valid values are ``html4``, ``css2``, ``css21`` and
+      ``css3``. Default is ``css3``.
+
+.. function:: name_to_rgb_percent(name, spec='css3')
+
+   Convert a color name to a 3-tuple of percentages suitable for use
+   in an ``rgb()`` triplet specifying that color.
+
+   The color name will be normalized to lower-case before being looked
+   up, and when no color of that name exists in the given
+   specification, ``ValueError`` is raised.
+
+   Examples::
+
+       >>> name_to_rgb_percent('white')
+       ('100%', '100%', '100%')
+       >>> name_to_rgb_percent('navy')
+       ('0%', '0%', '50%')
+       >>> name_to_rgb_percent('goldenrod')
+       ('85.49%', '64.71%', '12.5%')
+
+   :param name: The color name to convert.
+   :param spec: The specification from which to draw the list of color
+      names; valid values are ``html4``, ``css2``, ``css21`` and
+      ``css3``. Default is ``css3``.
+
+
+Conversions from hexadecimal color values to other formats
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. function:: hex_to_name(hex_value, spec='css3')
+
+   Convert a hexadecimal color value to its corresponding normalized
+   color name, if any such name exists.
+
+   The hexadecimal value will be normalized before being looked up,
+   and when no color name for the value is found in the given
+   specification, ``ValueError`` is raised.
+
+   Examples::
+
+       >>> hex_to_name('#000080')
+       'navy'
+       >>> hex_to_name('#000080', spec='html4')
+       'navy'
+       >>> hex_to_name('#8b4513')
+       'saddlebrown'
+       >>> hex_to_name('#8b4513', spec='html4')
+       Traceback (most recent call last):
+           ...
+       ValueError: '#8b4513' has no defined color name in html4.
+
+   :param hex_value: The hexadecimal color value to convert.
+   :param spec: The specification from which to draw the list of color
+      names; valid values are ``html4``, ``css2``, ``css21`` and
+      ``css3``. Default is ``css3``.
+
+.. function:: hex_to_rgb(hex_value)
+
+   Convert a hexadecimal color value to a 3-tuple of integers suitable
+   for use in an ``rgb()`` triplet specifying that color.
+
+   The hexadecimal value will be normalized before being converted.
+
+   Examples::
+
+       >>> hex_to_rgb('#000080')
+       (0, 0, 128)
+       >>> hex_to_rgb('#ffff00')
+       (255, 255, 0)
+       >>> hex_to_rgb('#f00')
+       (255, 0, 0)
+       >>> hex_to_rgb('#deb887')
+       (222, 184, 135)
+
+   :param hex_value: The hexadecimal color value to convert.
+
+.. function:: hex_to_rgb_percent(hex_value)
+
+   Convert a hexadecimal color value to a 3-tuple of percentages
+   suitable for use in an ``rgb()`` triplet representing that color.
+
+   The hexadecimal value will be normalized before converting.
+
+   Examples::
+
+       >>> hex_to_rgb_percent('#ffffff')
+       ('100%', '100%', '100%')
+       >>> hex_to_rgb_percent('#000080')
+       ('0%', '0%', '50%')
+
+   :param hex_value: The hexadecimal color value to convert.
+
+
+Conversions from integer ``rgb()`` triplets to other formats
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. function:: rgb_to_name(rgb_triplet, spec='css3')
+
+   Convert a 3-tuple of integers, suitable for use in an ``rgb()``
+   color triplet, to its corresponding normalized color name, if any
+   such name exists.
+
+   If there is no matching name, ``ValueError`` is raised.
+
+   Examples::
+
+       >>> rgb_to_name((0, 0, 0))
+       'black'
+       >>> rgb_to_name((0, 0, 128))
+       'navy'
+       >>> rgb_to_name((95, 158, 160))
+       'cadetblue'
+
+   :param rgb_triplet: The ``rgb()`` triplet, as a three-tuple of
+      integers.
+   :param spec: The specification from which to draw the list of color
+      names; valid values are ``html4``, ``css2``, ``css21`` and
+      ``css3``. Default is ``css3``.
+
+.. function:: rgb_to_hex(rgb_triplet)
+
+   Convert a 3-tuple of integers, suitable for use in an ``rgb()``
+   color triplet, to a normalized hexadecimal value for that color.
+
+   Examples::
+
+       >>> rgb_to_hex((255, 255, 255))
+       '#ffffff'
+       >>> rgb_to_hex((0, 0, 128))
+       '#000080'
+       >>> rgb_to_hex((33, 56, 192))
+       '#2138c0'
+
+   :param rgb_triplet: The ``rgb()`` triplet, as a three-tuple of
+      integers.
+
+.. function:: rgb_to_rgb_percent(rgb_triplet)
+
+   Convert a 3-tuple of integers, suitable for use in an ``rgb()``
+   color triplet, to a 3-tuple of percentages suitable for use in
+   representing that color.
+
+   This function makes some trade-offs in terms of the accuracy of the
+   final representation; for some common integer values, special-case
+   logic is used to ensure a precise result (e.g., integer 128 will
+   always convert to '50%', integer 32 will always convert to
+   '12.5%'), but for all other values a standard Python ``float`` is
+   used and rounded to two decimal places, which may result in a loss
+   of precision for some values.
+
+   Examples:
+
+       >>> rgb_to_rgb_percent((255, 255, 255))
+       ('100%', '100%', '100%')
+       >>> rgb_to_rgb_percent((0, 0, 128))
+       ('0%', '0%', '50%')
+       >>> rgb_to_rgb_percent((33, 56, 192))
+       ('12.94%', '21.96%', '75.29%')
+       >>> rgb_to_rgb_percent((64, 32, 16))
+       ('25%', '12.5%', '6.25%')
+
+   :param rgb_triplet: The ``rgb()`` triplet, as a three-tuple of
+      integers.
+
+
+Conversions from percentage ``rgb()`` triplets to other formats
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. function:: rgb_percent_to_name(rgb_percent_triplet, spec='css3')
+
+   Convert a 3-tuple of percentages, suitable for use in an ``rgb()``
+   color triplet, to its corresponding normalized color name, if any
+   such name exists.
+
+   If there is no matching name, ``ValueError`` is raised.
+
+   Examples::
+
+       >>> rgb_percent_to_name(('0%', '0%', '0%'))
+       'black'
+       >>> rgb_percent_to_name(('0%', '0%', '50%'))
+       'navy'
+       >>> rgb_percent_to_name(('85.49%', '64.71%', '12.5%'))
+       'goldenrod'
+
+   :param rgb_percent_triplet: The ``rgb()`` triplet, as a three-tuple
+      of strings giving percentage values.
+   :param spec: The specification from which to draw the list of color
+      names; valid values are ``html4``, ``css2``, ``css21`` and
+      ``css3``. Default is ``css3``.
+
+.. function:: rgb_percent_to_hex(rgb_percent_triplet)
+
+   Convert a 3-tuple of percentages, suitable for use in an ``rgb()``
+   color triplet, to a normalized hexadecimal color value for that
+   color.
+
+   Examples::
+
+       >>> rgb_percent_to_hex(('100%', '100%', '0%'))
+       '#ffff00'
+       >>> rgb_percent_to_hex(('0%', '0%', '50%'))
+       '#000080'
+       >>> rgb_percent_to_hex(('85.49%', '64.71%', '12.5%'))
+       '#daa520'
+
+   :param rgb_percent_triplet: The ``rgb()`` triplet, as a three-tuple
+      of strings giving percentage values.
+
+.. function:: rgb_percent_to_rgb(rgb_percent_triplet)
+
+   Convert a 3-tuple of percentages, suitable for use in an ``rgb()``
+   color triplet, to a 3-tuple of integers suitable for use in
+   representing that color.
+
+   Some precision may be lost in this conversion. See the note
+   regarding precision for ``rgb_to_rgb_percent()`` for details;
+   generally speaking, the following is true for any 3-tuple ``t`` of
+   integers in the range 0...255 inclusive::
+
+       t == rgb_percent_to_rgb(rgb_to_rgb_percent(t))
+
+   Examples::
+
+       >>> rgb_percent_to_rgb(('100%', '100%', '100%'))
+       (255, 255, 255)
+       >>> rgb_percent_to_rgb(('0%', '0%', '50%'))
+       (0, 0, 128)
+       >>> rgb_percent_to_rgb(('25%', '12.5%', '6.25%'))
+       (64, 32, 16)
+       >>> rgb_percent_to_rgb(('12.94%', '21.96%', '75.29%'))
+       (33, 56, 192)
+
+   :param rgb_percent_triplet: The ``rgb()`` triplet, as a three-tuple
+      of strings giving percentage values.

File docs/make.bat

+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+set SPHINXBUILD=sphinx-build
+set ALLSPHINXOPTS=-d _build/doctrees %SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+	:help
+	echo.Please use `make ^<target^>` where ^<target^> is one of
+	echo.  html      to make standalone HTML files
+	echo.  dirhtml   to make HTML files named index.html in directories
+	echo.  pickle    to make pickle files
+	echo.  json      to make JSON files
+	echo.  htmlhelp  to make HTML files and a HTML help project
+	echo.  qthelp    to make HTML files and a qthelp project
+	echo.  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+	echo.  changes   to make an overview over all changed/added/deprecated items
+	echo.  linkcheck to check all external links for integrity
+	echo.  doctest   to run all doctests embedded in the documentation if enabled
+	goto end
+)
+
+if "%1" == "clean" (
+	for /d %%i in (_build\*) do rmdir /q /s %%i
+	del /q /s _build\*
+	goto end
+)
+
+if "%1" == "html" (
+	%SPHINXBUILD% -b html %ALLSPHINXOPTS% _build/html
+	echo.
+	echo.Build finished. The HTML pages are in _build/html.
+	goto end
+)
+
+if "%1" == "dirhtml" (
+	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% _build/dirhtml
+	echo.
+	echo.Build finished. The HTML pages are in _build/dirhtml.
+	goto end
+)
+
+if "%1" == "pickle" (
+	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% _build/pickle
+	echo.
+	echo.Build finished; now you can process the pickle files.
+	goto end
+)
+
+if "%1" == "json" (
+	%SPHINXBUILD% -b json %ALLSPHINXOPTS% _build/json
+	echo.
+	echo.Build finished; now you can process the JSON files.
+	goto end
+)
+
+if "%1" == "htmlhelp" (
+	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% _build/htmlhelp
+	echo.
+	echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in _build/htmlhelp.
+	goto end
+)
+
+if "%1" == "qthelp" (
+	%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% _build/qthelp
+	echo.
+	echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in _build/qthelp, like this:
+	echo.^> qcollectiongenerator _build\qthelp\webcolors.qhcp
+	echo.To view the help file:
+	echo.^> assistant -collectionFile _build\qthelp\webcolors.ghc
+	goto end
+)
+
+if "%1" == "latex" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% _build/latex
+	echo.
+	echo.Build finished; the LaTeX files are in _build/latex.
+	goto end
+)
+
+if "%1" == "changes" (
+	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% _build/changes
+	echo.
+	echo.The overview file is in _build/changes.
+	goto end
+)
+
+if "%1" == "linkcheck" (
+	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% _build/linkcheck
+	echo.
+	echo.Link check complete; look for any errors in the above output ^
+or in _build/linkcheck/output.txt.
+	goto end
+)
+
+if "%1" == "doctest" (
+	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% _build/doctest
+	echo.
+	echo.Testing of doctests in the sources finished, look at the ^
+results in _build/doctest/output.txt.
+	goto end
+)
+
+:end