Skip to content

Commit 262df29

Browse files
0.4
1 parent 4c90c2b commit 262df29

15 files changed

+88
-21
lines changed

.github/workflows/run_tox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
max-parallel: 4
1010
matrix:
11-
python-version: [3.7, 3.8, 3.9]
11+
python-version: ['3.7', '3.8', '3.9', '3.10']
1212

1313
steps:
1414
- uses: actions/checkout@v1

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v3.4.0
3+
rev: v4.1.0
44
hooks:
55
- id: check-yaml
66
- id: end-of-file-fixer
77
- id: trailing-whitespace
88

99
- repo: https://github.com/pycqa/isort
10-
rev: 5.8.0
10+
rev: 5.10.1
1111
hooks:
1212
- id: isort
1313
name: isort (python)

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ formats: all
1818

1919
# Optionally set the version of Python and requirements required to build your docs
2020
python:
21-
version: 3.8
21+
version: 3.9
2222
install:
2323
- requirements: requirements.txt
2424
- method: setuptools

doc/configuration.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ To use this extension just add it to the ``extensions`` in your ``conf.py``
1010
1111
Additionally the following configuration parameters are available:
1212

13+
.. _config_options:
14+
1315
.. list-table::
1416
:widths: auto
1517
:header-rows: 1
@@ -20,13 +22,18 @@ Additionally the following configuration parameters are available:
2022

2123
* - ``exec_code_working_dir``
2224
- ``Path`` or ``str``
23-
- The working directory where the code will be executed
25+
- The working directory where the code will be executed.
2426

2527
* - ``exec_code_folders``
2628
- | ``List`` of
2729
| ``Path`` or ``str``
2830
- | Additional folders that will be added to PYTHONPATH.
29-
| Use this to e.g. make imports available
31+
| Use this to e.g. make imports available.
32+
33+
* - ``exec_code_example_dir``
34+
- ``Path`` or ``str``
35+
- | The directory that is used to create the path to the
36+
| example files. Defaults to the parent folder of the ``conf.py``.
3037
3138
If it's a relative path it will be resolved relative to the parent folder of the ``conf.py``
3239

@@ -36,6 +43,7 @@ Example:
3643
3744
exec_code_working_dir = '..'
3845
exec_code_folders = ['../my_src']
46+
exec_code_example_dir = '.'
3947
4048
If you are unsure what the values are you can run Sphinx build in verbose mode with ``-v -v``.
4149
The configured values are logged.
@@ -46,3 +54,4 @@ Log output for Example:
4654

4755
[exec-code] Working dir: C:\Python\sphinx-exec-code
4856
[exec-code] Folders: C:\Python\sphinx-exec-code\my_src
57+
[exec-code] Example dir: C:\Python\sphinx-exec-code\doc

doc/description.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,27 @@ Generated view
6060

6161
----
6262

63+
Code from files
64+
------------------------------
65+
It's possible to have code in example files with the ``filename`` option.
66+
The folder that is used to resolve to a file name can be :ref:`configured <config_options>`.
67+
68+
Example:
69+
70+
.. code-block:: python
71+
72+
.. exec_code::
73+
:filename: file_example.py
74+
75+
76+
Generated view
77+
78+
----
79+
80+
.. exec_code::
81+
:filename: file_example.py
82+
83+
----
6384

6485
Code Markers
6586
------------------------------

doc/file_example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print('This is code from an example file')

readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ This code will be executed
3636
```
3737

3838
# Changelog
39+
#### 0.4 (09.03.2022)
40+
- Added option to run code from example files
41+
3942
#### 0.3 (24.09.2021)
4043
- Added some more documentation and fixed some false path warnings
4144

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pytest==6.2.5
2-
pre-commit==2.15.0
3-
sphinx==4.2.0
1+
pytest==7.0.1
2+
pre-commit==2.17.0
3+
sphinx==4.4.0
44
sphinx-rtd-theme==1.0.0

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def load_version() -> str:
5555
"Programming Language :: Python :: 3.7",
5656
"Programming Language :: Python :: 3.8",
5757
"Programming Language :: Python :: 3.9",
58+
"Programming Language :: Python :: 3.10",
5859
"Programming Language :: Python :: 3 :: Only",
5960
],
6061
)

src/sphinx_exec_code/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.3'
1+
__version__ = '0.4'

0 commit comments

Comments
 (0)