Skip to content

Commit 4d1272e

Browse files
authored
Maintenance Update (#5)
- Updated `README.md` with note for devs - Updated package to `pyproject.toml` - Updated Sphinx to `9.0.0` and RTD Theme to `3.1.0` - Updated links in csv which were breaking in doc to their DOI - Added notes on how to install script requirements with `uv`
1 parent 2851030 commit 4d1272e

File tree

13 files changed

+285
-181
lines changed

13 files changed

+285
-181
lines changed
Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Build documentation
2+
# The build is uploaded as artifact if the triggering event is a push for a pull request
3+
# The build is published to github pages if the triggering event is a push to the master branch (PR merge)
24
name: Build and upload documentation
35

4-
defaults:
5-
run:
6-
shell: bash
7-
86
on: # Runs on any push event in a PR or any push event to master
97
pull_request:
108
push:
@@ -13,48 +11,4 @@ on: # Runs on any push event in a PR or any push event to master
1311

1412
jobs:
1513
documentation:
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.9]
22-
23-
steps:
24-
- uses: actions/checkout@v3
25-
26-
- name: Install LaTeX
27-
run: sudo apt-get install -y texlive-latex-base # texlive-fonts-extra texlive-fonts-recommended texlive-latex-extra texlive-latex-recommended ghostscript
28-
29-
- name: Install optipng
30-
run: sudo apt-get install -y optipng
31-
32-
- name: Set up Python ${{ matrix.python-version }}
33-
uses: actions/setup-python@v4
34-
with:
35-
python-version: ${{ matrix.python-version }}
36-
37-
- name: Upgrade pip
38-
run: python -m pip install --upgrade pip
39-
40-
- name: Install dependencies
41-
run: python -m pip install -r doc/requirements.txt
42-
43-
- name: Build documentation
44-
run: python -m sphinx -v -b html doc doc_build -d doc_build
45-
46-
- name: Upload build artifacts # upload artifacts so reviewers can have a quick look without building documentation from the branch locally
47-
if: success() && github.event_name == 'pull_request' # only for pushes in PR
48-
uses: actions/upload-artifact@v3
49-
with:
50-
name: site-build
51-
path: doc_build
52-
retention-days: 5
53-
54-
- name: Upload documentation to gh-pages
55-
if: success() && github.ref == 'refs/heads/master' # only for pushes to master
56-
uses: JamesIves/github-pages-deploy-action@v4
57-
with:
58-
token: ${{ secrets.GITHUB_TOKEN }}
59-
branch: gh-pages
60-
folder: doc_build
14+
uses: pylhc/.github/.github/workflows/documentation.yml@master

README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,44 @@
44
[![GitHub release](https://img.shields.io/github/release/pylhc/accelerator_timeline.svg?style=popout)](https://github.com/pylhc/accelerator_timeline/)
55
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8316137.svg)](https://doi.org/10.5281/zenodo.8316137)
66

7-
In this package, the main parameters of major historical, modern and possible future accelerators are
7+
In this package, the main parameters of major historical, modern and possible future accelerators are
88
collected, including references to the origin of the collected data, into a single csv:
99

10-
- [accelerator-parameters.csv](accelerator-parameters.csv).
10+
- [accelerator-parameters.csv](accelerator-parameters.csv).
1111

12-
13-
14-
## Installation
12+
## Installation
1513

1614
This package is mostly for collecting and sharing the data of the accelerators within
17-
the CSV file.
15+
the CSV file.
1816

19-
20-
To get the data, either download the [accelerator-parameters.csv](accelerator-parameters.csv) directly,
17+
To get the data, either download the [accelerator-parameters.csv](accelerator-parameters.csv) directly,
2118
or clone the repository via `git`, e.g.::
2219

23-
```
20+
```bash
2421
git clone https://github.com/pylhc/accelerator_timeline.git
2522
```
2623

2724
## Example Scripts
2825

2926
In addition, small python scripts are provided to explore the data via and create Livingston-like plots.
3027
These charts are available interactively at:
31-
32-
- [pylhc.github.io/accelerator_timeline](https://pylhc.github.io/accelerator_timeline).
28+
29+
- [pylhc.github.io/accelerator_timeline](https://pylhc.github.io/accelerator_timeline).
3330

3431
The python code itself can be found at
3532

36-
- [interactive_charts.py](interactive_charts.py), creating the interactive charts via plotly.
37-
- [export_charts.py](export_charts.py), making publication-grade exports to pdf via matplotlib.
33+
- [interactive_charts.py](interactive_charts.py), creating the interactive charts via plotly.
34+
- [export_charts.py](export_charts.py), making publication-grade exports to pdf via matplotlib.
3835

3936
The requirements for the scripts can be found in the respective `requirements_*.txt` file.
4037

4138
![Center of Mass](images/energy.png)
4239
![Luminosity](images/luminosity.png)
4340
![LuminosityVsEnergy](images/luminosity-vs-energy.png)
41+
42+
## Note for Developers
43+
44+
Updating the data in the CSV will automatically update the charts in the
45+
[pylhc.github.io/accelerator_timeline](https://pylhc.github.io/accelerator_timeline) website via GitHub Actions.
46+
The pictures in the `images/` folder (which are also linked in this `README`) are **not** automatically generated
47+
and need to be updated manually by running the `export_charts.py` script and committing the changes.

accelerator-parameters.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ FCC-ee WW,CERN,Switzerland,2043*,,e+e-,80,,2.8E+035,97750,https://journals.aps.o
4343
FCC-ee ZH,CERN,Switzerland,2045*,,e+e-,120,,8.5E+034,97750,https://journals.aps.org/rmp/pdf/10.1103/RevModPhys.93.015006 https://doi-org.ezproxy.cern.ch/10.1140/epjst/e2019-900045-4
4444
FCC-ee ttbar,CERN,Switzerland,2049*,,e+e-,182.5,,1.55E+034,97750,https://journals.aps.org/rmp/pdf/10.1103/RevModPhys.93.015006 https://doi-org.ezproxy.cern.ch/10.1140/epjst/e2019-900045-4
4545
FCC-hh,CERN,Switzerland,2070*,,p+p+,50000,,3E+035,97750,https://journals.aps.org/rmp/pdf/10.1103/RevModPhys.93.015006
46-
CEPC,IHEP,China,2035*,,e+e-,45.5,,3.2E+035,100000,https://journals.aps.org/rmp/pdf/10.1103/RevModPhys.93.015006 https://arxiv.org/abs/1809.00285 https://www.researchgate.net/publication/359254433_Snowmass_2021_White_Paper_AF4_-_SPPC
47-
SppC,IHEP,China,2050*,,p+p+,37500,,1E+035,100000,https://journals.aps.org/rmp/pdf/10.1103/RevModPhys.93.015006 https://www.researchgate.net/publication/359254433_Snowmass_2021_White_Paper_AF4_-_SPPC
46+
CEPC,IHEP,China,2035*,,e+e-,45.5,,3.2E+035,100000,https://journals.aps.org/rmp/pdf/10.1103/RevModPhys.93.015006 https://arxiv.org/abs/1809.00285 https://doi.org/10.48550/arXiv.2203.07987
47+
SppC,IHEP,China,2050*,,p+p+,37500,,1E+035,100000,https://journals.aps.org/rmp/pdf/10.1103/RevModPhys.93.015006 https://doi.org/10.48550/arXiv.2203.07987
4848
ILC v1,Fermilab,USA,2035*,,e+e-,125,,1.35E+034,20500,https://journals.aps.org/rmp/pdf/10.1103/RevModPhys.93.015006 https://arxiv.org/pdf/1901.09829.pdf
4949
ILC v2,Fermilab,USA,2040*,,e+e-,250,,1.8E+034,31000,https://journals.aps.org/rmp/pdf/10.1103/RevModPhys.93.015006 https://arxiv.org/pdf/1901.09829.pdf
5050
ILC v3,Fermilab,USA,2045*,,e+e-,500,,4.9E+034,40000,https://journals.aps.org/rmp/pdf/10.1103/RevModPhys.93.015006 https://arxiv.org/pdf/1901.09829.pdf

doc/Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ html:
5151
@echo
5252
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
5353

54-
josch:
55-
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) ../../Documentation/accelerator_timeline-doc
56-
@echo
57-
@echo "Build finished. The HTML pages are in ../../Documentation/accelerator_timeline-doc."
58-
5954
dirhtml:
6055
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
6156
@echo

doc/_static/css/custom.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
:root {
2-
--nav-side-width: 300px; /* default is 300px */
2+
--nav-side-width: 250px; /* default is 300px */
33
/* for 100% width */
44
/*--nav-content-width: 100%;*/
55
/*--local-toc-width: 300px;*/
66
/*--nav-content-width-wide: calc(100% - var(--local-toc-width)); /* 100% here is fullscreen */
77
/*--local-toc-left: calc(100% - var(--local-toc-width)); /* 100% here is w/o sidebar */
88

99
/* for fixed widths */
10-
--nav-content-width: 800px; /* default is 800px */
10+
--nav-content-width: 1000px; /* default is 800px */
1111
--nav-content-width-wide: var(--nav-content-width);
1212
--local-toc-width: calc(100% - var(--nav-content-width-wide));
1313
--local-toc-left: calc(var(--nav-content-width-wide) + var(--nav-side-width));
@@ -57,7 +57,7 @@
5757
border: none;
5858
}
5959

60-
/* Hide the first two entries (combined in the first <ul>) of the nav-bar,
60+
/* Hide the first two entries (combined in the first <ul>) of the nav-bar,
6161
as they are coming from the included gallery */
6262

6363
.wy-menu-vertical ul:nth-child(-n + 1) {
@@ -198,7 +198,7 @@ em.sig-param span.default_value {
198198

199199

200200
/* Format Tables
201-
Not sure why the following were in the css,
201+
Not sure why the following were in the css,
202202
but some of them break the csv table formatting.
203203
I left those in, that looked good.
204204
*/

doc/conf.py

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
1-
# Configuration file for the Sphinx documentation builder.
2-
#
3-
# This file only contains a selection of the most common options. For a full
4-
# list see the documentation:
5-
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6-
7-
# -- Path setup --------------------------------------------------------------
8-
9-
# If extensions (or modules to document with autodoc) are in another directory,
10-
# add these directories to sys.path here. If the directory is relative to the
11-
# documentation root, use os.path.abspath to make it absolute, like shown here.
12-
13-
import pathlib
141
import os
2+
import pathlib
153
import shutil
164
import sys
175
import warnings
6+
from functools import partial
187

8+
# -- Filter Warnings -----------------------------------------------------------
199
# ignore numpy warnings, see:
2010
# https://stackoverflow.com/questions/40845304/runtimewarning-numpy-dtype-size-changed-may-indicate-binary-incompatibility
2111
warnings.filterwarnings("ignore", message="numpy.dtype size changed")
@@ -25,9 +15,17 @@
2515
warnings.filterwarnings(
2616
"ignore",
2717
category=UserWarning,
28-
message="Matplotlib is currently using agg, which is a" " non-GUI backend, so cannot show the figure.",
18+
message="Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.",
2919
)
3020

21+
# suppress Sphinx cache-related warnings
22+
suppress_warnings = ["config.cache"]
23+
24+
# -- Path setup ---------------------------------------------------------------
25+
26+
# If extensions (or modules to document with autodoc) are in another directory,
27+
# add these directories to sys.path here. If the directory is relative to the
28+
# documentation root, use os.path.abspath to make it absolute, like shown here.
3129

3230
TOPLEVEL_DIR = pathlib.Path(__file__).parent.parent.absolute()
3331
ABOUT_FILE = TOPLEVEL_DIR / "__init__.py"
@@ -39,14 +37,16 @@
3937
with ABOUT_FILE.open("r") as f:
4038
exec(f.read(), ABOUT_accelerator_timeline)
4139

40+
41+
# -- Accelerator Timeline specific setup ---------------------------------------
4242
# Set environment variable for scripts to check if we are in sphinx-mode
43-
from utilities.sphinx_helper import SPHINX_BUILD_ENVIRON
44-
os.environ[SPHINX_BUILD_ENVIRON] = '1'
43+
from utilities.sphinx_helper import SPHINX_BUILD_ENVIRON # noqa: E402
4544

45+
os.environ[SPHINX_BUILD_ENVIRON] = '1'
4646

4747
# Copy accelerator data file
4848
shutil.copy2(
49-
TOPLEVEL_DIR / "accelerator-parameters.csv",
49+
TOPLEVEL_DIR / "accelerator-parameters.csv",
5050
TOPLEVEL_DIR / "doc" / "accelerator-parameters.csv"
5151
)
5252

@@ -69,7 +69,7 @@
6969

7070
# General information about the project.
7171
project = ABOUT_accelerator_timeline["__title__"]
72-
copyright_ = '2019-2023, pyLHC/OMC-TEAM'
72+
copyright_ = '2019-2025, pyLHC/OMC-TEAM'
7373
author = ABOUT_accelerator_timeline["__author__"]
7474

7575
rst_prolog = f"""
@@ -113,7 +113,7 @@
113113
# List of patterns, relative to source directory, that match files and
114114
# directories to ignore when looking for source files.
115115
# This patterns also effect to html_static_path and html_extra_path
116-
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "docs", "docker", "tests", ".github", ".vscode"]
116+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "docs", "docker", "tests", ".github", ".vscode", ".venv"]
117117

118118
# The reST default role (used for this markup: `text`) to use for all
119119
# documents.
@@ -189,33 +189,29 @@
189189
# bibtex_reference_style = "label"
190190

191191
# -- Setup scrapers for the gallery ------------------------------------------
192-
from plotly.io._sg_scraper import plotly_sg_scraper
193-
import plotly.io as pio
192+
import plotly.io as pio # noqa: E402
193+
from plotly.io._sg_scraper import plotly_sg_scraper # noqa: E402
194+
194195
pio.renderers.default = 'sphinx_gallery'
195196

196197
# To use SVG outputs when scraping matplotlib figures for the sphinx-gallery
197-
from sphinx_gallery.scrapers import matplotlib_scraper
198-
from sphinx_gallery.sorting import ExampleTitleSortKey
199-
class matplotlib_svg_scraper(object):
200-
def __repr__(self):
201-
return self.__class__.__name__
202-
203-
def __call__(self, *args, **kwargs):
204-
return matplotlib_scraper(*args, format="svg", **kwargs)
198+
from sphinx_gallery.scrapers import matplotlib_scraper # noqa: E402
199+
from sphinx_gallery.sorting import ExampleTitleSortKey # noqa: E402
205200

206201
# Config for the matplotlib plot directive
207202
plot_formats = [("svg", 250)]
208203

209204
# image_scrapers = (matplotlib_svg_scraper(), plotly_sg_scraper,)
210-
image_scrapers = (matplotlib_svg_scraper(),)
205+
image_scrapers = (partial(matplotlib_scraper, format="svg"), plotly_sg_scraper)
211206

212207
# -- Configuration for the sphinx-gallery extension -------------------------------
208+
213209
sphinx_gallery_conf = {
214-
"examples_dirs": ["../"], # directory where to find plotting scripts
210+
"examples_dirs": [TOPLEVEL_DIR], # directory where to find plotting scripts
215211
"gallery_dirs": ["gallery"], # directory where to store generated plots
216212
"filename_pattern": "^((?!sgskip).)*$", # which files to execute
217-
"subsection_order": ExampleTitleSortKey,
218-
"within_subsection_order": ExampleTitleSortKey,
213+
"subsection_order": ExampleTitleSortKey(TOPLEVEL_DIR),
214+
"within_subsection_order": ExampleTitleSortKey(TOPLEVEL_DIR),
219215
"reference_url": {"accelerator_timeline": None}, # Sets up intersphinx in gallery code
220216
"backreferences_dir": "gen_modules/backreferences", # where function/class granular galleries are stored
221217
# Modules for which function/class level galleries are created
@@ -228,6 +224,7 @@ def __call__(self, *args, **kwargs):
228224
"compress_images": ("images", "thumbnails", "-o1"),
229225
"only_warn_on_example_error": True, # keep the build going if an example fails, very important for doc workflow
230226
"download_all_examples": False,
227+
"ignore_pattern": r"^(tst_|_|\.).*", # ignore test/private files
231228
}
232229

233230
# Config for the sphinx_panels extension
@@ -247,8 +244,8 @@ def __call__(self, *args, **kwargs):
247244
# documentation.
248245
html_theme_options = {
249246
"collapse_navigation": False,
250-
"display_version": True,
251247
"logo_only": True,
248+
"version_selector": True,
252249
"navigation_depth": 2,
253250
}
254251

@@ -547,7 +544,7 @@ def __call__(self, *args, **kwargs):
547544
# -- Autodoc Configuration ---------------------------------------------------
548545

549546
# Add here all modules to be mocked up. When the dependencies are not met
550-
# at building time.
547+
# at building time.
551548
autodoc_mock_imports = []
552549

553550
# -- Instersphinx Configuration ----------------------------------------------

doc/requirements.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)