Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9773516
feat: basic sphinx docs
APN-Pucky Jul 31, 2025
e8cb5ae
Merge branch 'main' into sphinx_doc
eduardo-rodrigues Aug 13, 2025
450cd18
Fix sphinx warnings
APN-Pucky Aug 21, 2025
c05d38f
copy .readthedocs.yaml from pyhf
APN-Pucky Aug 21, 2025
097e795
Sort examples by number prefix
APN-Pucky Aug 21, 2025
78dde2f
Use rtd theme
APN-Pucky Aug 21, 2025
0af57d3
Add citations to Readme.md
APN-Pucky Aug 21, 2025
a44ce7e
Add modified docs.yml CI workflow from pyhf
APN-Pucky Aug 21, 2025
d864f6b
more docstrings and typing
APN-Pucky Aug 21, 2025
d3a07d9
comment all functions but __init__ (which are to-be removed in 1.0.0)
APN-Pucky Aug 21, 2025
660b1ec
Explicit list selected D1 group
APN-Pucky Aug 21, 2025
5fb46c5
update pyproject.toml docs
APN-Pucky Aug 21, 2025
36bfcdd
Implicit use of myst-parser extension by myst-nb
APN-Pucky Aug 21, 2025
61f8849
Make html without doctest run on readme
APN-Pucky Aug 21, 2025
2fb98f8
linkcheck ignore allcontributors
APN-Pucky Aug 21, 2025
0885907
Merge branch 'main' into sphinx_doc
APN-Pucky Aug 21, 2025
66e79d1
Also list pylhe.awkward module
APN-Pucky Aug 21, 2025
6379fe8
Merge branch 'main' into sphinx_doc
eduardo-rodrigues Aug 29, 2025
5c2d48b
Merge branch 'main' into sphinx_doc
APN-Pucky Sep 2, 2025
c899f1e
Update src/pylhe/__init__.py
APN-Pucky Sep 2, 2025
413beaa
Update src/pylhe/__init__.py
APN-Pucky Sep 2, 2025
31f57bf
Update src/pylhe/__init__.py
APN-Pucky Sep 2, 2025
747976a
Merge branch 'main' into sphinx_doc
APN-Pucky Sep 2, 2025
a43d58c
List publications starting with the most recent ones
eduardo-rodrigues Sep 2, 2025
a240b46
Update .github/workflows/docs.yml
APN-Pucky Sep 2, 2025
25fe2e9
Update src/pylhe/__init__.py
APN-Pucky Sep 2, 2025
57b3bbc
Update src/pylhe/__init__.py
APN-Pucky Sep 2, 2025
883eeec
Update src/pylhe/__init__.py
APN-Pucky Sep 2, 2025
05d3029
Update src/pylhe/awkward.py
APN-Pucky Sep 2, 2025
6045346
Update src/pylhe/__init__.py
APN-Pucky Sep 2, 2025
89062da
Update src/pylhe/__init__.py
APN-Pucky Sep 2, 2025
b945d03
Update src/pylhe/__init__.py
APN-Pucky Sep 2, 2025
2349da5
Update src/pylhe/__init__.py
APN-Pucky Sep 2, 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
102 changes: 102 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Docs

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
build:
name: Build docs
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install Python dependencies
run: |
python -m pip install uv
uv pip --quiet install --system --upgrade ".[docs,test]"
uv pip install --system yq
python -m pip list

- name: Install apt-get dependencies
run: |
sudo apt-get update
# Ubuntu 22.04's pandoc is too old (2.9.2.x), so install manually
# until the ubuntu-latest updates.
curl --silent --location --remote-name https://github.com/jgm/pandoc/releases/download/3.1.6.2/pandoc-3.1.6.2-1-amd64.deb
sudo apt-get install ./pandoc-*amd64.deb

- name: Check docstrings
run: |
# ignore D107 missing comment for __init__, since starting from 1.0.0 there are no more __init__ functions
pydocstyle --select=D100,D101,D102,D103,D104,D105,D106 src/pylhe/

- name: Verify CITATION.cff schema
run: |
jsonschema <(curl -sL "https://citation-file-format.github.io/1.2.0/schema.json") --instance <(cat CITATION.cff | yq)

- name: Check for broken links
run: |
pushd docs
make linkcheck
# Don't ship the linkcheck
rm -r build/linkcheck
popd

- name: Build docs
run: |
pushd docs
make html

- name: Fix permissions if needed
run: |
chmod -c -R +rX "docs/build/html/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'docs/build/html'

deploy:
name: Deploy docs to GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: build
# Set permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest

steps:
- name: Setup Pages
uses: actions/configure-pages@v5

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ config.rst
.pytest_cache
htmlcov
.benchmarks

docs/source/_autosummary
docs/source/examples/*.lhe
docs/source/examples/*.lhe.gz
29 changes: 29 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"
apt_packages:
- curl
- jq
jobs:
post_create_environment:
- pip install uv
post_install:
# VIRTUAL_ENV needs to be set manually for now.
# See https://github.com/readthedocs/readthedocs.org/pull/11152/
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv pip install '.[docs]'

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# If using Sphinx, optionally build your docs in additional formats such as PDF and ePub
formats: all
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pylhe: Python LHE interface

<img src="https://raw.githubusercontent.com/scikit-hep/pylhe/main/docs/_static/img/pylhe-logo.png" alt="pylhe logo" width="250"/>
<img src="https://raw.githubusercontent.com/scikit-hep/pylhe/main/docs/source/_static/img/pylhe-logo.png" alt="pylhe logo" width="250"/>

[![GitHub Project](https://img.shields.io/badge/GitHub--blue?style=social&logo=GitHub)](https://github.com/scikit-hep/pylhe)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1217031.svg)](https://doi.org/10.5281/zenodo.1217031)
Expand Down Expand Up @@ -75,7 +75,7 @@ event.graph.render(filename="test", format="pdf", cleanup=True)

### Writing

For a full example see [write](examples/write_monte_carlo_example.ipynb) or [filter](examples/filter_events_example.ipynb).
For a full example see [write](examples/03_write_monte_carlo_example.ipynb) or [filter](examples/02_filter_events_example.ipynb).
The values in the sketch below are intentionally left empty since they depend on the use-case.
The data structure of `pylhe` is:

Expand Down Expand Up @@ -159,6 +159,20 @@ The preferred BibTeX entry for citation of `pylhe` is
}
```

`pylhe` has been referenced in:

* [Constraints on the trilinear and quartic Higgs couplings from triple Higgs production at the LHC and beyond](https://inspirehep.net/literature/2734125) (2023)
* [BSM reach of four-top production at the LHC](https://inspirehep.net/literature/2633019) (2023)
* [Probing compressed higgsinos with forward protons at the LHC](https://inspirehep.net/literature/2140007) (2023)
* [FLArE up dark sectors with EM form factors at the LHC Forward Physics Facility](https://inspirehep.net/literature/2085195) (2022)
* [Probing Neutrino-Portal Dark Matter at the Forward Physics Facility](https://inspirehep.net/literature/1966337) (2021)
* [Looking forward to test the KOTO anomaly with FASER](https://inspirehep.net/literature/1801897) (2020)
* [Probing Light Gauge Bosons in Tau Neutrino Experiments](https://inspirehep.net/literature/1794757) (2020)
* [Benchmarking simplified template cross sections in WH production](https://inspirehep.net/literature/1750323) (2019)
* [MadMiner: Machine learning-based inference for particle physics](https://inspirehep.net/literature/1746275) (2019)
* [Search Strategy for Sleptons and Dark Matter Using the LHC as a Photon Collider](https://inspirehep.net/literature/1703804) (2018)


## Contributors

We hereby acknowledge the contributors that made this project possible ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
15 changes: 15 additions & 0 deletions docs/source/_templates/as_module.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
:mod:`{{fullname}}`
======================

.. currentmodule:: {{fullname}}


.. automodule:: {{fullname}}
:members:

.. autosummary::
{% for element in functions %}
{{element}}
{% endfor %}

.. rubric:: Functions
33 changes: 33 additions & 0 deletions docs/source/_templates/custom-class-template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{ fullname | escape | underline}}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:members:
:show-inheritance:
:inherited-members:

{% block methods %}
.. automethod:: __init__

{% if methods %}
.. rubric:: {{ _('Methods') }}

.. autosummary::
{% for item in methods %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Attributes') }}

.. autosummary::
:nosignatures:
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
52 changes: 52 additions & 0 deletions docs/source/_templates/custom-module-template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{ fullname | escape | underline}}

.. automodule:: {{ fullname }}

{% block attributes %}
{% if attributes %}
.. rubric:: Module Attributes

.. autosummary::
:toctree:
{% for item in attributes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block functions %}
{% if functions %}
.. rubric:: {{ _('Functions') }}

.. autosummary::
:toctree:
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block classes %}
{% if classes %}
.. rubric:: {{ _('Classes') }}

.. autosummary::
:toctree:
:template: custom-class-template.rst
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block exceptions %}
{% if exceptions %}
.. rubric:: {{ _('Exceptions') }}

.. autosummary::
:toctree:
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
58 changes: 58 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
import os
import re
from datetime import datetime

# we use toml to read pyproject.toml
# the python provided toml parser does not support older python versions
import toml

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
try:
info = toml.load("../../pyproject.toml")
except FileNotFoundError:
info = toml.load("pyproject.toml")
project = info["project"]["name"]
current_year = datetime.now().year
copyright = f"{current_year}, The Scikit-HEP admins"
# Handle multiple authors
authors_list = info.get("authors", [])
author_names = [a.get("name", "") for a in authors_list if "name" in a]
author = ", ".join(author_names)
version = re.sub("^", "", os.popen("git describe --tags").read().strip())
rst_epilog = f""".. |project| replace:: {project} \n\n"""

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"myst_nb",
"sphinx.ext.autodoc",
"sphinx.ext.githubpages",
"sphinx.ext.viewcode",
"sphinx.ext.mathjax",
"sphinx.ext.todo",
"sphinx.ext.doctest",
"sphinx_math_dollar",
"sphinx.ext.autosummary",
"sphinx.ext.coverage",
]
nb_execution_mode = "off"
templates_path = ["_templates"]
exclude_patterns = []

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]

# Patterns of URLs to ignore
linkcheck_ignore = [
# Currently, down or blocking
r"https?://allcontributors\.org/.*",
]
Loading