Skip to content

Commit 76e8aba

Browse files
authored
Merge pull request #55 from pytest-dev/readme_update
README improvements
2 parents 9b2bc8c + 0278dee commit 76e8aba

File tree

2 files changed

+66
-14
lines changed

2 files changed

+66
-14
lines changed

README.rst

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,72 @@
1+
pluggy - A minimalist production ready plugin system
2+
====================================================
3+
|pypi| |versions| |travis| |appveyor|
14

2-
Plugin registration and hook calling for Python
3-
===============================================
45

5-
.. image:: https://img.shields.io/pypi/v/pluggy.svg
6+
This is the core framework used by the `pytest`_, `tox`_, and `devpi`_ projects.
7+
8+
Please `read the docs`_ to learn more!
9+
10+
A definitive example
11+
********************
12+
.. code-block:: python
13+
14+
import pluggy
15+
16+
hookspec = pluggy.HookspecMarker("myproject")
17+
hookimpl = pluggy.HookimplMarker("myproject")
18+
19+
20+
class MySpec(object):
21+
"""A hook specification namespace.
22+
"""
23+
@hookspec
24+
def myhook(self, arg1, arg2):
25+
"""My special little hook that you can customize.
26+
"""
27+
28+
29+
class Plugin_1(object):
30+
"""A hook implementation namespace.
31+
"""
32+
@hookimpl
33+
def myhook(self, arg1, arg2):
34+
print("inside Plugin_1.myhook()")
35+
return arg1 + arg2
36+
37+
38+
class Plugin_2(object):
39+
"""A 2nd hook implementation namespace.
40+
"""
41+
@hookimpl
42+
def myhook(self, arg1, arg2):
43+
print("inside Plugin_2.myhook()")
44+
return arg1 - arg2
45+
46+
47+
# create a manager and add the spec
48+
pm = pluggy.PluginManager("myproject")
49+
pm.add_hookspecs(MySpec)
50+
51+
# register plugins
52+
pm.register(Plugin_1())
53+
pm.register(Plugin_2())
54+
55+
# call our `myhook` hook
56+
results = pm.hook.myhook(arg1=1, arg2=2)
57+
print(results)
58+
59+
60+
.. badges
61+
.. |pypi| image:: https://img.shields.io/pypi/v/pluggy.svg
662
:target: https://pypi.python.org/pypi/pluggy
7-
.. image:: https://img.shields.io/pypi/pyversions/pluggy.svg
63+
.. |versions| image:: https://img.shields.io/pypi/pyversions/pluggy.svg
864
:target: https://pypi.python.org/pypi/pluggy
9-
.. image:: https://img.shields.io/travis/pytest-dev/pluggy/master.svg
65+
.. |travis| image:: https://img.shields.io/travis/pytest-dev/pluggy/master.svg
1066
:target: https://travis-ci.org/pytest-dev/pluggy
11-
.. image:: https://img.shields.io/appveyor/ci/pytestbot/pluggy/master.svg
67+
.. |appveyor| image:: https://img.shields.io/appveyor/ci/pytestbot/pluggy/master.svg
1268
:target: https://ci.appveyor.com/project/pytestbot/pluggy
1369

14-
This is the core plugin system used by the `pytest`_, `tox`_, and `devpi`_ projects.
15-
Please `read the docs`_ to learn more!
16-
1770
.. links
1871
.. _pytest:
1972
http://pytest.org

tox.ini

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,17 @@ deps=
1818
deps =
1919
flake8
2020
restructuredtext_lint
21+
pygments
2122
commands =
2223
flake8 pluggy.py setup.py testing
2324
rst-lint CHANGELOG.rst README.rst
2425

2526
[testenv:docs]
2627
deps =
27-
sphinx
28-
pygments
28+
sphinx
29+
pygments
2930
commands =
30-
sphinx-build \
31-
-b html \
32-
{toxinidir}/docs {toxinidir}/build/html-docs
31+
sphinx-build -b html {toxinidir}/docs {toxinidir}/build/html-docs
3332

3433
[pytest]
3534
minversion=2.0

0 commit comments

Comments
 (0)