Skip to content

Commit

Permalink
Added CI for building docs
Browse files Browse the repository at this point in the history
  • Loading branch information
daurer committed Dec 18, 2024
1 parent 2d0d76d commit d0a455a
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 2 deletions.
135 changes: 135 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Documentation

on:
push:
branches:
- master

jobs:
build_docs_old:
runs-on: ubuntu-latest
steps:
- name: Checkout PtyPy Code
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
check-latest: true

- name: Setup MPI
uses: mpi4py/setup-mpi@v1
with:
mpi: mpich

- name: Install Sphinx
run: pip install sphinx

- name: Install PtyPy
run: pip install .[full]

- name: Prepare Tutorials
working-directory: doc
run: python script2rst.py

- name: Prepare Templates
working-directory: doc
run: python tmp2rst.py

- name: Prepare Parameters
working-directory: doc
run: python parameters2rst.py

- name: Set Path to Sphinx Build
run: echo "SPHINXBUILD=`which sphinx-build`" >> $GITHUB_ENV

- name: Build Sphinx Documentation
working-directory: doc
run: make html

- name: Upload Docs Artifact
uses: actions/[email protected]
with:
name: old-docs
path: doc/build/html/

build_docs:
runs-on: ubuntu-latest
steps:
- name: Checkout PtyPy Code
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
check-latest: true

- name: Setup MPI
uses: mpi4py/setup-mpi@v1
with:
mpi: mpich

- name: Install Sphinx
run: pip install sphinx

- name: Install PtyPy
run: pip install .[full]

- name: Install docs dependencies
run: pip install -r docs/requirements.txt

- name: Set Path to Sphinx Build
run: echo "SPHINXBUILD=`which sphinx-build`" >> $GITHUB_ENV

- name: Build Sphinx Documentation
working-directory: docs
run: make html

- name: Upload Docs Artifact
uses: actions/[email protected]
with:
name: new-docs
path: docs/_build/html/

publish_pages:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs:
- build_docs_old
- build_docs
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Setup Pages
uses: actions/[email protected]

- name: Download Old Docs Artifact
uses: actions/[email protected]
with:
name: old-docs
path: ./

- name: Download Docs Artifact
uses: actions/[email protected]
with:
name: new-docs
path: ./docs

- name: Fix File Permissions for Pages
run: |
chmod -R +rX .
- name: Upload Merged Artifact
uses: actions/[email protected]
with:
path: ./

- name: Publish Docs to GitHub Pages
id: deployment
uses: actions/[email protected]
5 changes: 5 additions & 0 deletions .github/workflows/test.yml → .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ on:
push:
branches:
- master
paths-ignore:
- "docs/**"
- ".github/workflows/**"
pull_request:
branches:
- master
- dev
- hotfixes
paths-ignore:
- "docs/**"
# Also trigger on page_build, as well as release created events
page_build:
release:
Expand Down
3 changes: 3 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

sys.path.insert(0, str(Path('..', 'ptypy').resolve()))

print(sys.path)

project = 'PtyPy'
copyright = '2024, AUTHORS'
author = 'AUTHORS'
Expand All @@ -33,6 +35,7 @@
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


#autodoc_mock_imports = ["numpy", "scipy"]

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ documentation for details.
:maxdepth: 2
:caption: Contents:

reference/index
reference/index
2 changes: 1 addition & 1 deletion docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ API Reference
.. toctree::
:maxdepth: 2

utils
utils
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pydata-sphinx-theme

0 comments on commit d0a455a

Please sign in to comment.