Skip to content

Commit 21771da

Browse files
authored
Merge pull request #39 from tgoodlet/sphinxdocs
Sphinx docs
2 parents 5182582 + dfcbf3f commit 21771da

File tree

7 files changed

+721
-88
lines changed

7 files changed

+721
-88
lines changed

README.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ Plugin registration and hook calling for Python
1111
.. image:: https://img.shields.io/appveyor/ci/pytestbot/pluggy/master.svg
1212
:target: https://ci.appveyor.com/project/pytestbot/pluggy
1313

14-
This is the plugin manager as used by [pytest](http://pytest.org), [tox](https://tox.readthedocs.org), [devpi](http://doc.devpi.net) and probably other projects.
14+
This is the core plugin system used by the `pytest`_, `tox`_, and `devpi`_ projects.
15+
Please `read the docs`_ to learn more!
1516

16-
During the 0.x series this plugin does not have much documentation
17-
except extensive docstrings in the pluggy.py module.
17+
.. links
18+
.. _pytest:
19+
http://pytest.org
20+
.. _tox:
21+
https://tox.readthedocs.org
22+
.. _devpi:
23+
http://doc.devpi.net
24+
.. _read the docs:
25+
https://pluggy.readthedocs.io/en/latest/

docs/_static/img/plug.png

9.13 KB
Loading

docs/api_reference.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
2-
31
Api Reference
42
=============
53

64
.. automodule:: pluggy
75
:members:
86
:undoc-members:
97
:show-inheritance:
10-
11-

docs/conf.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,19 @@
3333
language = None
3434

3535
pygments_style = 'sphinx'
36+
html_logo = '_static/img/plug.png'
3637
html_theme = 'alabaster'
38+
html_theme_options = {
39+
# 'logo': 'img/plug.png',
40+
# 'logo_name': 'true',
41+
'description': 'The `pytest` plugin system',
42+
'github_user': 'pytest-dev',
43+
'github_repo': 'pluggy',
44+
'github_button': 'true',
45+
'github_banner': 'true',
46+
'page_width': '1080px',
47+
'fixed_sidebar': 'false',
48+
}
3749
html_static_path = ['_static']
3850

3951
# One entry per manual page. List of tuples

docs/examples/firstexample.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import pluggy
2+
3+
hookspec = pluggy.HookspecMarker("myproject")
4+
hookimpl = pluggy.HookimplMarker("myproject")
5+
6+
7+
class MySpec:
8+
"""A hook specification namespace.
9+
"""
10+
@hookspec
11+
def myhook(self, arg1, arg2):
12+
"""My special little hook that you can customize.
13+
"""
14+
15+
16+
class Plugin_1:
17+
"""A hook implementation namespace.
18+
"""
19+
@hookimpl
20+
def myhook(self, arg1, arg2):
21+
print("inside Plugin_1.myhook()")
22+
return arg1 + arg2
23+
24+
25+
class Plugin_2:
26+
"""A 2nd hook implementation namespace.
27+
"""
28+
@hookimpl
29+
def myhook(self, arg1, arg2):
30+
print("inside Plugin_2.myhook()")
31+
return arg1 - arg2
32+
33+
34+
# create a manager and add the spec
35+
pm = pluggy.PluginManager("myproject")
36+
pm.add_hookspecs(MySpec)
37+
38+
# register plugins
39+
pm.register(Plugin_1())
40+
pm.register(Plugin_2())
41+
42+
# call our `myhook` hook
43+
results = pm.hook.myhook(arg1=1, arg2=2)
44+
print(results)

0 commit comments

Comments
 (0)