Skip to content

Commit a8521ea

Browse files
"Modernize" GitHub Wrokflows (#18)
* put install and import test into its own workflow * add tests on py 3.6 and 3.13 * cache tests and set fetch-depth to 1 * restrict workflow permissions * no not explicitly install plasmapy * set upper sphinx limit to < 8.2 * set upper sphinx limit to < 7.4 * add plasmapy dependency to the documentation requirements * set min python version to 3.8 * set min setuptools version to 61 * remove fail on warnings and add 3x verbosity * remove the 3x verbosity * add dependency "packaging" * adopt a kwarg passing scheme so we can be flexible in passing args to generate_autosummary_content(), who's signature changes for sphinx >= 8.0 * put sphinx upper limit to 8.2 * add sphinx_limits workflow * repair sphinx_limits workflow * repair sphinx_limits workflow * replace double quotes with single quotes * put ${{ matrix.sphinx }} between quotes * put fail on warning for the sphinx_limit workflow * put fail on warning for the documentation workflow * explicitly pass prefixes to import_by_name * explicitly remove prefixes before passing to parent method * add a nitpick exception for SphinxDirective.parse_inline * remove the quiet tag from sphinx builds workflow * add to nitpick exceptions * remove the string prefix in a python agnostic way * correct the prefix removal +1 * add nitpick ignore for ObjectMembers type annotation * make nitpick ignore rules a little more generic * add ObjectMember to nitpick ignore rules * remove upper dependency limit on sphinx * add a build on py3.11 * add kwargs for generate_autosummary_content() that are specific to sphinx >= 8.2 specific * remove trailing whitespace * add check on py3.11 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * wrangle option :no-index: to :index: for sphinx < 7.2 * remove unused import * remove wrongly placed handling of the no-index option for sphinx < 7.2 * add the 'no-index' option to option_spec if ModuleDocumenter.option_spec does not have it * wrangle option :no-index: to :index: for sphinx < 7.2 * remove unused import * remove unused import * add permissions statement * remove if-clause for importing importlib.metadata * add build for sphinx<7.2 * update actions/setup-python@v4 to actions/setup-python@v5 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 563a667 commit a8521ea

File tree

12 files changed

+144
-41
lines changed

12 files changed

+144
-41
lines changed

.github/workflows/check_install.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Install and Import
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- v0.*.x
8+
tags:
9+
- v*
10+
pull_request:
11+
workflow_dispatch:
12+
13+
permissions: {} # disables all GitHub permissions for the workflow
14+
15+
jobs:
16+
pip-install-and-import:
17+
name: Installation with pip & import (py-${{ matrix.python }})
18+
runs-on: ${{ matrix.os }}
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
python: ['3.8', '3.10', '3.11', '3.12', '3.13']
24+
os: [ubuntu-latest]
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v3
29+
with:
30+
fetch-depth: 1
31+
32+
- name: Set up Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: ${{ matrix.python }}
36+
cache: pip
37+
- name: Install plasmapy_sphinx with pip
38+
run: pip install .
39+
- name: Import plasmapy_sphinx
40+
run: python -c "import plasmapy_sphinx"

.github/workflows/documentation.yml

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ on:
1010
pull_request:
1111
workflow_dispatch:
1212

13+
permissions: {} # disables all GitHub permissions for the workflow
14+
1315
jobs:
1416
documentation:
1517
name: Doc Build - py${{ matrix.python }} on ${{ matrix.os }}
@@ -18,39 +20,64 @@ jobs:
1820
strategy:
1921
fail-fast: false
2022
matrix:
21-
python: ['3.10', '3.12']
23+
python: ['3.8', '3.10', '3.11', '3.12', '3.13']
2224
os: [ubuntu-latest]
2325

2426
steps:
2527
- name: Checkout code
2628
uses: actions/checkout@v3
2729
with:
28-
fetch-depth: 0
30+
fetch-depth: 1
2931
- name: Set up Python
30-
uses: actions/setup-python@v4
32+
uses: actions/setup-python@v5
3133
with:
3234
python-version: ${{ matrix.python }}
35+
cache: pip
3336
- name: Install dependencies
3437
run: |
3538
python -m pip install --progress-bar off --upgrade pip
36-
python -m pip install --progress-bar off -r requirements/docs.txt git+https://github.com/PlasmaPy/plasmapy
39+
python -m pip install --progress-bar off -r requirements/docs.txt
3740
sudo apt-get install graphviz pandoc
3841
- name: Build Docs
3942
run: |
40-
sphinx-build ./docs ./docs/_build -n --keep-going -W -b html -q
43+
sphinx-build ./docs ./docs/_build -n --keep-going -W -b html
44+
45+
sphinx_limits:
46+
name: Doc Build on ${{ matrix.sphinx }}
47+
runs-on: ${{ matrix.os }}
48+
49+
strategy:
50+
fail-fast: false
51+
52+
matrix:
53+
include:
54+
- python: '3.11'
55+
os: ubuntu-latest
56+
sphinx: sphinx<7.2
4157

42-
pip-install:
43-
name: Installation with pip
44-
runs-on: ubuntu-latest
58+
- python: '3.12'
59+
os: ubuntu-latest
60+
sphinx: sphinx<7.4
61+
62+
- python: '3.12'
63+
os: ubuntu-latest
64+
sphinx: sphinx<8.2
4565

4666
steps:
4767
- name: Checkout code
4868
uses: actions/checkout@v3
4969
with:
50-
fetch-depth: 0
70+
fetch-depth: 1
5171
- name: Set up Python
52-
uses: actions/setup-python@v4
72+
uses: actions/setup-python@v5
5373
with:
54-
python-version: 3.12
55-
- name: Install plasmapy_sphinx with pip
56-
run: pip install .
74+
python-version: ${{ matrix.python }}
75+
cache: pip
76+
- name: Install dependencies
77+
run: |
78+
python -m pip install --progress-bar off --upgrade pip
79+
python -m pip install --progress-bar off -r requirements/docs.txt "${{ matrix.sphinx }}"
80+
sudo apt-get install graphviz pandoc
81+
- name: Build Docs
82+
run: |
83+
sphinx-build ./docs ./docs/_build -n --keep-going -W -b html

.github/workflows/mint-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
required: true
99
default: 0.1.0rc1
1010

11+
permissions: {} # disables all GitHub permissions for the workflow
12+
1113
jobs:
1214

1315
tag:

docs/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,10 @@
339339
(python_role, "plasmapy.analysis.swept_langmuir.find_floating_potential"),
340340
(python_role, "plasmapy.particles.particle_collections"),
341341
(python_role, "plasmapy.utils.decorators.lite_func"),
342+
# Sphinx
343+
(python_role, "system_message"), # sphinx.util.docutils.system_message
344+
(python_role, "ObjectMember"), # sphinx.ext.autodoc.ObjectMember
345+
(python_role, "ObjectMembers"), # sphinx.ext.autodoc.ObjectMembers
342346
]
343347

344348
# -- Options for HTML output ----------------------------------------------

plasmapy_sphinx/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,10 @@
7070
# This is the same check as the one at the top of setup.py
7171
import sys
7272

73-
if sys.version_info < (3, 6): # coverage: ignore
74-
raise ImportError("plasmapy_sphinx does not support Python < 3.6")
73+
if sys.version_info < (3, 8): # coverage: ignore
74+
raise ImportError("plasmapy_sphinx does not support Python < 3.8")
7575

76-
if sys.version_info >= (3, 8):
77-
from importlib.metadata import version, PackageNotFoundError
78-
else:
79-
from importlib_metadata import version, PackageNotFoundError
76+
from importlib.metadata import version, PackageNotFoundError
8077

8178
from plasmapy_sphinx import autodoc, automodsumm, directives, utils
8279

plasmapy_sphinx/autodoc/automodapi.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,13 @@
303303

304304
import inspect
305305
import re
306-
import sys
307306
import warnings
308307

309308
from collections import OrderedDict
310309
from docutils.parsers.rst import directives
311310
from docutils.statemachine import StringList
311+
from packaging.version import Version
312+
from sphinx import __version__ as sphinx_version
312313
from sphinx.application import Sphinx
313314

314315
try:
@@ -349,6 +350,8 @@ class RemovedInSphinx50Warning(PendingDeprecationWarning):
349350
"inheritance-diagram": bool_option,
350351
"no-inheritance-diagram": bool_option,
351352
} # type: Dict[str, Callable]
353+
if "no-index" not in _option_spec:
354+
_option_spec["no-index"] = bool_option
352355
for option_name in list(_option_spec):
353356
if "member" in option_name:
354357
del _option_spec[option_name]
@@ -504,6 +507,15 @@ class ModAPIDocumenter(ModuleDocumenter):
504507
),
505508
}
506509

510+
def __init__(self, *args: Any) -> None:
511+
super().__init__(*args)
512+
513+
if Version(sphinx_version) < Version("7.2") and "no-index" in self.options:
514+
# sphinx started using :no-index: instead of the original :noindex:
515+
# in version 7.2
516+
opt_value = self.options.pop("no-index")
517+
self.options["noindex"] = opt_value
518+
507519
@property
508520
def grouping_info(self) -> Dict[str, Dict[str, Union[str, None]]]:
509521
"""

plasmapy_sphinx/automodsumm/core.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@
208208
import os
209209

210210
from importlib import import_module
211+
from packaging.version import Version
212+
from sphinx import __version__ as sphinx_version
211213
from sphinx.ext.autosummary import Autosummary
212214
from sphinx.util import logging
213215
from typing import Any, Callable, Dict, List, Tuple, Union
@@ -664,7 +666,16 @@ def import_by_name(
664666
self, name: str, prefixes: List[str]
665667
) -> Tuple[str, Any, Any, str]:
666668
"""See :func:`sphinx.ext.autosummary.import_by_name`"""
667-
return super(Automodsumm, self).import_by_name(name, prefixes)
669+
670+
for prefix in prefixes:
671+
if prefix is None:
672+
continue
673+
674+
if name.startswith(f"{prefix}."):
675+
name = name[len(prefix)+1:]
676+
break
677+
678+
return super().import_by_name(name, prefixes)
668679

669680

670681
def setup(app: "Sphinx"):

plasmapy_sphinx/automodsumm/generate.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import re
99

1010
from jinja2 import TemplateNotFound
11+
from packaging.version import Version
12+
from sphinx import __version__ as sphinx_version
1113
from sphinx.ext.autodoc.mock import mock
1214
from sphinx.ext.autosummary import get_rst_suffix, import_by_name, import_ivar_by_name
1315
from sphinx.ext.autosummary.generate import (
@@ -25,7 +27,6 @@
2527
if False:
2628
# for annotation, does not need real import
2729
from sphinx.application import Sphinx
28-
from sphinx.builders import Builder
2930

3031

3132
logger = logging.getLogger(__name__)
@@ -291,7 +292,7 @@ def generate_docs(
291292
ensuredir(path)
292293

293294
try:
294-
name, obj, parent, modname = import_by_name(entry.name)
295+
name, obj, parent, modname = import_by_name(entry.name, prefixes=(None,))
295296
qualname = name.replace(modname + ".", "")
296297
except ImportError as e:
297298
try:
@@ -306,19 +307,26 @@ def generate_docs(
306307
if app:
307308
context.update(app.config.autosummary_context)
308309

309-
content = generate_autosummary_content(
310-
name,
311-
obj,
312-
parent,
313-
template,
314-
entry.template,
315-
imported_members,
316-
app,
317-
entry.recursive,
318-
context,
319-
modname,
320-
qualname,
321-
)
310+
_kwargs = {
311+
"name": name,
312+
"obj": obj,
313+
"parent": parent,
314+
"template": template,
315+
"template_name": entry.template,
316+
"imported_members": imported_members,
317+
"recursive": entry.recursive,
318+
"context": context,
319+
"modname": modname,
320+
"qualname": qualname,
321+
}
322+
if Version(sphinx_version) < Version("8.2"):
323+
_kwargs["app"] = app
324+
else:
325+
_kwargs["config"] = app.config
326+
_kwargs["events"] = app.events
327+
_kwargs["registry"] = app.registry
328+
329+
content = generate_autosummary_content(**_kwargs)
322330

323331
filename = os.path.join(path, filename_map.get(name, name) + suffix)
324332
if os.path.isfile(filename):

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
22
requires = [ # ought to mirror 'requirements/build.txt'
3-
"setuptools >= 41.2",
3+
"setuptools >= 61",
44
"setuptools_scm",
55
"wheel >= 0.29.0",
66
]
@@ -14,7 +14,7 @@ maintainers = [
1414
]
1515
description = "Sphinx extensions for the PlasmaPy Project"
1616
readme = "README.md"
17-
requires-python = ">=3.6"
17+
requires-python = ">=3.8"
1818
dynamic = ["version"]
1919
license = {file = "LICENSE.md"}
2020
keywords = ["plasmapy", "sphinx", "documentation"]
@@ -24,8 +24,6 @@ classifiers = [
2424
"License :: OSI Approved :: BSD License",
2525
"Operating System :: OS Independent",
2626
"Programming Language :: Python :: 3",
27-
"Programming Language :: Python :: 3.6",
28-
"Programming Language :: Python :: 3.7",
2927
"Programming Language :: Python :: 3.8",
3028
"Programming Language :: Python :: 3.8",
3129
"Programming Language :: Python :: 3.9",
@@ -37,6 +35,7 @@ dependencies = [ # ought to mirror 'requirements/install.txt'
3735
"docutils",
3836
"importlib_metadata; python_version < '3.8'",
3937
"jinja2 != 3.1",
38+
"packaging",
4039
"sphinx >= 4.4",
4140
"sphinx-gallery",
4241
"sphinx_rtd_theme >= 1.0.0",
@@ -65,6 +64,7 @@ docs = [ # ought to mirror 'requirements/docs.txt'
6564
"numpydoc",
6665
"packaging",
6766
"pillow",
67+
"plasmapy > 8.0",
6868
"pygments >= 2.11.0",
6969
"sphinx-changelog",
7070
"sphinx-copybutton",

requirements/build.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
#
44
# ought to mirror [build-system.requires] under in pyproject.toml
55
#
6-
setuptools >= 41.2
6+
setuptools >= 61
77
setuptools_scm
88
wheel >= 0.29.0

requirements/docs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
numpydoc
77
packaging
88
pillow
9+
plasmapy > 8.0
910
pygments >= 2.11.0
1011
sphinx-changelog
1112
sphinx-copybutton

requirements/install.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
docutils
77
importlib_metadata; python_version < '3.8'
88
jinja2 != 3.1
9+
packaging
910
sphinx >= 4.4
1011
sphinx-gallery
1112
sphinx_rtd_theme >= 1.0.0

0 commit comments

Comments
 (0)