sphinx-examples-as-code 0.7.0__tar.gz → 0.8.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/PKG-INFO +58 -3
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/README.md +56 -2
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/pyproject.toml +1 -1
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/sphinx_examples_as_code/__init__.py +318 -18
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/sphinx_examples_as_code/_version.py +3 -3
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/sphinx_examples_as_code.egg-info/PKG-INFO +58 -3
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/sphinx_examples_as_code.egg-info/requires.txt +1 -0
- sphinx_examples_as_code-0.8.1/sphinx_examples_as_code.egg-info/scm_version.json +8 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/test_gallery_downloads.py +1 -1
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/test_single_function_page.py +1 -1
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/test_sphinx_examples_as_code.py +448 -2
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/test_tinypages.py +3 -3
- sphinx_examples_as_code-0.7.0/sphinx_examples_as_code.egg-info/scm_version.json +0 -8
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/.github/dependabot.yml +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/.github/release.yml +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/.github/workflows/ci.yml +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/.gitignore +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/.pre-commit-config.yaml +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/LICENSE +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/setup.cfg +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/sphinx_examples_as_code.egg-info/SOURCES.txt +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/sphinx_examples_as_code.egg-info/dependency_links.txt +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/sphinx_examples_as_code.egg-info/scm_file_list.json +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/sphinx_examples_as_code.egg-info/top_level.txt +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/gallery_fixture/conf.py +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/gallery_fixture/examples/GALLERY_HEADER.rst +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/gallery_fixture/examples/plot_minimal.py +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/gallery_fixture/index.rst +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/heading_level_fixture/conf.py +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/heading_level_fixture/examples/GALLERY_HEADER.rst +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/heading_level_fixture/examples/plot_reused_level.py +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/heading_level_fixture/examples/plot_three_levels.py +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/heading_level_fixture/index.rst +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/single_function_fixture/conf.py +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/single_function_fixture/index.rst +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/single_function_fixture/mymodule.py +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/test_heading_level_reuse.py +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/tinypages/conf.py +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/tinypages/docstring_cases.py +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/tinypages/docstring_cases.rst +0 -0
- {sphinx_examples_as_code-0.7.0 → sphinx_examples_as_code-0.8.1}/tests/tinypages/index.rst +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sphinx-examples-as-code
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.1
|
|
4
4
|
Summary: Sphinx extension for converting docstring examples into downloadable code.
|
|
5
5
|
Author-email: The PyVista Developers <info@pyvista.org>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -22,6 +22,7 @@ Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
|
22
22
|
Requires-Python: >=3.10
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
License-File: LICENSE
|
|
25
|
+
Requires-Dist: packaging>=22
|
|
25
26
|
Requires-Dist: pyvista>=0.48
|
|
26
27
|
Provides-Extra: gallery
|
|
27
28
|
Requires-Dist: sphinx-gallery<0.23,>=0.22; extra == "gallery"
|
|
@@ -85,6 +86,9 @@ sphinx_examples_as_code_conf = {
|
|
|
85
86
|
'jupyter': 'Download Jupyter notebook',
|
|
86
87
|
'marimo': 'Download marimo notebook',
|
|
87
88
|
},
|
|
89
|
+
'script_metadata': False,
|
|
90
|
+
'dependencies': {},
|
|
91
|
+
'requires_python': None,
|
|
88
92
|
}
|
|
89
93
|
```
|
|
90
94
|
|
|
@@ -92,7 +96,7 @@ sphinx_examples_as_code_conf = {
|
|
|
92
96
|
(default) or `'bottom'`.
|
|
93
97
|
- `formats`: which downloads to generate. A list containing any of `'python'` (a plain
|
|
94
98
|
Python script, `<name>.py`), `'jupyter'` (a Jupyter notebook, `<name>.ipynb`) and
|
|
95
|
-
`'marimo'` (a marimo notebook, `<name
|
|
99
|
+
`'marimo'` (a marimo notebook, `<name>_marimo.py`); defaults to all three. Always
|
|
96
100
|
offered in that order regardless of how the list is written. Without marimo 0.14 or
|
|
97
101
|
newer installed, the default skips the marimo download, and a `formats` that names
|
|
98
102
|
`'marimo'` (in `conf.py` or through `-D`) stops the build with a configuration error. An unknown format raises a configuration error too;
|
|
@@ -111,6 +115,17 @@ sphinx_examples_as_code_conf = {
|
|
|
111
115
|
Markdown link in notebooks, and renders inline as `text url` in Python scripts. Plain
|
|
112
116
|
text with no markup at all becomes one comment line per line of text, and
|
|
113
117
|
blank-line-separated paragraphs stay separated.
|
|
118
|
+
- `script_metadata`: `True` adds each download's dependencies and a one-line run
|
|
119
|
+
command. See [Dependencies and run commands](#dependencies-and-run-commands) below.
|
|
120
|
+
`False` (default) adds neither.
|
|
121
|
+
- `dependencies`: extra PEP 508 requirements per format, added to the detected ones, e.g.
|
|
122
|
+
`{'jupyter': ['pyvista[jupyter]']}`. An entry naming a detected project replaces it,
|
|
123
|
+
so `{'python': ['pyvista>=0.46']}` sets its version. An entry without a version keeps
|
|
124
|
+
the automatic pin described below. Only used with `script_metadata` on.
|
|
125
|
+
- `requires_python`: a `requires-python` specifier for the dependency block, e.g.
|
|
126
|
+
`'>=3.10'`. `None` (default) derives one from the dependencies instead; see
|
|
127
|
+
[Dependencies and run commands](#dependencies-and-run-commands). Only used with
|
|
128
|
+
`script_metadata` on.
|
|
114
129
|
|
|
115
130
|
An unrecognized key raises a configuration error at build start.
|
|
116
131
|
|
|
@@ -122,6 +137,46 @@ Overriding a single key from the command line works via a dotted `-D` flag, e.g.
|
|
|
122
137
|
`-D sphinx_examples_as_code_conf.link_position=bottom` -- this only touches that one
|
|
123
138
|
key, leaving the rest (`conf.py`'s values, or the defaults) alone.
|
|
124
139
|
|
|
140
|
+
## Dependencies and run commands
|
|
141
|
+
|
|
142
|
+
With `script_metadata` on, each download lists the third-party projects its code
|
|
143
|
+
imports, plus any `dependencies` set for its format, and says how to run it:
|
|
144
|
+
|
|
145
|
+
- Python scripts start with a [PEP 723](https://peps.python.org/pep-0723/) `# /// script`
|
|
146
|
+
block, followed by `# Run this script with: uv run <name>.py`.
|
|
147
|
+
- Jupyter notebooks say `` Open this notebook with: `uvx --python "<requires-python>" --from jupyterlab --with <dependency> ... jupyter-lab <name>.ipynb` `` in their first cell,
|
|
148
|
+
with `--python` only when there is a `requires-python`. Arguments are double-quoted where
|
|
149
|
+
needed, so the command works in bash, zsh, PowerShell and cmd. An argument containing
|
|
150
|
+
`"`, `$`, a backtick, `\`, `%` or a `!` not followed by `=` is single-quoted instead,
|
|
151
|
+
which cmd does not understand.
|
|
152
|
+
- marimo notebooks start with the same `# /// script` block, which also lists `marimo`,
|
|
153
|
+
followed by `# Open this notebook with: uvx marimo edit --sandbox <name>_marimo.py`.
|
|
154
|
+
- Each run command is followed by a line linking to
|
|
155
|
+
[uv's installation guide](https://docs.astral.sh/uv/getting-started/installation/).
|
|
156
|
+
|
|
157
|
+
Imports are read from the code, not run. Each imported top-level module maps to the
|
|
158
|
+
project that provides it in the environment building the docs; standard-library
|
|
159
|
+
modules, relative imports and modules no single installed project provides are left
|
|
160
|
+
out. Projects the code needs but never imports, such as an optional backend, go in
|
|
161
|
+
`dependencies`.
|
|
162
|
+
|
|
163
|
+
The project named by Sphinx's own `project` setting (e.g. `project = 'PyVista'`) gets
|
|
164
|
+
extra treatment when an example imports it and it is installed: its dependency becomes
|
|
165
|
+
`<name>>=X.Y`, the installed release's major and minor version, or plain `<name>` for a
|
|
166
|
+
pre-release or dev build.
|
|
167
|
+
|
|
168
|
+
Unless `requires_python` is set, the block's `requires-python` combines:
|
|
169
|
+
|
|
170
|
+
- that project's own `Requires-Python`, e.g. `>=3.10`, when it is listed;
|
|
171
|
+
- `<3.N`, one minor version above the newest Python named in the `Programming Language ::
|
|
172
|
+
Python :: 3.X` classifiers of that project and of every listed dependency installed
|
|
173
|
+
from a platform-specific wheel, as installed in the environment building the docs.
|
|
174
|
+
Pure-Python dependencies and dependencies without such classifiers don't count, and
|
|
175
|
+
the bound is dropped when it would exclude every Python the project's own
|
|
176
|
+
`Requires-Python` allows.
|
|
177
|
+
|
|
178
|
+
With neither, the line is left out.
|
|
179
|
+
|
|
125
180
|
## Conversion rules
|
|
126
181
|
|
|
127
182
|
What happens to the content of an Examples section:
|
|
@@ -166,7 +221,7 @@ cells instead.
|
|
|
166
221
|
|
|
167
222
|
Generated marimo notebooks are that same Jupyter notebook converted by marimo's own
|
|
168
223
|
converter, the one behind `marimo convert`. `from __future__` imports are dropped first,
|
|
169
|
-
so the notebook also runs as a plain script (`python <name
|
|
224
|
+
so the notebook also runs as a plain script (`python <name>_marimo.py`).
|
|
170
225
|
|
|
171
226
|
A download link is only added if the resulting code contains at least one real
|
|
172
227
|
executable statement.
|
|
@@ -54,6 +54,9 @@ sphinx_examples_as_code_conf = {
|
|
|
54
54
|
'jupyter': 'Download Jupyter notebook',
|
|
55
55
|
'marimo': 'Download marimo notebook',
|
|
56
56
|
},
|
|
57
|
+
'script_metadata': False,
|
|
58
|
+
'dependencies': {},
|
|
59
|
+
'requires_python': None,
|
|
57
60
|
}
|
|
58
61
|
```
|
|
59
62
|
|
|
@@ -61,7 +64,7 @@ sphinx_examples_as_code_conf = {
|
|
|
61
64
|
(default) or `'bottom'`.
|
|
62
65
|
- `formats`: which downloads to generate. A list containing any of `'python'` (a plain
|
|
63
66
|
Python script, `<name>.py`), `'jupyter'` (a Jupyter notebook, `<name>.ipynb`) and
|
|
64
|
-
`'marimo'` (a marimo notebook, `<name
|
|
67
|
+
`'marimo'` (a marimo notebook, `<name>_marimo.py`); defaults to all three. Always
|
|
65
68
|
offered in that order regardless of how the list is written. Without marimo 0.14 or
|
|
66
69
|
newer installed, the default skips the marimo download, and a `formats` that names
|
|
67
70
|
`'marimo'` (in `conf.py` or through `-D`) stops the build with a configuration error. An unknown format raises a configuration error too;
|
|
@@ -80,6 +83,17 @@ sphinx_examples_as_code_conf = {
|
|
|
80
83
|
Markdown link in notebooks, and renders inline as `text url` in Python scripts. Plain
|
|
81
84
|
text with no markup at all becomes one comment line per line of text, and
|
|
82
85
|
blank-line-separated paragraphs stay separated.
|
|
86
|
+
- `script_metadata`: `True` adds each download's dependencies and a one-line run
|
|
87
|
+
command. See [Dependencies and run commands](#dependencies-and-run-commands) below.
|
|
88
|
+
`False` (default) adds neither.
|
|
89
|
+
- `dependencies`: extra PEP 508 requirements per format, added to the detected ones, e.g.
|
|
90
|
+
`{'jupyter': ['pyvista[jupyter]']}`. An entry naming a detected project replaces it,
|
|
91
|
+
so `{'python': ['pyvista>=0.46']}` sets its version. An entry without a version keeps
|
|
92
|
+
the automatic pin described below. Only used with `script_metadata` on.
|
|
93
|
+
- `requires_python`: a `requires-python` specifier for the dependency block, e.g.
|
|
94
|
+
`'>=3.10'`. `None` (default) derives one from the dependencies instead; see
|
|
95
|
+
[Dependencies and run commands](#dependencies-and-run-commands). Only used with
|
|
96
|
+
`script_metadata` on.
|
|
83
97
|
|
|
84
98
|
An unrecognized key raises a configuration error at build start.
|
|
85
99
|
|
|
@@ -91,6 +105,46 @@ Overriding a single key from the command line works via a dotted `-D` flag, e.g.
|
|
|
91
105
|
`-D sphinx_examples_as_code_conf.link_position=bottom` -- this only touches that one
|
|
92
106
|
key, leaving the rest (`conf.py`'s values, or the defaults) alone.
|
|
93
107
|
|
|
108
|
+
## Dependencies and run commands
|
|
109
|
+
|
|
110
|
+
With `script_metadata` on, each download lists the third-party projects its code
|
|
111
|
+
imports, plus any `dependencies` set for its format, and says how to run it:
|
|
112
|
+
|
|
113
|
+
- Python scripts start with a [PEP 723](https://peps.python.org/pep-0723/) `# /// script`
|
|
114
|
+
block, followed by `# Run this script with: uv run <name>.py`.
|
|
115
|
+
- Jupyter notebooks say `` Open this notebook with: `uvx --python "<requires-python>" --from jupyterlab --with <dependency> ... jupyter-lab <name>.ipynb` `` in their first cell,
|
|
116
|
+
with `--python` only when there is a `requires-python`. Arguments are double-quoted where
|
|
117
|
+
needed, so the command works in bash, zsh, PowerShell and cmd. An argument containing
|
|
118
|
+
`"`, `$`, a backtick, `\`, `%` or a `!` not followed by `=` is single-quoted instead,
|
|
119
|
+
which cmd does not understand.
|
|
120
|
+
- marimo notebooks start with the same `# /// script` block, which also lists `marimo`,
|
|
121
|
+
followed by `# Open this notebook with: uvx marimo edit --sandbox <name>_marimo.py`.
|
|
122
|
+
- Each run command is followed by a line linking to
|
|
123
|
+
[uv's installation guide](https://docs.astral.sh/uv/getting-started/installation/).
|
|
124
|
+
|
|
125
|
+
Imports are read from the code, not run. Each imported top-level module maps to the
|
|
126
|
+
project that provides it in the environment building the docs; standard-library
|
|
127
|
+
modules, relative imports and modules no single installed project provides are left
|
|
128
|
+
out. Projects the code needs but never imports, such as an optional backend, go in
|
|
129
|
+
`dependencies`.
|
|
130
|
+
|
|
131
|
+
The project named by Sphinx's own `project` setting (e.g. `project = 'PyVista'`) gets
|
|
132
|
+
extra treatment when an example imports it and it is installed: its dependency becomes
|
|
133
|
+
`<name>>=X.Y`, the installed release's major and minor version, or plain `<name>` for a
|
|
134
|
+
pre-release or dev build.
|
|
135
|
+
|
|
136
|
+
Unless `requires_python` is set, the block's `requires-python` combines:
|
|
137
|
+
|
|
138
|
+
- that project's own `Requires-Python`, e.g. `>=3.10`, when it is listed;
|
|
139
|
+
- `<3.N`, one minor version above the newest Python named in the `Programming Language ::
|
|
140
|
+
Python :: 3.X` classifiers of that project and of every listed dependency installed
|
|
141
|
+
from a platform-specific wheel, as installed in the environment building the docs.
|
|
142
|
+
Pure-Python dependencies and dependencies without such classifiers don't count, and
|
|
143
|
+
the bound is dropped when it would exclude every Python the project's own
|
|
144
|
+
`Requires-Python` allows.
|
|
145
|
+
|
|
146
|
+
With neither, the line is left out.
|
|
147
|
+
|
|
94
148
|
## Conversion rules
|
|
95
149
|
|
|
96
150
|
What happens to the content of an Examples section:
|
|
@@ -135,7 +189,7 @@ cells instead.
|
|
|
135
189
|
|
|
136
190
|
Generated marimo notebooks are that same Jupyter notebook converted by marimo's own
|
|
137
191
|
converter, the one behind `marimo convert`. `from __future__` imports are dropped first,
|
|
138
|
-
so the notebook also runs as a plain script (`python <name
|
|
192
|
+
so the notebook also runs as a plain script (`python <name>_marimo.py`).
|
|
139
193
|
|
|
140
194
|
A download link is only added if the resulting code contains at least one real
|
|
141
195
|
executable statement.
|
|
@@ -32,7 +32,7 @@ classifiers = [
|
|
|
32
32
|
'Programming Language :: Python :: 3.14',
|
|
33
33
|
'Topic :: Scientific/Engineering :: Visualization',
|
|
34
34
|
]
|
|
35
|
-
dependencies = ['pyvista>=0.48']
|
|
35
|
+
dependencies = ['packaging>=22', 'pyvista>=0.48']
|
|
36
36
|
description = 'Sphinx extension for converting docstring examples into downloadable code.'
|
|
37
37
|
dynamic = ['version']
|
|
38
38
|
keywords = ['download', 'examples', 'sphinx']
|