Permalink
Browse files

Add docs for extending the parser.

  • Loading branch information...
1 parent 9c41740 commit 55b26cd22f78b0d792962212a18465e4f8692d0c @SimonSapin SimonSapin committed Mar 31, 2012
Showing with 154 additions and 79 deletions.
  1. +6 −0 docs/css3.rst
  2. +47 −2 docs/extending.rst
  3. +1 −0 docs/parsing.rst
  4. +88 −72 tinycss/css21.py
  5. +9 −5 tinycss/parsing.py
  6. +3 −0 tinycss/selectors3.py
View
@@ -52,3 +52,9 @@ Paged Media 3
.. autoclass:: CSSPage3Parser
.. autoclass:: MarginRule
+
+
+Other CSS modules
+-----------------
+
+To add support for new CSS syntax, see :ref:`extending`.
View
@@ -1,5 +1,50 @@
+.. _extending:
+
Extending the parser
====================
-**TODO:**
-Describe how to write a :class:`CoreParser` subclass to extend the parser.
+Various modules such as :mod:`.selectors3` and :mod:`.page3` extend the
+CSS 2.1 parser to add support for some 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.
+
+
+.. currentmodule:: tinycss.css21
+
+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
View
@@ -37,6 +37,7 @@ is also a convenience function to do that:
.. module:: tinycss.css21
+.. _parsing:
Parsing a stylesheet
~~~~~~~~~~~~~~~~~~~~
Oops, something went wrong.

0 comments on commit 55b26cd

Please sign in to comment.