diff options
author | gbrandl <devnull@localhost> | 2007-01-11 23:52:35 +0100 |
---|---|---|
committer | gbrandl <devnull@localhost> | 2007-01-11 23:52:35 +0100 |
commit | 25ae5e77486b0484e26ef3be04f8f92c712cb31c (patch) | |
tree | b2e2296b659c95fe3bfb6daae6563b0f6332a566 | |
parent | 836c5db8bb5161cc6c9e358b7324c5f1043bea1b (diff) | |
download | pygments-25ae5e77486b0484e26ef3be04f8f92c712cb31c.tar.gz |
[svn] Some doc nits.
-rw-r--r-- | docs/src/filterdevelopment.txt | 23 | ||||
-rw-r--r-- | docs/src/filters.txt | 41 |
2 files changed, 33 insertions, 31 deletions
diff --git a/docs/src/filterdevelopment.txt b/docs/src/filterdevelopment.txt index 9c902d12..27003ce8 100644 --- a/docs/src/filterdevelopment.txt +++ b/docs/src/filterdevelopment.txt @@ -4,7 +4,7 @@ Write your own filter ===================== -*New in Pygments 0.7* +*New in Pygments 0.7.* Writing own filters is very easy. All you have to do is to subclass the `Filter` class and override the `filter` method. Additionally a @@ -37,19 +37,18 @@ to normal `Name` tokens to make the output less colorful. ttype = Name yield ttype, value -Some words on the `lexer` argument. That can be quite confusing since it -must not be a lexer instance. If a filter was added by using the `add_filter` -function of lexers that lexer is registered for the filter. In that case -`lexer` will be point to the lexer that has registered the filter. It can -be used (but must not) to access options passed to a lexer. Because it -could be `None` you always have to check for that case if you access it. +Some notes on the `lexer` argument: that can be quite confusing since it doesn't +need to be a lexer instance. If a filter was added by using the `add_filter()` +function of lexers, that lexer is registered for the filter. In that case +`lexer` will refer to the lexer that has registered the filter. It *can* be used +to access options passed to a lexer. Because it could be `None` you always have +to check for that case if you access it. -Using a Decorator +Using a decorator ================= -You can also use the `simplefilter` decorator from the `pygments.filter` -module: +You can also use the `simplefilter` decorator from the `pygments.filter` module: .. sourcecode:: python @@ -67,5 +66,5 @@ module: ttype = Name yield ttype, value -The decorator automatically subclasses an internal filter class and uses -the decorated function for filtering. +The decorator automatically subclasses an internal filter class and uses the +decorated function for filtering. diff --git a/docs/src/filters.txt b/docs/src/filters.txt index 55b74faf..570be584 100644 --- a/docs/src/filters.txt +++ b/docs/src/filters.txt @@ -4,11 +4,13 @@ Filters ======= -Since Pygments 0.7 you can filter token streams to improve the output. For -example you can highlight special words in comments, convert keywords -to upper or lowercase to enforce an styleguide etc. +*New in Pygments 0.7.* -To apply an filter you can use the `add_filter` method of a lexer: +You can filter token streams coming from lexers to improve or annotate the +output. For example, you can highlight special words in comments, convert +keywords to upper or lowercase to enforce a style guide etc. + +To apply a filter, you can use the `add_filter()` method of a lexer: .. sourcecode:: pycon @@ -22,14 +24,14 @@ To apply an filter you can use the `add_filter` method of a lexer: >>> # or class >>> l.add_filter(KeywordRewriteFilter(keywordcase='lower')) -The `add_filter` method also takes keyword arguments which are forwarded -to the constructor of the filter. +The `add_filter()` method also takes keyword arguments which are forwarded to +the constructor of the filter. -To get a list of all registered filters by name you can use the -`get_all_filters` function from the `pygments.filters` module that returns -an iterable for all known filters. +To get a list of all registered filters by name, you can use the +`get_all_filters()` function from the `pygments.filters` module that returns an +iterable for all known filters. -If you want to write your own lexer have a look at `Write your own filter`_. +If you want to write your own filter, have a look at `Write your own filter`_. .. _Write your own filter: filterdevelopment.txt @@ -39,19 +41,20 @@ Builtin Filters `CodeTagFilter` - Highlights special code tags in comments and docstrings. Per - default the list of highlighted tags is ``XXX``, ``TODO``, - ``BUG`` and ``NOTE``. You can override this list by specifying - a ``codetags`` parameter that takes a list of words. + Highlights special code tags in comments and docstrings. Per default, the + list of highlighted tags is ``XXX``, ``TODO``, ``BUG`` and ``NOTE``. You can + override this list by specifying a `codetags` parameter that takes a list of + words. :Name: ``codetagify`` + `KeywordCaseFilter` - Converts keywords to ``lower``, ``upper`` or ``capitalize`` which - means first letter uppercase, rest lowercase. This can be useful - if you highlight pascal code and want to adapt the code to your - styleguide. The default is ``lower``, override that by providing - the `keywordcase` parameter. + Converts keywords to ``lower``, ``upper`` or ``capitalize`` which means + first letter uppercase, rest lowercase. This can be useful e.g. if you + highlight Pascal code and want to adapt the code to your styleguide. The + default is ``lower``, override that by providing the `keywordcase` + parameter. :Name: ``keywordcase`` |