Skip to content

Commit 9a9daf2

Browse files
authored
Migrate Docs to Sphinx-Design, Remove NPS, Update Workflows (#109)
1 parent 078c533 commit 9a9daf2

File tree

21 files changed

+269
-241
lines changed

21 files changed

+269
-241
lines changed

.github/workflows/coverage.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ on: # Runs on all push events to master branch and any push related to a pull r
1313

1414
jobs:
1515
coverage:
16-
name: ${{ matrix.os }} / ${{ matrix.python-version }}
17-
runs-on: ${{ matrix.os }}
18-
strategy:
19-
matrix: # only lowest supported python on ubuntu-latest
20-
os: [ubuntu-latest]
21-
python-version: [3.11]
16+
runs-on: ubuntu-latest
17+
env:
18+
python-version: 3.12
2219

2320
steps:
2421
- uses: actions/checkout@v4
2522

26-
- name: Set up Python ${{ matrix.python-version }}
23+
- name: Set up Python ${{ env.python-version }}
2724
uses: actions/setup-python@v5
2825
with:
29-
python-version: ${{ matrix.python-version }}
30-
cache: pip
26+
python-version: ${{ env.python-version }}
27+
cache: 'pip'
3128
cache-dependency-path: '**/pyproject.toml'
3229

30+
- name: Upgrade pip, setuptools and wheel
31+
run: python -m pip install --upgrade pip setuptools wheel
32+
3333
- name: Install package with test dependencies
3434
run: python -m pip install ".[test]"
3535

@@ -40,6 +40,6 @@ jobs:
4040
run: make alltests
4141

4242
- name: Upload Coverage to Codecov
43-
uses: codecov/codecov-action@v3
43+
uses: codecov/codecov-action@v4
4444
with:
4545
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/cron.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,8 @@ jobs:
1515
runs-on: ${{ matrix.os }}
1616
strategy:
1717
matrix:
18-
os: [ubuntu-22.04, macos-latest, windows-latest]
19-
python-version: [3.8, 3.9, "3.10", 3.11, 3.12, 3.x] # crons should always run latest python hence 3.x
20-
# exclude:
21-
# - os: windows-latest # scipy deps issues
22-
# python-version: "3.10"
23-
# - os: windows-latest
24-
# python-version: "3.x"
25-
# - os: macos-latest # scipy deps issues
26-
# python-version: "3.10"
27-
# - os: macos-latest
28-
# python-version: "3.x"
18+
os: [ubuntu-22.04, ubuntu-24.04, macos-latest, windows-latest]
19+
python-version: ["3.10", 3.11, 3.12, 3.x] # crons should always run latest python hence 3.x
2920
fail-fast: false
3021

3122
steps:
@@ -35,9 +26,12 @@ jobs:
3526
uses: actions/setup-python@v5
3627
with:
3728
python-version: ${{ matrix.python-version }}
38-
cache: pip
29+
cache: 'pip'
3930
cache-dependency-path: '**/pyproject.toml'
4031

32+
- name: Upgrade pip, setuptools and wheel
33+
run: python -m pip install --upgrade pip setuptools wheel
34+
4135
- name: Install package with test dependencies
4236
run: python -m pip install ".[test]"
4337

.github/workflows/docker.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,29 @@ jobs:
2121
uses: actions/checkout@v4
2222

2323
- name: Set up QEMU
24-
uses: docker/setup-qemu-action@v2
24+
uses: docker/setup-qemu-action@v3
2525

2626
- name: Set up Docker Buildx
2727
id: buildx
28-
uses: docker/setup-buildx-action@v2
28+
uses: docker/setup-buildx-action@v3
2929

3030
- name: Cache Docker layers
31-
uses: actions/cache@v3
31+
uses: actions/cache@v4
3232
with:
3333
path: /tmp/.buildx-cache
3434
key: ${{ runner.os }}-buildx-${{ github.sha }}
3535
restore-keys: |
3636
${{ runner.os }}-buildx-
3737
3838
- name: Login to Docker Hub
39-
uses: docker/login-action@v2
39+
uses: docker/login-action@v3
4040
with:
4141
username: ${{ secrets.DOCKERHUB_ID }}
4242
password: ${{ secrets.DOCKERHUB_TOKEN }}
4343

4444
- name: Build and push image
4545
id: docker_build
46-
uses: docker/build-push-action@v4
46+
uses: docker/build-push-action@v6
4747
with:
4848
context: ./
4949
file: ./docker/Dockerfile

.github/workflows/documentation.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@ on: # Runs on any push event in a PR or any push event to master
1313

1414
jobs:
1515
documentation:
16-
name: ${{ matrix.os }} / ${{ matrix.python-version }}
17-
runs-on: ${{ matrix.os }}
18-
strategy:
19-
matrix:
20-
os: [ubuntu-latest]
21-
python-version: [3.11]
16+
runs-on: ubuntu-latest
17+
env:
18+
python-version: 3.12
2219

2320
steps:
2421
- uses: actions/checkout@v4
@@ -32,38 +29,43 @@ jobs:
3229
- name: Install optipng, dvipng and cm-super
3330
run: sudo apt-get install -y optipng dvipng cm-super
3431

35-
- name: Get acc-models-lhc
36-
run: git clone -b 2022 https://gitlab.cern.ch/acc-models/acc-models-lhc.git --depth 1
37-
38-
- name: Move acc-models-lhc to examples folder
39-
run: mv acc-models-lhc examples/
40-
41-
- name: Set up Python ${{ matrix.python-version }}
32+
- name: Set up Python ${{ env.python-version }}
4233
uses: actions/setup-python@v5
4334
with:
44-
python-version: ${{ matrix.python-version }}
45-
cache: pip
35+
python-version: ${{ env.python-version }}
36+
cache: 'pip'
4637
cache-dependency-path: '**/pyproject.toml'
4738

39+
- name: Upgrade pip, setuptools and wheel
40+
run: python -m pip install --upgrade pip setuptools wheel
41+
4842
- name: Install package with doc dependencies
4943
run: python -m pip install ".[docs]"
5044

45+
- name: Get acc-models-lhc
46+
run: git clone -b 2022 https://gitlab.cern.ch/acc-models/acc-models-lhc.git --depth 1
47+
48+
- name: Move acc-models-lhc to examples folder
49+
run: mv acc-models-lhc examples/
50+
5151
- name: Build documentation
5252
continue-on-error: true
5353
run: make docs
5454

5555
# Upload artifacts if in PR so reviewers can have a quick look without building documentation from the branch locally
5656
- name: Upload build artifacts
57-
uses: actions/upload-artifact@v3
57+
uses: actions/upload-artifact@v4
5858
if: success() && github.event_name == 'pull_request' # only for pushes in PR
5959
with:
6060
name: site-build
6161
path: doc_build
62-
retention-days: 7
62+
retention-days: 5
6363

6464
# Upload the doc to github pages branch and publish if from a push to master
6565
- name: Upload documentation to gh-pages
6666
if: success() && github.ref == 'refs/heads/master' # only for pushes to master
6767
uses: JamesIves/github-pages-deploy-action@v4
6868
with:
69+
token: ${{ secrets.GITHUB_TOKEN }}
70+
branch: gh-pages
6971
folder: doc_build

.github/workflows/publish.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@ on: # Runs everytime a release is added to the repository
1111

1212
jobs:
1313
deploy:
14-
name: ${{ matrix.os }} / ${{ matrix.python-version }}
15-
runs-on: ${{ matrix.os }}
16-
strategy:
17-
matrix: # only lowest supported python on ubuntu-latest
18-
os: [ubuntu-latest]
19-
python-version: [3.11]
14+
runs-on: ubuntu-latest
15+
env:
16+
python-version: 3.12
2017

2118

2219
steps:
@@ -32,5 +29,5 @@ jobs:
3229
uses: pypa/gh-action-pypi-publish@release/v1
3330
with:
3431
verbose: true
35-
print_hash: true
32+
print-hash: true
3633
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ on: # Runs on any push event to any branch except master (the coverage workflow
1010
- 'master'
1111

1212
jobs:
13-
quick_tests: # fails here if flaky tests
13+
quick_tests:
1414
name: ${{ matrix.os }} / ${{ matrix.python-version }}
1515
runs-on: ${{ matrix.os }}
1616
strategy:
1717
matrix:
18-
os: [ubuntu-22.04, macos-latest, windows-latest]
19-
python-version: [3.8, 3.9, "3.10", 3.11, 3.12]
18+
os: [ubuntu-22.04, ubuntu-24.04, macos-latest, windows-latest]
19+
python-version: ["3.10", 3.11, 3.12]
2020
fail-fast: false
2121

2222
steps:
@@ -41,8 +41,8 @@ jobs:
4141
runs-on: ${{ matrix.os }}
4242
strategy:
4343
matrix:
44-
os: [ubuntu-22.04, macos-latest, windows-latest]
45-
python-version: [3.8, 3.9, "3.10", 3.11, 3.12]
44+
os: [ubuntu-22.04, ubuntu-24.04, macos-latest, windows-latest]
45+
python-version: ["3.10", 3.11, 3.12]
4646
fail-fast: false
4747

4848
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,5 +253,6 @@ Temporary Items
253253
doc_build/
254254
docs/gallery/
255255
docs/gen_modules/
256+
docs/sg_execution_times.rst
256257

257258
acc-models-lhc/

docs/api/optics.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Optics
66
.. automodule:: pyhdtoolkit.optics.beam
77
:members:
88

9+
.. automodule:: pyhdtoolkit.optics.rdt
10+
:members:
11+
912
.. automodule:: pyhdtoolkit.optics.ripken
1013
:members:
1114

docs/conf.py

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
import sys
1515
import warnings
1616

17-
from sphinx_gallery.scrapers import matplotlib_scraper
18-
from sphinx_gallery.sorting import ExampleTitleSortKey
19-
2017
import pyhdtoolkit
2118

2219
# ignore numpy warnings, see:
@@ -28,7 +25,7 @@
2825
warnings.filterwarnings(
2926
"ignore",
3027
category=UserWarning,
31-
message="Matplotlib is currently using agg, which is a" " non-GUI backend, so cannot show the figure.",
28+
message="Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.",
3229
)
3330

3431
TOPLEVEL_DIR = pathlib.Path(__file__).parent.parent.absolute()
@@ -41,14 +38,6 @@
4138
# See: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#confval-autodoc_type_aliases
4239
autodoc_type_aliases = {"ArrayLike": "ArrayLike"}
4340

44-
# To use SVG outputs when scraping matplotlib figures for the sphinx-gallery
45-
class matplotlib_svg_scraper(object):
46-
def __repr__(self):
47-
return self.__class__.__name__
48-
49-
def __call__(self, *args, **kwargs):
50-
return matplotlib_scraper(*args, format="svg", **kwargs)
51-
5241

5342
# -- Project information -----------------------------------------------------
5443

@@ -145,7 +134,8 @@ def __call__(self, *args, **kwargs):
145134
"sphinx_copybutton", # Add a "copy" button to code blocks
146135
"sphinx_gallery.gen_gallery", # Build an HTML gallery of examples from a set of Python scripts
147136
"sphinx_issues", # Link to project's issue tracker
148-
"sphinx_panels", # Create panels in a grid layout or as drop-downs
137+
# "sphinx_panels", # Create panels in a grid layout or as drop-downs
138+
"sphinx_design", # successor to sphinx_panels, for grid layouts and drop-downs
149139
"matplotlib.sphinxext.plot_directive", # Include a Matplotlib plot in a Sphinx document
150140
"sphinx-prompt", # prompt symbols will not be copy-pastable
151141
"sphinx_codeautolink", # Automatically link example code to documentation source
@@ -176,19 +166,16 @@ def __call__(self, *args, **kwargs):
176166
"examples_dirs": ["../examples"], # directory where to find plotting scripts
177167
"gallery_dirs": ["gallery"], # directory where to store generated plots
178168
"filename_pattern": "^((?!sgskip).)*$", # which files to execute, taken from matplotlib
179-
"subsection_order": ExampleTitleSortKey,
180-
"within_subsection_order": ExampleTitleSortKey,
181-
"reference_url": {"pyhdtoolkit": None}, # Sets up intersphinx in gallery code
182169
"backreferences_dir": "gen_modules/backreferences", # where function/class granular galleries are stored
183170
# Modules for which function/class level galleries are created
184171
"doc_module": "pyhdtoolkit",
185-
"image_scrapers": (matplotlib_svg_scraper(),), # scrape gallery as SVG
172+
"image_scrapers": ("pyhdtoolkit.plotting.utils._matplotlib_svg_scraper",), # scrape gallery as SVG
186173
"image_srcset": ["2x"], # use srcset twice as dense for high-resolution images display
187174
"min_reported_time": 2, # minimum execution time to enable reporting
188175
"remove_config_comments": True, # remove config comments from the code
189176
"capture_repr": ("_repr_html_",),
190177
"compress_images": ("images", "thumbnails", "-o1"),
191-
"only_warn_on_example_error": True, # keep the build going if an example fails, very important for doc workflow
178+
"only_warn_on_example_error": True, # keep the build going if an example fails, important for doc workflow
192179
}
193180

194181
# Config for the sphinx_panels extension
@@ -352,9 +339,7 @@ def __call__(self, *args, **kwargs):
352339
# Font configuration
353340
# Fix fontspec converting " into right curly quotes in PDF
354341
# cf https://github.com/sphinx-doc/sphinx/pull/6888/
355-
latex_elements[
356-
"fontenc"
357-
] = r"""
342+
latex_elements["fontenc"] = r"""
358343
\usepackage{fontspec}
359344
\defaultfontfeatures[\rmfamily,\sffamily,\ttfamily]{}
360345
"""
@@ -406,9 +391,7 @@ def __call__(self, *args, **kwargs):
406391

407392

408393
# Additional stuff for the LaTeX preamble.
409-
latex_elements[
410-
"preamble"
411-
] = r"""
394+
latex_elements["preamble"] = r"""
412395
% Show Parts and Chapters in Table of Contents
413396
\setcounter{tocdepth}{0}
414397
% One line per author on title page

0 commit comments

Comments
 (0)