summaryrefslogtreecommitdiff
path: root/docs/source/plugin-development
diff options
context:
space:
mode:
authorFabian Neundorf <CommodoreFabianus@gmx.de>2016-07-21 11:55:41 +0000
committerFabian Neundorf <CommodoreFabianus@gmx.de>2016-07-22 00:28:23 +0200
commit9cf8603e9494420ebd1a48bea33b31d4979525d7 (patch)
tree5dbcb788ecec3349d9a5579a699c238fc747e196 /docs/source/plugin-development
parentc3ee4829ed8d8286a167949ed6ca09a4db571318 (diff)
downloadflake8-9cf8603e9494420ebd1a48bea33b31d4979525d7.tar.gz
Add support for tokens of a complete file
The `tokens` property of the `FileProcessor` class only contains tokens of the current line but not all tokens. So if a plugin which is only executed once per file, that property is useless. To make the tokens also available to plugins it is now be able to supply all the tokens of a file. It also updates the documentation to separate which parameters are static and which are changed on each line. Using the latter parameters on plugins which are only run once per file isn't very sensible.
Diffstat (limited to 'docs/source/plugin-development')
-rw-r--r--docs/source/plugin-development/plugin-parameters.rst17
1 files changed, 13 insertions, 4 deletions
diff --git a/docs/source/plugin-development/plugin-parameters.rst b/docs/source/plugin-development/plugin-parameters.rst
index 3c4534a..e341572 100644
--- a/docs/source/plugin-development/plugin-parameters.rst
+++ b/docs/source/plugin-development/plugin-parameters.rst
@@ -34,18 +34,27 @@ a file, a plugin can ask for any of the following:
- :attr:`~flake8.processor.FileProcessor.indent_level`
- :attr:`~flake8.processor.FileProcessor.line_number`
- :attr:`~flake8.processor.FileProcessor.logical_line`
-- :attr:`~flake8.processor.FileProcessor.max_line_length`
- :attr:`~flake8.processor.FileProcessor.multiline`
- :attr:`~flake8.processor.FileProcessor.noqa`
- :attr:`~flake8.processor.FileProcessor.previous_indent_level`
- :attr:`~flake8.processor.FileProcessor.previous_logical`
- :attr:`~flake8.processor.FileProcessor.tokens`
+
+Some properties are set once per file for plugins which iterate itself over
+the data instead of being called on each physical or logical line.
+
+- :attr:`~flake8.processor.FileProcessor.filename`
+- :attr:`~flake8.processor.FileProcessor.file_tokens`
+- :attr:`~flake8.processor.FileProcessor.lines`
+- :attr:`~flake8.processor.FileProcessor.max_line_length`
- :attr:`~flake8.processor.FileProcessor.total_lines`
- :attr:`~flake8.processor.FileProcessor.verbose`
-Alternatively, a plugin can accept ``tree`` and ``filename``.
-``tree`` will be a parsed abstract syntax tree that will be used by plugins
-like PyFlakes and McCabe.
+These parameters can also be supplied to plugins working on each line
+separately. Additionally, plugins called once per file can also accept ``tree``
+which is not supplied as a parameter of
+:class:`~flake8.processor.FileProcessor`, which will be a parsed abstract
+syntax tree. It is used by plugins like PyFlakes and McCabe.
Registering Options