Skip to content

Commit 3dbcb55

Browse files
authored
Extend the documentation. (#11)
1 parent a3c3c6d commit 3dbcb55

38 files changed

+937
-345
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ coverage.*
99
.vscode
1010
_build
1111
__pycache__
12+
_generated
1213

1314
*.egg-info
1415

.pre-commit-config.yaml

+4-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ repos:
3232
rev: 3.8.3
3333
hooks:
3434
- id: flake8
35-
types: [python]
3635
additional_dependencies: [
3736
flake8-alfred,
3837
flake8-bugbear,
@@ -55,12 +54,10 @@ repos:
5554
name: doc8
5655
description: This hook runs doc8 for linting docs
5756
entry: python -m doc8
58-
language: python
59-
files: \.rst$
60-
- repo: https://github.com/codespell-project/codespell
61-
rev: v1.17.1
62-
hooks:
63-
- id: codespell
57+
- repo: https://github.com/codespell-project/codespell
58+
rev: v1.17.1
59+
hooks:
60+
- id: codespell
6461
- repo: meta
6562
hooks:
6663
- id: check-hooks-apply

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ To execute the task, type the following command on the command-line
9999
Documentation
100100
-------------
101101

102-
The documentation can be found under https://pytask-dev.readthedocs.io/en/latest and
102+
The documentation can be found under https://pytask-dev.readthedocs.io/en/latest with
103103
tutorials and explanations.
104104

105105

docs/_static/css/custom.css

+1-20
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,6 @@ div.prompt {
33
display: none;
44
}
55

6-
/* General options */
7-
8-
h1, h2, h3, h4, h5, h6 {
9-
color: #547482 !important;
10-
}
11-
12-
a {
13-
color: #547482;
14-
}
15-
16-
a.headerlink {
17-
color: #C87259 !important;
18-
}
19-
20-
a.headerlink:hover {
21-
color: #fff !important;
22-
background-color: #C87259 !important;
23-
}
24-
256
/* Getting started index page */
267

278
.intro-card {
@@ -70,7 +51,7 @@ a#index-link {
7051

7152
.gs-torefguide a:hover {
7253
margin-left: 5px;
73-
color: grey;
54+
color: #333;
7455
text-decoration: none;
7556
border-bottom: 1px solid #b2ff80f3;
7657
box-shadow: 0px -10px 0px #b2ff80f3 inset;

docs/changes.rst

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ This is a record of all past pytask releases and what went into them in reverse
55
chronological order. Releases follow `semantic versioning <https://semver.org/>`_ and
66
all releases are available on `Anaconda.org <https://anaconda.org/pytask/pytask>`_.
77

8+
9+
0.0.5 - 2020-xx-xx
10+
------------------
11+
12+
- :gh:`10` turns parametrization into a plugin.
13+
- :gh:`11` extends the documentation.
14+
- :gh:`12` replaces ``pytest.mark`` with ``pytask.mark``.
15+
16+
817
0.0.4 - 2020-07-22
918
------------------
1019

docs/conf.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@
3131
extensions = [
3232
"IPython.sphinxext.ipython_console_highlighting",
3333
"IPython.sphinxext.ipython_directive",
34-
"numpydoc",
34+
"sphinx.ext.autodoc",
35+
"sphinx.ext.autosummary",
3536
"sphinx.ext.extlinks",
3637
"sphinx.ext.intersphinx",
38+
"sphinx.ext.napoleon",
39+
"sphinx.ext.viewcode",
3740
"sphinx_copybutton",
41+
"autoapi.extension",
42+
"sphinx_autodoc_typehints",
3843
]
3944

4045
# Add any paths that contain templates here, relative to this directory.
@@ -46,7 +51,6 @@
4651
# html_extra_path.
4752
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4853

49-
5054
# -- Extensions configuration ----------------------------------------------------------
5155

5256
# Configuration for autodoc
@@ -64,11 +68,14 @@
6468

6569
intersphinx_mapping = {
6670
"python": ("https://docs.python.org/3.8", None),
71+
"click": ("https://click.palletsprojects.com/en/7.x", None),
72+
"pluggy": ("https://pluggy.readthedocs.io/en/latest", None),
6773
}
6874

69-
# Configuration for numpydoc
70-
numpydoc_xref_param_type = True
71-
numpydoc_xref_ignore = {"type", "optional", "default", "of"}
75+
# Configuration for autoapi
76+
autoapi_type = "python"
77+
autoapi_dirs = ["../src/pytask"]
78+
autoapi_keep_files = False
7279

7380

7481
# -- Options for HTML output -----------------------------------------------------------

docs/explanations/design.rst

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Design
2+
======
3+
4+
The design of pytask has some key objectives.
5+
6+
1. The interface must be simple, easy-to-learn, and may have synergies with pytest. It
7+
is important that even users without a strong background in computer science are able
8+
to use pytask.
9+
10+
2. pytask must be easily extensible via plugins. Developers of pytask are naturally
11+
unaware of all the possible applications of a build system. Thus, they must focus on
12+
the host application and the design of the entry-points. This will also reduce the
13+
amount of maintenance.

docs/explanations/index.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Explanations
22
============
33

4-
.. note::
4+
Explanations provide background information and historical context on pytask and build
5+
systems in general as well as its design.
56

6-
Unfortunately, this section is still under development. If you want to contribute to
7-
the documentation, please file an issue to start a conversation or create a pull
8-
request.
7+
.. toctree::
8+
:maxdepth: 1
99

10-
Explanations offer background information on the software, discuss design decisions and
11-
alternative implementations.
10+
why_another_build_system
11+
design
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
Why another build system?
2+
=========================
3+
4+
There are a lot of build systems out there with existing communities who accumulated a
5+
lot of experience over time. So why go through the hassle of creating another build
6+
system?
7+
8+
One reason was pure curiosity. `Waf <https://waf.io>`_ has been used for some time as a
9+
build system for research projects. Although, it has several limitations (difficult
10+
interface, no debugging, cryptic error messages, a bus factor of one), it is also a
11+
mature library. At some point annoyance won over comfort and I (`@tobiasraabe
12+
<https://github.com/tobiasraabe>`_) started to write pytask.
13+
14+
Another reason is that pytask is created having a particular audience in mind. Many
15+
researchers are not computer scientists first, but acquired some programming skills
16+
throughout their careers. This means a build system must be extremely user-friendly or
17+
provide a `steep learning curve <https://english.stackexchange.com/a/6226>`_, because it
18+
is only a tool. Since pytask resembles pytest in some ways, users have an easier time
19+
switching to pytask and feel more comfortable.
20+
21+
The third reason is that pytest seems to provide the ideal architecture for a build
22+
system. Its plugin-based design allows for customization at every level. A build system
23+
is a tool which can be deployed in many different environments whose requirements are
24+
not foreseeable by the developer. If it is easy for users / developers to write plugins
25+
which extend the functionality of pytask it is more valuable. If there is any question
26+
whether pytest's architecture is really suited for this, one should look at the success
27+
of pytest, its wide-spread adoption, and its over 800 plugins (even if most of them
28+
might be dead).
29+
30+
31+
Alternatives
32+
------------
33+
34+
Here is a list of other build systems and their advantages and disadvantages compared to
35+
pytask. The list helps to define pytask's niche and to collect new ideas to improve
36+
pytask.
37+
38+
39+
`snakemake <https://github.com/snakemake/snakemake>`_
40+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41+
42+
Pros
43+
44+
- Mature library.
45+
- Is the build system for some research projects.
46+
- Can scale to clusters and use Docker images.
47+
- Supports Python and R.
48+
49+
Cons
50+
51+
- Need to learn snakemake's syntax which is a mixture of Make and Python.
52+
- Seems to have no plugin system.
53+
54+
55+
`Waf <https://waf.io>`_
56+
~~~~~~~~~~~~~~~~~~~~~~~
57+
58+
Pros
59+
60+
- Mature library.
61+
- Can be extended.
62+
63+
Cons
64+
65+
- Focus on compiling binaries.
66+
- Bus factor of 1.
67+
68+
69+
`Scons <https://github.com/SCons/scons>`_
70+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
71+
72+
Pros
73+
74+
- Mature library.
75+
76+
Cons
77+
78+
- Seems to have no plugin system.
79+
80+
81+
`cook <https://github.com/jachris/cook>`_
82+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83+
84+
Pros
85+
86+
- Still simple, maybe useful for some quick inspirations.
87+
88+
Cons
89+
90+
- Development is paused.
91+
- No plugin system, but extensible interfaces.

docs/glossary.rst

+24-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Glossary
33

44
.. glossary::
55

6-
Build system
6+
build system
77
A build system is a tool for developing software which manages the process from
88
compiling the source code to binary code, packaging the binary code and running
99
tests.
@@ -13,5 +13,27 @@ Glossary
1313

1414
DAG
1515
A `directed acyclic graph (DAG) <https://en.wikipedia.org/wiki/
16-
Directed_acyclic_graph>`_ is a graph with a finite amount of vertices and edges
16+
Directed_acyclic_graph>`_ is a graph with a finite amount of nodes and edges
1717
which are connected such that no circles exist.
18+
19+
host
20+
The program which offers extensibility via entry-points.
21+
22+
entry-point
23+
Access points for plugins in the host program. At an entry-point, the host sends
24+
a message which can be processed by plugins. Then, the plugins may respond.
25+
26+
plugin
27+
A plugin is a software which changes the behavior of the host program by
28+
processing the message send by the host at an entry-point. A plugin can consist
29+
of one or more :term:`hook implementations <hook implementation>`.
30+
31+
hooking
32+
See the reference guide on :ref:`pluggy` or the more general explanation on
33+
`Wikipedia <https://en.wikipedia.org/wiki/Hooking>`_.
34+
35+
hook specification
36+
Another term for :term:`entry-point` when talking about hooking and pluggy.
37+
38+
hook implementation
39+
A part of the plugin which intercepts the message at one specific entry-point.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
How to write a plugin
2+
=====================
3+
4+
Since pytask is built using pluggy, it is easily extensible. In this section, you will
5+
learn some key concepts you need to know to write a plugin. It won't deal with pluggy in
6+
detail, but if you are interested feel free to read :ref:`pluggy`. A quick look at the
7+
first paragraphs might be useful nonetheless.
8+
9+
10+
Preparation
11+
-----------
12+
13+
Before you start implementing your plugin, it makes sense to go through the following
14+
steps.
15+
16+
- Check whether there exist plugins which offer similar functionality. For example, many
17+
plugins provide convenient interfaces to run another program with inputs via the
18+
command line. Naturally, there is a lot of overlap in the structure of the program and
19+
even the the test battery. Finding the right template may save you a lot of time.
20+
21+
- Make a list of hooks you want to implement. Think about how this plugin relates to
22+
functionality defined in pytask and other plugins. Maybe skim the documentation on
23+
:ref:`pluggy` to see whether there is advanced pattern
24+
which makes your implementation easier.
25+
26+
- You may file an issue on `Github <https://github.com/pytask-dev/pytask>`_ and propose
27+
your plugin to get feedback from others. Your proposal should be concise, should
28+
explain which problem is solved and how.
29+
30+
31+
Writing your plugin
32+
-------------------
33+
34+
Set up the setuptools entry-point
35+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36+
37+
pytask discovers plugins via ``setuptools`` entry-points. This is specified in
38+
``setup.py``. See the following example.
39+
40+
.. code-block:: python
41+
42+
# Content of setup.py
43+
44+
from setuptools import find_packages
45+
from setuptools import setup
46+
47+
setup(
48+
name="pytask-plugin",
49+
version="0.0.1",
50+
entry_points={"pytask": ["pytask_plugin = pytask_plugin.plugin"]},
51+
# PyPI classifier for pytask plugins
52+
classifiers=["Framework :: pytask"],
53+
)
54+
55+
The entry-point for pytask is also called ``"pytask"`` and you point to a module called
56+
``pytask_plugin.plugin``.
57+
58+
59+
plugin.py
60+
~~~~~~~~~
61+
62+
``plugin.py`` is the main module in your package. You can put all of your hook
63+
implementations in this module, but it is recommended imitate the structure of pytask
64+
and its modules. For example, all hook implementations which change the configuration
65+
should be implemented in ``pytask_plugin.config``.
66+
67+
If you follow the recommendations, the only content in ``plugin.py`` is a single hook
68+
implementation which registers other hook implementations of your plugin. The following
69+
example registers all hooks implemented in ``config.py``.
70+
71+
.. code-block:: python
72+
73+
# Content of plugin.py
74+
75+
import pytask
76+
from pytask_plugin import cli
77+
78+
79+
@pytask.hookimpl
80+
def pytask_add_hooks(pm):
81+
pm.register(cli)

docs/how_to_guides/index.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
How-to Guides
22
=============
33

4-
.. note::
5-
6-
Unfortunately, this section is still under development. If you want to contribute to
7-
the documentation, please file an issue to start a conversation or create a pull
8-
request.
9-
104
How-to guides provide detailed explanations on how to accomplish specific tasks with
115
pytask.
6+
7+
8+
.. toctree::
9+
:maxdepth: 1
10+
11+
how_to_write_a_plugin

0 commit comments

Comments
 (0)