Skip to content

Commit 996ead9

Browse files
BilchreisPeter Braun
andauthored
Sphinx docs (#45)
* pages cicd * pages publish correct permissions * pages publish split into two jobs * cicd fix: removed uneccecary deploy step * only deploy pages on master branch updates --------- Co-authored-by: Peter Braun <[email protected]>
1 parent 7898d1e commit 996ead9

File tree

6 files changed

+263
-9
lines changed

6 files changed

+263
-9
lines changed

.github/workflows/code.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,64 @@ jobs:
5454
run: |
5555
uv run pytest tests/ -v
5656
57+
build-pages:
58+
if: github.ref == 'refs/heads/master'
59+
permissions:
60+
contents: read
61+
pages: write
62+
id-token: write
63+
runs-on: ubuntu-latest
64+
65+
66+
strategy:
67+
matrix:
68+
python-version: ["3.12"]
69+
fail-fast: false
70+
71+
steps:
72+
73+
- name: Set env.REPOSITORY_NAME # just the repo, as opposed to org/repo
74+
shell: bash -l {0}
75+
run: |
76+
export REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}
77+
echo "REPOSITORY_NAME=${REPOSITORY_NAME}" >> $GITHUB_ENV
78+
79+
- uses: actions/checkout@v4
80+
81+
- name: Install uv and set the python version
82+
uses: astral-sh/setup-uv@v6
83+
with:
84+
python-version: ${{ matrix.python-version }}
85+
86+
- name: Install secop-ophyd with all deps
87+
run: uv sync --all-extras
88+
89+
- name: Build Docs
90+
shell: bash -l {0}
91+
run: uv run make -C docs/ html
92+
93+
- name: Upload
94+
uses: actions/upload-pages-artifact@v3
95+
with:
96+
path: ./docs/build/html
97+
98+
# Deployment job
99+
deploy-pages:
100+
if: github.ref == 'refs/heads/master'
101+
permissions:
102+
contents: read
103+
pages: write
104+
id-token: write
105+
environment:
106+
name: github-pages
107+
url: ${{ steps.deployment.outputs.page_url }}
108+
runs-on: ubuntu-latest
109+
needs: build-pages
110+
steps:
111+
- name: Deploy to GitHub Pages
112+
id: deployment
113+
uses: actions/deploy-pages@v4
114+
57115

58116
build:
59117
name: Build distribution 📦

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ repos:
1515
rev: 6.1.0
1616
hooks:
1717
- id: flake8
18+
exclude: ^docs/
1819

1920
- repo: https://github.com/PyCQA/isort
2021
rev: 6.0.1
@@ -36,4 +37,4 @@ repos:
3637
hooks:
3738
- id: mypy
3839
args: [--config-file=.mypy.ini]
39-
exclude: ^cfg/
40+
exclude: ^(cfg/|docs/)

docs/source/conf.py

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,26 @@
66
# -- Project information -----------------------------------------------------
77
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
88

9-
project = "SECoP-Ophyd"
10-
copyright = "2024, Peter Wegmann"
11-
author = "Peter Wegmann"
12-
release = "0.0"
139

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

1713
extensions = [
18-
"sphinx.ext.duration",
19-
"sphinx.ext.doctest",
2014
"sphinx.ext.autodoc",
15+
"sphinx.ext.autosummary",
16+
"sphinx.ext.githubpages",
17+
"sphinx.ext.intersphinx",
18+
"sphinx.ext.mathjax",
19+
"sphinx.ext.viewcode",
20+
"IPython.sphinxext.ipython_directive",
21+
"IPython.sphinxext.ipython_console_highlighting",
22+
"matplotlib.sphinxext.plot_directive",
23+
"numpydoc",
24+
"sphinx_click",
25+
"sphinx_copybutton",
26+
"myst_parser",
27+
"sphinxcontrib.jquery",
28+
"sphinxcontrib.mermaid",
2129
]
2230

2331
templates_path = ["_templates"]
@@ -28,3 +36,31 @@
2836

2937
html_theme = "alabaster"
3038
html_static_path = ["_static"]
39+
40+
41+
# Generate the API documentation when building
42+
autosummary_generate = True
43+
numpydoc_show_class_members = False
44+
45+
source_suffix = ".rst"
46+
47+
master_doc = "index"
48+
49+
import secop_ophyd
50+
51+
project = "SECoP-Ophyd"
52+
copyright = "2024, Peter Braun"
53+
author = "Peter Braun"
54+
release = secop_ophyd.__version__
55+
version = secop_ophyd.__version__
56+
57+
language = "en"
58+
59+
60+
# -- Options for HTML output ----------------------------------------------
61+
62+
# The theme to use for HTML and HTML Help pages. See the documentation for
63+
# a list of builtin themes.
64+
#
65+
html_theme = "sphinx_rtd_theme"
66+
import sphinx_rtd_theme

pyproject.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ dev = [
4040
'mlzlog',
4141
'python-dotenv',
4242
'bluesky',
43-
'sphinx',
43+
"sphinx !=4.1.0, !=4.1.1, !=4.1.2, !=4.2.0",
44+
"sphinx-click",
45+
"sphinx-copybutton",
46+
"sphinx_rtd_theme",
47+
"sphinxcontrib-mermaid",
48+
"myst-parser",
49+
"numpydoc",
4450
'snakefmt'
4551
]
4652

src/secop_ophyd/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from ._version import __version__, __version_tuple__
2+
3+
__all__ = [
4+
"__version__",
5+
"__version_tuple__",
6+
]

uv.lock

Lines changed: 148 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)