Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add doc workflow #3

Merged
merged 14 commits into from
Oct 29, 2023
Merged
Next Next commit
Add doc build workflow
ericpre committed Oct 29, 2023
commit 206f12de6caa69eb2ec3293eb8f89c85e4719bf7
115 changes: 115 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Docs

on: [push, pull_request]

jobs:
build_doc_PR:
# This build is to automatically add comments on PR
name: PR comments
runs-on: ubuntu-latest
env:
BUILD_DEPS: python3-dev build-essential graphviz
LATEX_DEPS: dvipng latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended

steps:
- uses: actions/checkout@v4

- uses: ericpre/sphinx-action@latest_sphinx
with:
pre-build-command: "apt-get update -y && apt-get install -y ${{ env.BUILD_DEPS }} ${{ env.LATEX_DEPS }} && pip install .'[doc]'"
build-command: make html
docs-folder: doc/

- uses: actions/upload-artifact@v3
with:
path: ./doc/_build/html/
name: docs_build

build_docs:
# This build is to check links and update table of supported formats
name: Check links
runs-on: ubuntu-latest
env:
DOCS_PATH: ./doc/_build/html/
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.11'

- name: Install build docs
shell: bash -l {0}
run: |
pip install .'[doc]'
- name: Check links
shell: bash -l {0}
run: |
cd doc
make linkcheck
- name: Build docs
shell: bash -l {0}
run: |
cd doc
make SPHINXOPTS="-W --keep-going" html
- uses: actions/upload-artifact@v3
with:
path: ${{ env.DOCS_PATH }}
name: docs_html

push_docs:
# This build is to push changes to gh-pages branch (https://hyperspy.org/exspy)
needs: build_docs
name: Push to gh-pages
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' && github.repository == 'hyperspy/exspy' }}
permissions:
# needs write permission to push the docs to gh-pages
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: gh-pages

- uses: actions/download-artifact@v3
with:
name: docs_html
path: .

- name: list files
run: |
ls
- name: Git status
run: |
git status
git status -s
if [[ $(git status -s) ]]; then
HAS_CHANGES='true'
else
HAS_CHANGES='false'
fi
echo "HAS_CHANGES=${HAS_CHANGES}" >> $GITHUB_ENV
- name: Commit files
# Skip when there is nothing to commit
if: ${{ env.HAS_CHANGES == 'true' }}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -A
git commit -m "Update docs build" -a
- name: Push changes
if: ${{ env.HAS_CHANGES == 'true' }}
uses: ad-m/github-push-action@d91a481090679876dfc4178fef17f286781251df
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
27 changes: 27 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# .readthedocs.yml
# 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.11"

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

# Optionally build your docs in additional formats such as PDF and ePub
formats:
- htmlzip

python:
install:
- method: pip
path: .
extra_requirements:
- doc
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -27,10 +27,10 @@

extra_feature_requirements = {
"gui-jupyter": [
"hyperspy_gui_ipywidgets @ git+https://github.com/ericpre/hyperspy_gui_ipywidgets.git@hyperspy2.0",
"hyperspy_gui_ipywidgets @ https://github.com/hyperspy/hyperspy_gui_ipywidgets/archive/hyperspy2.0.zip",
],
"gui-traitsui": [
"hyperspy_gui_traitsui @ git+https://github.com/ericpre/hyperspy_gui_traitsui.git@hyperspy2.0",
"hyperspy_gui_traitsui @ https://github.com/hyperspy/hyperspy_gui_traitsui/archive/hyperspy2.0.zip",
],
"doc": [
"numpydoc",
@@ -82,7 +82,7 @@
extras_require=extra_feature_requirements,
install_requires=[
"dask[array]",
"hyperspy @ git+https://github.com/hyperspy/hyperspy@RELEASE_next_major",
"hyperspy @ https://github.com/hyperspy/hyperspy/archive/RELEASE_next_major.zip",
"matplotlib",
"numexpr",
"numpy",