Skip to content

Commit 514f5f8

Browse files
authored
Allow to specify paths in the configuration file, document the cli and configuration values. (#23)
1 parent 5725566 commit 514f5f8

34 files changed

+509
-166
lines changed

.github/workflows/continuous-integration-workflow.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

3636
- name: Run unit tests and doctests.
3737
shell: bash -l {0}
38-
run: tox -e pytest -- -m "unit or (not integration and not end_to_end)" --cov=./src --cov-report=xml -n auto
38+
run: tox -e pytest -- src tests -m "unit or (not integration and not end_to_end)" --cov=./src --cov-report=xml -n auto
3939

4040
- name: Upload coverage report for unit tests and doctests.
4141
if: runner.os == 'Linux' && matrix.python-version == '3.8'
@@ -44,7 +44,7 @@ jobs:
4444

4545
- name: Run integration tests.
4646
shell: bash -l {0}
47-
run: tox -e pytest -- -m integration --cov=./src --cov-report=xml -n auto
47+
run: tox -e pytest -- src tests -m integration --cov=./src --cov-report=xml -n auto
4848

4949
- name: Upload coverage reports of integration tests.
5050
if: runner.os == 'Linux' && matrix.python-version == '3.8'
@@ -53,7 +53,7 @@ jobs:
5353

5454
- name: Run end-to-end tests.
5555
shell: bash -l {0}
56-
run: tox -e pytest -- -m end_to_end --cov=./src --cov-report=xml -n auto
56+
run: tox -e pytest -- src tests -m end_to_end --cov=./src --cov-report=xml -n auto
5757

5858
- name: Upload coverage reports of end-to-end tests.
5959
if: runner.os == 'Linux' && matrix.python-version == '3.8'

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Installation
5858
pytask is available on `Anaconda.org <https://anaconda.org/pytask/pytask>`_. Install the
5959
package with
6060

61-
.. code-block:: bash
61+
.. code-block:: console
6262
6363
$ conda config --add channels conda-forge --add channels pytask
6464
$ conda install pytask
@@ -93,7 +93,7 @@ Here are some details:
9393

9494
To execute the task, type the following command on the command-line
9595

96-
.. code-block::
96+
.. code-block:: console
9797
9898
$ pytask
9999
========================= Start pytask session =========================

docs/api.rst

Lines changed: 0 additions & 12 deletions
This file was deleted.

docs/changes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ all releases are available on `Anaconda.org <https://anaconda.org/pytask/pytask>
1717
- :gh:`18` changes the documentation theme to alabaster.
1818
- :gh:`19` adds some changes related to ignored folders.
1919
- :gh:`20` fixes copying code examples in the documentation.
20+
- :gh:`23` allows to specify paths via the configuration file, documents the cli and
21+
configuration options.
2022

2123

2224
0.0.5 - 2020-08-12

docs/conf.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import os
99
import sys
1010

11+
import sphinx
12+
1113

1214
sys.path.insert(0, os.path.abspath("../src"))
1315

@@ -38,8 +40,9 @@
3840
"sphinx.ext.napoleon",
3941
"sphinx.ext.viewcode",
4042
"sphinx_copybutton",
41-
"autoapi.extension",
4243
"sphinx_autodoc_typehints",
44+
"sphinx_click",
45+
"autoapi.extension",
4346
]
4447

4548
# List of patterns, relative to source directory, that match files and directories to
@@ -54,7 +57,15 @@
5457
# Configuration for autodoc.
5558
autosummary_generate = True
5659
add_module_names = False
57-
autodoc_mock_imports = ["attr", "click", "networkx", "pluggy", "pony"]
60+
# Actually irrelevant since sphinx-click needs to import everything to build the cli.
61+
autodoc_mock_imports = [
62+
"attr",
63+
"click",
64+
"click_default_group",
65+
"networkx",
66+
"pluggy",
67+
"pony",
68+
]
5869

5970
# Remove prefixed $ for bash, >>> for Python prompts, and In [1]: for IPython prompts.
6071
copybutton_prompt_text = r"\$ |>>> |In \[\d\]: "
@@ -106,3 +117,12 @@
106117
"font_family": '"Avenir Next", Calibri, "PT Sans", sans-serif',
107118
"head_font_family": '"Avenir Next", Calibri, "PT Sans", sans-serif',
108119
}
120+
121+
122+
def setup(app: "sphinx.application.Sphinx") -> None:
123+
app.add_object_type(
124+
"confval",
125+
"confval",
126+
objname="configuration value",
127+
indextemplate="pair: %s; configuration value",
128+
)

docs/explanations/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ systems in general as well as its design.
1010
why_do_i_need_a_build_system
1111
why_another_build_system
1212
design
13+
pluggy
File renamed without changes.

docs/index.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ pytask
2525
This is the documentation of pytask. You can install the package from `Anaconda.org
2626
<https://anaconda.org/pytask/pytask>`_ with
2727

28-
.. code-block:: bash
28+
.. code-block:: console
2929
3030
$ conda config --add channels conda-forge --add channels pytask
3131
$ conda install pytask
3232
33-
The documentation has four parts.
33+
The documentation has four central parts.
3434

3535
.. raw:: html
3636

@@ -103,9 +103,10 @@ The documentation has four parts.
103103
reference_guides/index
104104

105105

106+
Here are some additional resources.
107+
106108
.. toctree::
107109
:maxdepth: 1
108110

109111
glossary
110112
changes
111-
api
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The command line interface
2+
==========================
3+
4+
This section documents the command line interface of pytask.
5+
6+
.. click:: _pytask.cli:cli
7+
:show-nested:
8+
:prog: pytask
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
The configuration
2+
=================
3+
4+
This document lists all options to configure pytask via the configuration files.
5+
6+
7+
The basics
8+
----------
9+
10+
To learn about the basics visit the :doc:`tutorial
11+
<../tutorials/how_to_configure_pytask>`.
12+
13+
14+
Truthy and falsy values
15+
-----------------------
16+
17+
For some of the configuration values you need truthy or falsy values. pytask recognizes
18+
the following values.
19+
20+
- truthy: ``True``, ``true``, ``1``.
21+
- falsy: ``False``, ``false``, ``0``.
22+
23+
Additionally, the following values are interpreted as None which is neither truthy or
24+
falsy.
25+
26+
- ``None``
27+
- ``none``
28+
29+
30+
The options
31+
-----------
32+
33+
.. confval:: ignore
34+
35+
pytask can ignore files and directories and exclude some tasks or reduce the
36+
duration of the collection.
37+
38+
To ignore some file/folder via the command line, use the ``--ignore`` flag multiple
39+
times.
40+
41+
.. code-block:: console
42+
43+
$ pytask --ignore some_file.py --ignore some_directory/*
44+
45+
Or, use the configuration file:
46+
47+
.. code-block:: ini
48+
49+
# For single entries only.
50+
ignore = some_file.py
51+
52+
# Or single and multiple entries.
53+
ignore =
54+
some_directory/*
55+
some_file.py
56+
57+
58+
.. confval:: markers
59+
60+
pytask uses markers to attach additional information to task functions. To see which
61+
markers are available, type
62+
63+
.. code-block:: console
64+
65+
$ pytask markers
66+
67+
on the command-line interface.
68+
69+
If you use a marker which has not been configured, you will get a warning. To
70+
silence the warning and document the marker, provide the following information in
71+
your pytask configuration file.
72+
73+
.. code-block:: ini
74+
75+
markers =
76+
wip: Work-in-progress. These are tasks which I am currently working on.
77+
78+
79+
.. confval:: paths
80+
81+
If you want to collect tasks from specific paths without passing the names via the
82+
command line, you can add the paths to the configuration file. Paths passed via the
83+
command line will overwrite the configuration value.
84+
85+
.. code-block:: ini
86+
87+
# For single entries only.
88+
paths = src
89+
90+
# Or single and multiple entries.
91+
paths =
92+
folder_1
93+
folder_2/task_2.py
94+
95+
96+
.. confval:: pdb
97+
98+
If you want to enter the interactive debugger whenever an error occurs, pass the
99+
flag to the command line interface
100+
101+
.. code-block:: console
102+
103+
pytask --pdb
104+
105+
or use a truthy configuration value.
106+
107+
.. code-block:: ini
108+
109+
pdb = True
110+
111+
112+
.. confval:: strict_markers
113+
114+
If you want to raise an error for unregistered markers, pass
115+
116+
.. code-block:: console
117+
118+
pytask --strict-markers
119+
120+
or set the option to a truthy value.
121+
122+
.. code-block:: ini
123+
124+
strict_markers = True
125+
126+
127+
.. confval:: trace
128+
129+
If you want to enter the interactive debugger in the beginning of each task, use
130+
131+
.. code-block:: console
132+
133+
pytask --trace
134+
135+
or set this option to a truthy value.
136+
137+
.. code-block:: ini
138+
139+
trace = True

docs/reference_guides/index.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ additional details on the inner workings of pytask.
77
.. toctree::
88
:maxdepth: 1
99

10-
pluggy
10+
command_line_interface
11+
configuration
1112
hookspecs
1213
marks
14+
15+
16+
The following documents are auto-generated and not carefully edited. They provide direct
17+
access to the source code and the docstrings.
18+
19+
.. toctree::
20+
:titlesonly:
21+
22+
/autoapi/pytask/index
23+
/autoapi/_pytask/index

docs/rtd_environment.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,13 @@ dependencies:
77
- sphinx-copybutton
88
- sphinx-autodoc-typehints
99
- sphinx-autoapi
10+
- sphinx-click
11+
12+
# Package dependencies necessary for sphinx-click
13+
- attrs
14+
- click
15+
- click-default-group
16+
- networkx
17+
- pexpect
18+
- pluggy
19+
- pony >= 0.7.13

docs/tutorials/how_to_clean.rst

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ task was renamed and the old version still exists.
77
To clean directories from files which are not recognized by pytask, enter the directory
88
and type
99

10-
.. code-block::
10+
.. code-block:: console
1111
1212
$ pytask clean
1313
=============================== Start pytask session ===============================
@@ -34,7 +34,7 @@ If you want to remove the files, there exist two other modes for :option:`pytask
3434
If you want to delete whole folders instead of only the files in them, use
3535
:option:`pytask clean -d`.
3636

37-
.. code-block::
37+
.. code-block:: console
3838
3939
$ pytask clean -d
4040
=============================== Start pytask session ===============================
@@ -51,26 +51,6 @@ If you want to delete whole folders instead of only the files in them, use
5151
Command line options
5252
--------------------
5353

54-
.. program:: pytask clean
55-
56-
To clean your project, pytask offers a clean command similar to ``git clean``.
57-
58-
.. option:: pytask clean [OPTIONS] [PATHS]...
59-
60-
The command line interface has the following options.
61-
62-
.. option:: -m, --mode [dry-run|interactive|force]
63-
64-
The mode for the clean command.
65-
66-
- ``dry-run`` shows which files and directories would be removed.
67-
- ``force`` removes all files and directories without further confirmation.
68-
- ``interactive`` allows the user to choose for every file and directory.
69-
70-
.. option:: -d, --directories
71-
72-
Allows to remove whole directories if all its content can be removed as well.
73-
74-
.. option:: -q, --quiet
75-
76-
Do not show which files are removed.
54+
.. click:: _pytask.cli:cli
55+
:commands: clean
56+
:prog: pytask

0 commit comments

Comments
 (0)