[Python-modules-commits] [python-tinycss] 01/03: importing python-tinycss_0.4.orig.tar.gz

Michael Fladischer fladi at moszumanska.debian.org
Fri Dec 16 11:49:05 UTC 2016


This is an automated email from the git hooks/post-receive script.

fladi pushed a commit to branch master
in repository python-tinycss.

commit 0e1ebf4f69ec0437e95a8b3452b342a6456474ee
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date:   Fri Dec 16 09:46:06 2016 +0100

    importing python-tinycss_0.4.orig.tar.gz
---
 .coveragerc                     |  10 +
 .gitignore                      |  12 +
 .travis.yml                     |  16 +
 CHANGES                         |  53 +++
 LICENSE                         |  31 ++
 MANIFEST.in                     |   3 +
 PKG-INFO                        |  47 +++
 README.rst                      |  26 ++
 docs/_static/custom.css         |  24 ++
 docs/_templates/layout.html     |   4 +
 docs/changelog.rst              |   1 +
 docs/conf.py                    | 252 ++++++++++++
 docs/css3.rst                   | 116 ++++++
 docs/extending.rst              |  97 +++++
 docs/hacking.rst                | 117 ++++++
 docs/index.rst                  |  50 +++
 docs/parsing.rst                |  97 +++++
 setup.cfg                       |  23 ++
 setup.py                        | 127 +++++++
 tinycss/__init__.py             |  47 +++
 tinycss/color3.py               | 383 +++++++++++++++++++
 tinycss/css21.py                | 823 ++++++++++++++++++++++++++++++++++++++++
 tinycss/decoding.py             | 252 ++++++++++++
 tinycss/fonts3.py               | 200 ++++++++++
 tinycss/page3.py                | 162 ++++++++
 tinycss/parsing.py              | 166 ++++++++
 tinycss/speedups.pyx            | 189 +++++++++
 tinycss/tests/__init__.py       |  26 ++
 tinycss/tests/speed.py          | 134 +++++++
 tinycss/tests/test_api.py       |  45 +++
 tinycss/tests/test_color3.py    | 202 ++++++++++
 tinycss/tests/test_css21.py     | 353 +++++++++++++++++
 tinycss/tests/test_decoding.py  |  79 ++++
 tinycss/tests/test_fonts3.py    | 144 +++++++
 tinycss/tests/test_page3.py     | 101 +++++
 tinycss/tests/test_tokenizer.py | 302 +++++++++++++++
 tinycss/token_data.py           | 452 ++++++++++++++++++++++
 tinycss/tokenizer.py            | 215 +++++++++++
 tinycss/version.py              |   1 +
 39 files changed, 5382 insertions(+)

diff --git a/.coveragerc b/.coveragerc
new file mode 100644
index 0000000..a79ad05
--- /dev/null
+++ b/.coveragerc
@@ -0,0 +1,10 @@
+[run]
+branch = True
+
+[report]
+exclude_lines =
+    pragma: no cover
+    def __repr__
+    except ImportError
+omit =
+    tinycss/tests/speed.py
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d9285a1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,12 @@
+*.pyc
+*.c
+*.so
+*.egg-info
+/.coverage
+/htmlcov
+/build
+/dist
+/.tox
+/MANIFEST
+/docs/_build
+/env
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..618318d
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,16 @@
+language: python
+
+python:
+  - "2.7"
+  - "3.3"
+  - "3.4"
+  - "3.5"
+  - "pypy"
+  - "pypy3"
+
+install:
+  - pip install Cython
+  - pip install --upgrade -e .[test]
+
+script:
+  - python setup.py test
diff --git a/CHANGES b/CHANGES
new file mode 100644
index 0000000..27b8cf7
--- /dev/null
+++ b/CHANGES
@@ -0,0 +1,53 @@
+tinycss changelog
+=================
+
+
+Version 0.4
+-----------
+
+Released on 2016-09-23.
+
+* Add an __eq__ operator to Token object.
+* Support Fonts 3.
+
+
+
+Version 0.3
+-----------
+
+Released on 2012-09-18.
+
+* Fix a bug when parsing \5c (an escaped antislash.)
+
+
+
+Version 0.2
+-----------
+
+Released on 2012-04-27.
+
+**Breaking changes:**
+
+* Remove the ``selectors3`` module. The functionality has moved to the
+  `cssselect <http://packages.python.org/cssselect/>`_ project.
+* Simplify the API for :func:`~tinycss.make_parser`.
+
+
+Version 0.1.1
+-------------
+
+Released on 2012-04-06.
+
+Bug fixes:
+
+* Error handling on exepected end of stylesheet in an at-rule head
+* Fix the installation on ASCII-only locales
+
+
+Version 0.1
+-----------
+
+Released on 2012-04-05.
+
+First release. Parser support for CSS 2.1, Seloctors 3, Color 3 and
+Paged Media 3.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..52d60c5
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,31 @@
+Copyright (c) 2012 by Simon Sapin.
+
+Some rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+
+    * The names of the contributors may not be used to endorse or
+      promote products derived from this software without specific
+      prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..4847068
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,3 @@
+include README.rst CHANGES LICENSE tox.ini .coveragerc tinycss/speedups.c
+recursive-include docs *
+prune docs/_build
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..710dc9c
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,47 @@
+Metadata-Version: 1.1
+Name: tinycss
+Version: 0.4
+Summary: tinycss is a complete yet simple CSS parser for Python.
+Home-page: http://tinycss.readthedocs.io/
+Author: Simon Sapin
+Author-email: simon.sapin at exyr.org
+License: BSD
+Description: tinycss: CSS parser for Python
+        ==============================
+        
+        *tinycss* is a complete yet simple CSS parser for Python. It supports the full
+        syntax and error handling for CSS 2.1 as well as some CSS 3 modules:
+        
+        * CSS Color 3
+        * CSS Fonts 3
+        * CSS Paged Media 3
+        
+        It is designed to be easy to extend for new CSS modules and syntax,
+        and integrates well with cssselect_ for Selectors 3 support.
+        
+        Quick facts:
+        
+        * Free software: BSD licensed
+        * Compatible with Python 2.7 and 3.x
+        * Latest documentation `on python.org`_
+        * Source, issues and pull requests `on Github`_
+        * Releases `on PyPI`_
+        * Install with ``pip install tinycss``
+        
+        .. _cssselect: http://packages.python.org/cssselect/
+        .. _on python.org: http://packages.python.org/tinycss/
+        .. _on Github: https://github.com/SimonSapin/tinycss/
+        .. _on PyPI: http://pypi.python.org/pypi/tinycss
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..9f1879b
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,26 @@
+tinycss: CSS parser for Python
+==============================
+
+*tinycss* is a complete yet simple CSS parser for Python. It supports the full
+syntax and error handling for CSS 2.1 as well as some CSS 3 modules:
+
+* CSS Color 3
+* CSS Fonts 3
+* CSS Paged Media 3
+
+It is designed to be easy to extend for new CSS modules and syntax,
+and integrates well with cssselect_ for Selectors 3 support.
+
+Quick facts:
+
+* Free software: BSD licensed
+* Compatible with Python 2.7 and 3.x
+* Latest documentation `on python.org`_
+* Source, issues and pull requests `on Github`_
+* Releases `on PyPI`_
+* Install with ``pip install tinycss``
+
+.. _cssselect: http://packages.python.org/cssselect/
+.. _on python.org: http://packages.python.org/tinycss/
+.. _on Github: https://github.com/SimonSapin/tinycss/
+.. _on PyPI: http://pypi.python.org/pypi/tinycss
diff --git a/docs/_static/custom.css b/docs/_static/custom.css
new file mode 100644
index 0000000..ea5c271
--- /dev/null
+++ b/docs/_static/custom.css
@@ -0,0 +1,24 @@
+div.body {
+    text-align: left;
+}
+div.document p, div.document ul {
+    margin-top: 0;
+    margin-bottom: 1em;
+}
+div.document ul ul {
+    margin-top: 0;
+    margin-bottom: .5em;
+}
+.field-name {
+    padding-right: .5em;
+}
+table.field-list p, table.field-list ul {
+    margin-bottom: .5em;
+}
+table {
+    border-collapse: collapse;
+    margin-bottom: 1em;
+}
+table.docutils td, table.docutils th {
+    padding: .2em .5em;
+}
diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html
new file mode 100644
index 0000000..3ac9078
--- /dev/null
+++ b/docs/_templates/layout.html
@@ -0,0 +1,4 @@
+{% extends "!layout.html" %}
+{% block extrahead %}
+    <link rel="stylesheet" href="{{ pathto('_static/custom.css', 1) }}" />
+{% endblock %} 
diff --git a/docs/changelog.rst b/docs/changelog.rst
new file mode 100644
index 0000000..d6c5f48
--- /dev/null
+++ b/docs/changelog.rst
@@ -0,0 +1 @@
+.. include:: ../CHANGES
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..fa7da0a
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,252 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# tinycss documentation build configuration file, created by
+# sphinx-quickstart on Tue Mar 27 14:20:34 2012.
+#
+# 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.insert(0, os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx',
+              'sphinx.ext.viewcode', 'sphinx.ext.doctest']
+
+# 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-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = 'tinycss'
+copyright = '2012, Simon Sapin'
+
+# 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 full version, including alpha/beta/rc tags.
+#release = '0.1dev'
+import re
+with open(os.path.join(os.path.dirname(__file__), '..',
+                       'tinycss', 'version.py')) as init_py:
+    release = re.search("VERSION = '([^']+)'", init_py.read()).group(1)
+# The short X.Y version.
+version = release.rstrip('dev')
+
+# 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 patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_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.  See the documentation for
+# a list of builtin themes.
+#html_theme = 'agogo'
+
+# 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_domain_indices = 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, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = 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 = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'tinycssdoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'tinycss.tex', 'tinycss Documentation',
+   'Simon Sapin', '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
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    ('index', 'tinycss', 'tinycss Documentation',
+     ['Simon Sapin'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output ------------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+  ('index', 'tinycss', 'tinycss Documentation',
+   'Simon Sapin', 'tinycss', 'One line description of project.',
+   'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+
+# Example configuration for intersphinx: refer to the Python standard library.
+intersphinx_mapping = {'http://docs.python.org/': None}
diff --git a/docs/css3.rst b/docs/css3.rst
new file mode 100644
index 0000000..91ad4c2
--- /dev/null
+++ b/docs/css3.rst
@@ -0,0 +1,116 @@
+CSS 3 Modules
+=============
+
+.. _selectors3:
+
+Selectors 3
+-----------
+
+.. currentmodule:: tinycss.css21
+
+On :attr:`RuleSet.selector`, the :meth:`~.token_data.TokenList.as_css` method
+can be used to serialize a selector back to an Unicode string.
+
+    >>> import tinycss
+    >>> stylesheet = tinycss.make_parser().parse_stylesheet(
+    ...     'div.error, #root > section:first-letter { color: red }')
+    >>> selector_string = stylesheet.rules[0].selector.as_css()
+    >>> selector_string
+    'div.error, #root > section:first-letter'
+
+This string can be parsed by cssselect_. The parsed objects have information
+about pseudo-elements and selector specificity.
+
+.. _cssselect: http://packages.python.org/cssselect/
+
+    >>> import cssselect
+    >>> selectors = cssselect.parse(selector_string)
+    >>> [s.specificity() for s in selectors]
+    [(0, 1, 1), (1, 0, 2)]
+    >>> [s.pseudo_element for s in selectors]
+    [None, 'first-letter']
+
+These objects can in turn be translated to XPath expressions. Note that
+the translation ignores pseudo-elements, you have to account for them
+somehow or reject selectors with pseudo-elements.
+
+    >>> xpath = cssselect.HTMLTranslator().selector_to_xpath(selectors[1])
+    >>> xpath
+    "descendant-or-self::*[@id = 'root']/section"
+
+Finally, the XPath expressions can be used with lxml_ to find the matching
+elements.
+
+    >>> from lxml import etree
+    >>> compiled_selector = etree.XPath(xpath)
+    >>> document = etree.fromstring('''<section id="root">
+    ...   <section id="head">Title</section>
+    ...   <section id="content">
+    ...     Lorem <section id="sub-section">ipsum</section>
+    ...   </section>
+    ... </section>''')
+    >>> [el.get('id') for el in compiled_selector(document)]
+    ['head', 'content']
+
+.. _lxml: http://lxml.de/xpathxslt.html#xpath
+
+Find more details in the `cssselect documentation`_.
+
+.. _cssselect documentation: http://packages.python.org/cssselect/
+
+
+.. module:: tinycss.color3
+
+Color 3
+-------
+
+This module implements parsing for the *<color>* values, as defined in
+`CSS 3 Color <http://www.w3.org/TR/css3-color/>`_.
+
+The (deprecated) CSS2 system colors are not supported, but you can
+easily test for them if you want as they are simple ``IDENT`` tokens.
+For example::
+
+    if token.type == 'IDENT' and token.value == 'ButtonText':
+        return ...
+
+All other values types *are* supported:
+
+* Basic, extended (X11) and transparent color keywords;
+* 3-digit and 6-digit hexadecimal notations;
+* ``rgb()``, ``rgba()``, ``hsl()`` and ``hsla()`` functional notations.
+* ``currentColor``
+
+This module does not integrate with a parser class. Instead, it provides
+a function that can parse tokens as found in :attr:`.css21.Declaration.value`,
+for example.
+
+.. autofunction:: parse_color
+.. autofunction:: parse_color_string
+.. autoclass:: RGBA
+
+
+.. module:: tinycss.page3
+
+Paged Media 3
+-------------
+
+.. autoclass:: CSSPage3Parser
+.. autoclass:: MarginRule
+
+
+.. module:: tinycss.fonts3
+
+Fonts 3
+-------
+
+.. autoclass:: CSSFonts3Parser
+.. autoclass:: FontFaceRule
+.. autoclass:: FontFeatureValuesRule
+.. autoclass:: FontFeatureRule
+
+
+Other CSS modules
+-----------------
+
+To add support for new CSS syntax, see :ref:`extending`.
diff --git a/docs/extending.rst b/docs/extending.rst
new file mode 100644
index 0000000..d688865
--- /dev/null
+++ b/docs/extending.rst
@@ -0,0 +1,97 @@
+.. _extending:
+
+Extending the parser
+====================
+
+Modules such as :mod:`.page3` extend the CSS 2.1 parser to add support for
+CSS 3 syntax.
+They do so by sub-classing :class:`.css21.CSS21Parser` and overriding/extending
+some of its methods. If fact, the parser is made of methods in a class
+(rather than a set of functions) solely to enable this kind of sub-classing.
+
+tinycss is designed to enable you to have parser subclasses outside of
+tinycss, without monkey-patching. If however the syntax you added is for a
+W3C specification, consider including your subclass in a new tinycss module
+and send a pull request: see :ref:`hacking`.
+
+
+.. currentmodule:: tinycss.css21
+
+Example: star hack
+------------------
+
+.. _star hack: https://en.wikipedia.org/wiki/CSS_filter#Star_hack
+
+The `star hack`_ uses invalid declarations that are only parsed by some
+versions of Internet Explorer. By default, tinycss ignores invalid
+declarations and logs an error.
+
+    >>> from tinycss.css21 import CSS21Parser
+    >>> css = '#elem { width: [W3C Model Width]; *width: [BorderBox Model]; }'
+    >>> stylesheet = CSS21Parser().parse_stylesheet(css)
+    >>> stylesheet.errors
+    [ParseError('Parse error at 1:35, expected a property name, got DELIM',)]
+    >>> [decl.name for decl in stylesheet.rules[0].declarations]
+    ['width']
+
+If for example a minifier based on tinycss wants to support the star hack,
+it can by extending the parser::
+
+    >>> class CSSStarHackParser(CSS21Parser):
+    ...     def parse_declaration(self, tokens):
+    ...         has_star_hack = (tokens[0].type == 'DELIM' and tokens[0].value == '*')
+    ...         if has_star_hack:
+    ...             tokens = tokens[1:]
+    ...         declaration = super(CSSStarHackParser, self).parse_declaration(tokens)
+    ...         declaration.has_star_hack = has_star_hack
+    ...         return declaration
+    ...
+    >>> stylesheet = CSSStarHackParser().parse_stylesheet(css)
+    >>> stylesheet.errors
+    []
+    >>> [(d.name, d.has_star_hack) for d in stylesheet.rules[0].declarations]
+    [('width', False), ('width', True)]
+
+This class extends the :meth:`~CSS21Parser.parse_declaration` method.
+It removes any ``*`` delimeter :class:`~.token_data.Token` at the start of
+a declaration, and adds a ``has_star_hack`` boolean attribute on parsed
+:class:`Declaration` objects: ``True`` if a ``*`` was removed, ``False`` for
+“normal” declarations.
+
+
+Parser methods
+--------------
+
+In addition to methods of the user API (see :ref:`parsing`), here
+are the methods of the CSS 2.1 parser that can be overriden or extended:
+
+.. automethod:: CSS21Parser.parse_rules
+.. automethod:: CSS21Parser.read_at_rule
+.. automethod:: CSS21Parser.parse_at_rule
+.. automethod:: CSS21Parser.parse_media
+.. automethod:: CSS21Parser.parse_page_selector
+.. automethod:: CSS21Parser.parse_declarations_and_at_rules
+.. automethod:: CSS21Parser.parse_ruleset
+.. automethod:: CSS21Parser.parse_declaration_list
+.. automethod:: CSS21Parser.parse_declaration
+.. automethod:: CSS21Parser.parse_value_priority
+
+Unparsed at-rules
+-----------------
+
+.. autoclass:: AtRule
+
+
+.. module:: tinycss.parsing
+
+Parsing helper functions
+------------------------
+
+The :mod:`tinycss.parsing` module contains helper functions for parsing
+tokens into a more structured form:
+
+.. autofunction:: strip_whitespace
+.. autofunction:: split_on_comma
+.. autofunction:: validate_value
+.. autofunction:: validate_block
+.. autofunction:: validate_any
diff --git a/docs/hacking.rst b/docs/hacking.rst
new file mode 100644
index 0000000..8fbd613
--- /dev/null
+++ b/docs/hacking.rst
@@ -0,0 +1,117 @@
+.. _hacking:
+
+Hacking tinycss
+===============
+
+.. highlight:: sh
+
+Bugs and feature requests
+-------------------------
+
+Bug reports, feature requests and other issues should got to the
+`tinycss issue tracker`_ on Github. Any suggestion or feedback is welcome.
+Please include in full any error message, trackback or other detail that
+could be helpful.
+
+.. _tinycss issue tracker: https://github.com/SimonSapin/tinycss/issues
+
+
+Installing the development version
+----------------------------------
+
+First, get the latest git version::
+
+    git clone https://github.com/SimonSapin/tinycss.git
+    cd tinycss
+
+You will need Cython_ and pytest_. Installing in a virtualenv_ is recommended::
+
+    virtualenv env
+    . env/bin/activate
+    pip install Cython pytest
+
+.. _Cython: http://cython.org/
+.. _pytest: http://pytest.org/
+.. _virtualenv: http://www.virtualenv.org/
+
+Then, install tinycss in-place with pip’s *editable mode*. This will also
+build the accelerators::
+
+    pip install -e .
+
+
+Running the test suite
+----------------------
+
+Once you have everything installed (see above), just run pytest from the
+*tinycss* directory::
+
+    py.test
+
+If the accelerators are not available for some reason, use the
+``TINYCSS_SKIP_SPEEDUPS_TESTS`` environment variable::
+
+    TINYCSS_SKIP_SPEEDUPS_TESTS=1 py.test
+
+If you get test failures on a fresh git clone, something may have gone wrong
+during the installation. Otherwise, you probably found a bug. Please
+`report it <#bugs-and-feature-requests>`_.
+
+
+Test in multiple Python versions with tox
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+tox_ automatically creates virtualenvs for various Python versions and
+runs the test suite there::
+
+    pip install tox
+
+Change to the project’s root directory and just run::
+
+    tox
+
+.. _tox: http://tox.testrun.org/
+
+tinycss comes with a pre-configured ``tox.ini`` file to test in CPython
+2.6, 2.7, 3.1 and 3.2 as well as PyPy. You can change that with the ``-e``
+parameter::
+
+    tox -e py27,py32
+
+If you use ``--`` in the arguments passed to tox, further arguments
+are passed to the underlying ``py.test`` command::
+
+    tox -- -x --pdb
+
+
+Building the documentation
+--------------------------
+
+This documentation is made with Sphinx_::
+
+    pip install Sphinx
+
+.. _Sphinx: http://sphinx.pocoo.org/
+
+To build the HTML version of the documentation, change to the project’s root
+directory and run::
+
+    python setup.py build_sphinx
+
+The built HTML files are in ``docs/_build/html``.
+
+
+Making a patch and a pull request
+---------------------------------
+
+If you would like to see something included in tinycss, please fork
+`the repository <https://github.com/SimonSapin/tinycss/>`_ on Github
+and make a pull request. Make sure to include tests for your change.
+
+
+Mailing-list
+------------
+
+tinycss does not have a mailing-list of its own for now, but the
+`WeasyPrint mailing-list <http://weasyprint.org/community/>`_
+is appropriate to discuss it.
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..541ff9d
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,50 @@
+.. include:: ../README.rst
+
+
+Requirements
+------------
+
+`tinycss is tested <https://travis-ci.org/Kozea/tinycss>`_ on CPython 2.7, 3.3,
+3.4 and 3.5 as well as PyPy 5.3 and PyPy3 2.4; it should work on any
+implementation of **Python 2.7 or later version (including 3.x)** of the
+language.
+
+Cython_ is used for optional accelerators but is only required for
+development versions on tinycss.
+
+.. _Cython: http://cython.org/
+
+
+Installation
+------------
+
+Installing with `pip <http://www.pip-installer.org/>`_ should Just Work:
+
+.. code-block:: sh
+
+    pip install tinycss
+
+The release tarballs contain pre-*cythoned* C files for the accelerators:
+you will not need Cython to install like this.
+If the accelerators fail to build for some reason, tinycss will
+print a warning and fall back to a pure-Python installation.
+
+
+Documentation
+-------------
+
+.. Have this page in the sidebar, but do not show a link to itself here:
+
+.. toctree::
+    :hidden:
+
+    self
+
+.. toctree::
+    :maxdepth: 2
+
+    parsing
+    css3
+    extending
... 4663 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-tinycss.git



More information about the Python-modules-commits mailing list