Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
cf43d4f
put install and import test into its own workflow
rocco8773 Apr 25, 2025
0f8b8fd
add tests on py 3.6 and 3.13
rocco8773 Apr 25, 2025
63b206a
cache tests and set fetch-depth to 1
rocco8773 Apr 25, 2025
1246caf
restrict workflow permissions
rocco8773 Apr 25, 2025
3cc97ce
no not explicitly install plasmapy
rocco8773 Apr 25, 2025
906b493
set upper sphinx limit to < 8.2
rocco8773 Apr 25, 2025
da1252d
set upper sphinx limit to < 7.4
rocco8773 Apr 28, 2025
d02a2e1
add plasmapy dependency to the documentation requirements
rocco8773 Apr 28, 2025
2bed441
set min python version to 3.8
rocco8773 Apr 28, 2025
91ca114
set min setuptools version to 61
rocco8773 Apr 28, 2025
5557b9a
remove fail on warnings and add 3x verbosity
rocco8773 May 1, 2025
b3cc46f
remove the 3x verbosity
rocco8773 May 1, 2025
e2dbfc1
add dependency "packaging"
rocco8773 May 1, 2025
e822c24
adopt a kwarg passing scheme so we can be flexible in passing args to…
rocco8773 May 1, 2025
4823b10
put sphinx upper limit to 8.2
rocco8773 May 1, 2025
4626a12
add sphinx_limits workflow
rocco8773 May 1, 2025
2b4b907
repair sphinx_limits workflow
rocco8773 May 1, 2025
c1af3d0
repair sphinx_limits workflow
rocco8773 May 1, 2025
b3b076c
replace double quotes with single quotes
rocco8773 May 1, 2025
ade581c
put ${{ matrix.sphinx }} between quotes
rocco8773 May 1, 2025
bd0bbad
put fail on warning for the sphinx_limit workflow
rocco8773 May 1, 2025
1c40391
put fail on warning for the documentation workflow
rocco8773 May 1, 2025
c62570a
explicitly pass prefixes to import_by_name
rocco8773 May 1, 2025
fe677e3
explicitly remove prefixes before passing to parent method
rocco8773 May 1, 2025
f7ac2ad
add a nitpick exception for SphinxDirective.parse_inline
rocco8773 May 1, 2025
491af31
remove the quiet tag from sphinx builds workflow
rocco8773 May 1, 2025
afc343a
add to nitpick exceptions
rocco8773 May 2, 2025
06a430a
remove the string prefix in a python agnostic way
rocco8773 May 2, 2025
a37349c
correct the prefix removal +1
rocco8773 May 2, 2025
230a2d8
add nitpick ignore for ObjectMembers type annotation
rocco8773 May 2, 2025
6bff2db
make nitpick ignore rules a little more generic
rocco8773 May 2, 2025
b77fb69
add ObjectMember to nitpick ignore rules
rocco8773 May 2, 2025
108f4c3
remove upper dependency limit on sphinx
rocco8773 May 2, 2025
5b6bae3
add a build on py3.11
rocco8773 May 2, 2025
d03199e
add kwargs for generate_autosummary_content() that are specific to sp…
rocco8773 May 2, 2025
0d463fd
remove trailing whitespace
rocco8773 May 2, 2025
a5427bc
add check on py3.11
rocco8773 May 2, 2025
83fa54e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 2, 2025
eaa5cb7
wrangle option :no-index: to :index: for sphinx < 7.2
rocco8773 May 3, 2025
aae0e6e
remove unused import
rocco8773 May 3, 2025
19bead0
remove wrongly placed handling of the no-index option for sphinx < 7.2
rocco8773 May 3, 2025
9c86ae2
add the 'no-index' option to option_spec if ModuleDocumenter.option_s…
rocco8773 May 3, 2025
80f7e02
wrangle option :no-index: to :index: for sphinx < 7.2
rocco8773 May 3, 2025
5a7bf8d
remove unused import
rocco8773 May 3, 2025
0d4e4de
remove unused import
rocco8773 May 5, 2025
0c2776d
add permissions statement
rocco8773 May 6, 2025
6ffd298
remove if-clause for importing importlib.metadata
rocco8773 May 6, 2025
e748b95
add build for sphinx<7.2
rocco8773 May 7, 2025
df14205
update actions/setup-python@v4 to actions/setup-python@v5
rocco8773 May 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/check_install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Install and Import

on:
push:
branches:
- main
- v0.*.x
tags:
- v*
pull_request:
workflow_dispatch:

permissions: {} # disables all GitHub permissions for the workflow

jobs:
pip-install-and-import:
name: Installation with pip & import (py-${{ matrix.python }})
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
python: ['3.8', '3.10', '3.11', '3.12', '3.13']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌠 If we wanted to be ambitious and thorough later on (not in this PR!), the lowest-direct resolution strategy of uv would let us test plasmapy_sphinx against the oldest allowed versions of direct dependencies. 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future work... I just want to get this to the next step first.

os: [ubuntu-latest]

steps:
- name: Checkout code
uses: actions/checkout@v3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uses: actions/checkout@v3
uses: actions/checkout@v4

with:
fetch-depth: 1

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: pip
- name: Install plasmapy_sphinx with pip
run: pip install .
- name: Import plasmapy_sphinx
run: python -c "import plasmapy_sphinx"
53 changes: 40 additions & 13 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
pull_request:
workflow_dispatch:

permissions: {} # disables all GitHub permissions for the workflow

jobs:
documentation:
name: Doc Build - py${{ matrix.python }} on ${{ matrix.os }}
Expand All @@ -18,39 +20,64 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['3.10', '3.12']
python: ['3.8', '3.10', '3.11', '3.12', '3.13']
os: [ubuntu-latest]

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 1
Comment on lines -28 to +30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for learning from my mistakes! 😅

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: pip
- name: Install dependencies
run: |
python -m pip install --progress-bar off --upgrade pip
python -m pip install --progress-bar off -r requirements/docs.txt git+https://github.com/PlasmaPy/plasmapy
python -m pip install --progress-bar off -r requirements/docs.txt
sudo apt-get install graphviz pandoc
- name: Build Docs
run: |
sphinx-build ./docs ./docs/_build -n --keep-going -W -b html -q
sphinx-build ./docs ./docs/_build -n --keep-going -W -b html

sphinx_limits:
name: Doc Build on ${{ matrix.sphinx }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false

matrix:
include:
- python: '3.11'
os: ubuntu-latest
sphinx: sphinx<7.2

pip-install:
name: Installation with pip
runs-on: ubuntu-latest
- python: '3.12'
os: ubuntu-latest
sphinx: sphinx<7.4

- python: '3.12'
os: ubuntu-latest
sphinx: sphinx<8.2

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install plasmapy_sphinx with pip
run: pip install .
python-version: ${{ matrix.python }}
cache: pip
- name: Install dependencies
run: |
python -m pip install --progress-bar off --upgrade pip
python -m pip install --progress-bar off -r requirements/docs.txt "${{ matrix.sphinx }}"
sudo apt-get install graphviz pandoc
- name: Build Docs
run: |
sphinx-build ./docs ./docs/_build -n --keep-going -W -b html
2 changes: 2 additions & 0 deletions .github/workflows/mint-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
required: true
default: 0.1.0rc1

permissions: {} # disables all GitHub permissions for the workflow

jobs:

tag:
Expand Down
4 changes: 4 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@
(python_role, "plasmapy.analysis.swept_langmuir.find_floating_potential"),
(python_role, "plasmapy.particles.particle_collections"),
(python_role, "plasmapy.utils.decorators.lite_func"),
# Sphinx
(python_role, "system_message"), # sphinx.util.docutils.system_message
(python_role, "ObjectMember"), # sphinx.ext.autodoc.ObjectMember
(python_role, "ObjectMembers"), # sphinx.ext.autodoc.ObjectMembers
]

# -- Options for HTML output ----------------------------------------------
Expand Down
9 changes: 3 additions & 6 deletions plasmapy_sphinx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,10 @@
# This is the same check as the one at the top of setup.py
import sys

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

Comment on lines +73 to 75
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if sys.version_info < (3, 8): # coverage: ignore
raise ImportError("plasmapy_sphinx does not support Python < 3.8")

plasmapy_sphinx is likely only going to be used by experienced developers and 3.8 has been around for a 5 years, so my inclination would be to drop this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should probably do that. I didn't since I'm using plasmapy_sphinx on packages that have to support older python versions, and I just want to make sure it's a non-issue before dropping support here.

In reality, I can restrict building documentation to newer versions of python for those packages that have to support older version of python.

if sys.version_info >= (3, 8):
from importlib.metadata import version, PackageNotFoundError
else:
from importlib_metadata import version, PackageNotFoundError
from importlib.metadata import version, PackageNotFoundError

from plasmapy_sphinx import autodoc, automodsumm, directives, utils

Expand Down
14 changes: 13 additions & 1 deletion plasmapy_sphinx/autodoc/automodapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,13 @@

import inspect
import re
import sys
import warnings

from collections import OrderedDict
from docutils.parsers.rst import directives
from docutils.statemachine import StringList
from packaging.version import Version
from sphinx import __version__ as sphinx_version
from sphinx.application import Sphinx

try:
Expand Down Expand Up @@ -349,6 +350,8 @@ class RemovedInSphinx50Warning(PendingDeprecationWarning):
"inheritance-diagram": bool_option,
"no-inheritance-diagram": bool_option,
} # type: Dict[str, Callable]
if "no-index" not in _option_spec:
_option_spec["no-index"] = bool_option
for option_name in list(_option_spec):
if "member" in option_name:
del _option_spec[option_name]
Expand Down Expand Up @@ -504,6 +507,15 @@ class ModAPIDocumenter(ModuleDocumenter):
),
}

def __init__(self, *args: Any) -> None:
super().__init__(*args)

if Version(sphinx_version) < Version("7.2") and "no-index" in self.options:
# sphinx started using :no-index: instead of the original :noindex:
# in version 7.2
opt_value = self.options.pop("no-index")
self.options["noindex"] = opt_value

@property
def grouping_info(self) -> Dict[str, Dict[str, Union[str, None]]]:
"""
Expand Down
13 changes: 12 additions & 1 deletion plasmapy_sphinx/automodsumm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@
import os

from importlib import import_module
from packaging.version import Version
from sphinx import __version__ as sphinx_version
from sphinx.ext.autosummary import Autosummary
from sphinx.util import logging
from typing import Any, Callable, Dict, List, Tuple, Union
Expand Down Expand Up @@ -664,7 +666,16 @@ def import_by_name(
self, name: str, prefixes: List[str]
) -> Tuple[str, Any, Any, str]:
"""See :func:`sphinx.ext.autosummary.import_by_name`"""
return super(Automodsumm, self).import_by_name(name, prefixes)

for prefix in prefixes:
if prefix is None:
continue

if name.startswith(f"{prefix}."):
name = name[len(prefix)+1:]
break

return super().import_by_name(name, prefixes)


def setup(app: "Sphinx"):
Expand Down
38 changes: 23 additions & 15 deletions plasmapy_sphinx/automodsumm/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import re

from jinja2 import TemplateNotFound
from packaging.version import Version
from sphinx import __version__ as sphinx_version
from sphinx.ext.autodoc.mock import mock
from sphinx.ext.autosummary import get_rst_suffix, import_by_name, import_ivar_by_name
from sphinx.ext.autosummary.generate import (
Expand All @@ -25,7 +27,6 @@
if False:
# for annotation, does not need real import
from sphinx.application import Sphinx
from sphinx.builders import Builder


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -291,7 +292,7 @@ def generate_docs(
ensuredir(path)

try:
name, obj, parent, modname = import_by_name(entry.name)
name, obj, parent, modname = import_by_name(entry.name, prefixes=(None,))
qualname = name.replace(modname + ".", "")
except ImportError as e:
try:
Expand All @@ -306,19 +307,26 @@ def generate_docs(
if app:
context.update(app.config.autosummary_context)

content = generate_autosummary_content(
name,
obj,
parent,
template,
entry.template,
imported_members,
app,
entry.recursive,
context,
modname,
qualname,
)
_kwargs = {
"name": name,
"obj": obj,
"parent": parent,
"template": template,
"template_name": entry.template,
"imported_members": imported_members,
"recursive": entry.recursive,
"context": context,
"modname": modname,
"qualname": qualname,
}
if Version(sphinx_version) < Version("8.2"):
_kwargs["app"] = app
else:
_kwargs["config"] = app.config
_kwargs["events"] = app.events
_kwargs["registry"] = app.registry

content = generate_autosummary_content(**_kwargs)

filename = os.path.join(path, filename_map.get(name, name) + suffix)
if os.path.isfile(filename):
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = [ # ought to mirror 'requirements/build.txt'
"setuptools >= 41.2",
"setuptools >= 61",
"setuptools_scm",
"wheel >= 0.29.0",
]
Expand All @@ -14,7 +14,7 @@ maintainers = [
]
description = "Sphinx extensions for the PlasmaPy Project"
readme = "README.md"
requires-python = ">=3.6"
requires-python = ">=3.8"
dynamic = ["version"]
license = {file = "LICENSE.md"}
keywords = ["plasmapy", "sphinx", "documentation"]
Expand All @@ -24,8 +24,6 @@ classifiers = [
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand All @@ -37,6 +35,7 @@ dependencies = [ # ought to mirror 'requirements/install.txt'
"docutils",
"importlib_metadata; python_version < '3.8'",
"jinja2 != 3.1",
"packaging",
"sphinx >= 4.4",
"sphinx-gallery",
"sphinx_rtd_theme >= 1.0.0",
Expand Down Expand Up @@ -65,6 +64,7 @@ docs = [ # ought to mirror 'requirements/docs.txt'
"numpydoc",
"packaging",
"pillow",
"plasmapy > 8.0",
"pygments >= 2.11.0",
"sphinx-changelog",
"sphinx-copybutton",
Expand Down
2 changes: 1 addition & 1 deletion requirements/build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
#
# ought to mirror [build-system.requires] under in pyproject.toml
#
setuptools >= 41.2
setuptools >= 61
setuptools_scm
wheel >= 0.29.0
1 change: 1 addition & 0 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
numpydoc
packaging
pillow
plasmapy > 8.0
pygments >= 2.11.0
sphinx-changelog
sphinx-copybutton
Expand Down
1 change: 1 addition & 0 deletions requirements/install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
docutils
importlib_metadata; python_version < '3.8'
jinja2 != 3.1
packaging
sphinx >= 4.4
sphinx-gallery
sphinx_rtd_theme >= 1.0.0