summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-08-02 20:36:03 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-08-02 20:36:03 -0400
commit4ae0a5843cbbf93e73b7a3df01090f8bff233e7a (patch)
tree4ab279d0d3f71d5aba4bb756d09f32aebd5a2248
parent736af3f5c1da02b58f5ccbbd00a2ee5c6317bc9e (diff)
downloadpython-coveragepy-git-4ae0a5843cbbf93e73b7a3df01090f8bff233e7a.tar.gz
More plugin docscoverage-4.0b1
-rw-r--r--coverage/__init__.py2
-rw-r--r--coverage/plugin.py22
-rw-r--r--doc/plugins.rst2
3 files changed, 18 insertions, 8 deletions
diff --git a/coverage/__init__.py b/coverage/__init__.py
index f9e8a04b..88b6c2f3 100644
--- a/coverage/__init__.py
+++ b/coverage/__init__.py
@@ -13,7 +13,7 @@ from coverage.version import __version__, __url__
from coverage.control import Coverage, process_startup
from coverage.data import CoverageData
from coverage.misc import CoverageException
-from coverage.plugin import CoveragePlugin
+from coverage.plugin import CoveragePlugin, FileTracer, FileReporter
# Backward compatibility.
coverage = Coverage
diff --git a/coverage/plugin.py b/coverage/plugin.py
index 5b0479c3..f4182b0f 100644
--- a/coverage/plugin.py
+++ b/coverage/plugin.py
@@ -10,15 +10,12 @@ from coverage import files
from coverage.misc import _needs_to_implement
-# TODO: document that the plugin objects may be decorated with attributes with
-# named "_coverage_*".
-
class CoveragePlugin(object):
"""Base class for coverage.py plugins.
- To write a coverage.py plugin, create a subclass of `CoveragePlugin`.
- You can override methods here to participate in various aspects of
- coverage.py's processing.
+ To write a coverage.py plugin, create a module with a subclass of
+ :class:`CoveragePlugin`. You can override methods in your class to
+ participate in various aspects of coverage.py's processing.
Currently the only plugin type is a file tracer, for implementing
measurement support for non-Python files. File tracer plugins implement
@@ -28,6 +25,19 @@ class CoveragePlugin(object):
Any plugin can optionally implement :meth:`sys_info` to provide debugging
information about their operation.
+ Coverage.py will store its own information on your plugin, with attributes
+ starting with "_coverage_". Don't be startled.
+
+ To register your plugin, define a function called `coverage_init` in your
+ module::
+
+ def coverage_init(reg, options):
+ reg.add_file_tracer(MyPlugin())
+
+ The `reg.add_file_tracer` method takes an instance of your plugin. If your
+ plugin takes options, the `options` argument is a dictionary of your
+ plugin's options from the .coveragerc file.
+
"""
def file_tracer(self, filename): # pylint: disable=unused-argument
diff --git a/doc/plugins.rst b/doc/plugins.rst
index b8cb1f1b..c0466b26 100644
--- a/doc/plugins.rst
+++ b/doc/plugins.rst
@@ -53,7 +53,7 @@ coverage.py plugin called ``something.plugin``.
Plugin API
----------
-.. module:: coverage.plugin
+.. module:: coverage
.. autoclass:: CoveragePlugin
:members: