summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2015-01-21 07:25:35 +0100
committerGeorg Brandl <georg@python.org>2015-01-21 07:25:35 +0100
commit181e8bff0a08fe2e31607991ef2c5b5b5d060f1b (patch)
treea19277cdc2535a1c71ed42311df14b8e9908aea3
parentc8222290adb37bd561d8230d5d45227958c056da (diff)
downloadpygments-181e8bff0a08fe2e31607991ef2c5b5b5d060f1b.tar.gz
Closes #1075: fix docs for @simplefilter.
The function needs a "self" argument since it is used as a method in the automatically created class. No use fixing that in the code, as it kills backwards compatibility.
-rw-r--r--.hgignore1
-rw-r--r--doc/docs/filterdevelopment.rst5
-rw-r--r--pygments/filter.py2
3 files changed, 5 insertions, 3 deletions
diff --git a/.hgignore b/.hgignore
index 509abffa..6fd21b49 100644
--- a/.hgignore
+++ b/.hgignore
@@ -10,5 +10,6 @@ Pygments.egg-info/*
tests/examplefiles/output
.idea/
.tags
+TAGS
tests/.coverage
tests/cover
diff --git a/doc/docs/filterdevelopment.rst b/doc/docs/filterdevelopment.rst
index 5f9ca8c7..fbcd0a09 100644
--- a/doc/docs/filterdevelopment.rst
+++ b/doc/docs/filterdevelopment.rst
@@ -58,7 +58,7 @@ You can also use the `simplefilter` decorator from the `pygments.filter` module:
@simplefilter
- def uncolor(lexer, stream, options):
+ def uncolor(self, lexer, stream, options):
class_too = get_bool_opt(options, 'classtoo')
for ttype, value in stream:
if ttype is Name.Function or (class_too and
@@ -67,4 +67,5 @@ You can also use the `simplefilter` decorator from the `pygments.filter` module:
yield ttype, value
The decorator automatically subclasses an internal filter class and uses the
-decorated function for filtering.
+decorated function as a method for filtering. (That's why there is a `self`
+argument that you probably won't end up using in the method.)
diff --git a/pygments/filter.py b/pygments/filter.py
index 092ef331..12eb6f03 100644
--- a/pygments/filter.py
+++ b/pygments/filter.py
@@ -29,7 +29,7 @@ def simplefilter(f):
Decorator that converts a function into a filter::
@simplefilter
- def lowercase(lexer, stream, options):
+ def lowercase(self, lexer, stream, options):
for ttype, value in stream:
yield ttype, value.lower()
"""