Skip to content

Commit 6e64982

Browse files
authored
switch from RTD to GitHub Pages (#8)
* switch from RTD to GitHub Pages * fix uvx in documentation action * add astral setup-uv to documentation action * build API docs in action * remove outdated packagename api file * remove docs/api folder * fix nbgallery errors in docs * style fixes * install pandoc in action * temporarily remove publishing site only for main * specify where docs are built in action * use sphinx githubpages extension * fix sphinx build location * update readme * enable preview of site in PR's * fixing PR preview * seperate deploy from preview actions * add bash to deplot docs action * fix docs preview action * fix docs preview action
1 parent 05667f4 commit 6e64982

11 files changed

Lines changed: 145 additions & 68 deletions

File tree

.github/workflows/docs_preview.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Docs Preview
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
- edited
10+
- closed
11+
branches:
12+
- "main"
13+
workflow_dispatch:
14+
15+
concurrency: preview-${{github.ref}}
16+
17+
jobs:
18+
preview:
19+
runs-on: ubuntu-latest
20+
# only run if from the same repository, not a fork
21+
if: github.event.pull_request.head.repo.full_name == github.repository
22+
permissions:
23+
contents: write
24+
pull-requests: write
25+
defaults:
26+
run:
27+
shell: bash -l {0}
28+
29+
steps:
30+
# Checkout current git repository
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
# setup python env
35+
- uses: actions/setup-python@v5
36+
if: github.event.action != 'closed' # Skip the build if the PR has been closed; just run the clean up steps
37+
with:
38+
python-version: "3.x"
39+
40+
- uses: astral-sh/setup-uv@v6
41+
42+
- id: install_pandoc
43+
run: sudo apt-get install pandoc
44+
45+
# Make API docs
46+
- name: Make API docs
47+
if: github.event.action != 'closed'
48+
run: uvx nox -s build_api_docs
49+
50+
# Build the documentation
51+
- name: Build the documentation
52+
if: github.event.action != 'closed'
53+
run: uvx nox -s docs --non-interactive -- docs/_build/html
54+
55+
# Deploy the preview of the docs
56+
- name: Deploy Preview
57+
uses: rossjrw/pr-preview-action@v1
58+
with:
59+
source-dir: docs/_build/html
60+
preview-branch: gh-pages
61+
# custom-url:
62+
umbrella-dir: pr-preview
63+
action: auto
64+
deploy-repository: ${{ github.repository }}
65+
token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
# This job installs dependencies, builds the html, and pushes it to gh-pages
10+
jobs:
11+
docs:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }} # only run one of these jobs at a time
17+
defaults:
18+
run:
19+
shell: bash -l {0}
20+
21+
steps:
22+
# Checkout current git repository
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
# setup python env
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.x"
30+
31+
- uses: astral-sh/setup-uv@v6
32+
33+
- id: install_pandoc
34+
run: sudo apt-get install pandoc
35+
36+
# Make API docs
37+
- name: Make API docs
38+
run: uvx nox -s build_api_docs
39+
40+
# Build the documentation
41+
- name: Build the documentation
42+
run: uvx nox -s docs --non-interactive -- docs/_build/html
43+
44+
# Deploy the HTML to gh-pages branch
45+
- name: GitHub Pages action
46+
uses: peaceiris/actions-gh-pages@v4
47+
with:
48+
github_token: ${{ secrets.GITHUB_TOKEN }}
49+
publish_dir: docs/_build/html
50+
publish_branch: gh-pages
51+
force_orphan: true

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,3 @@ repos:
9292
hooks:
9393
- id: check-dependabot
9494
- id: check-github-workflows
95-
- id: check-readthedocs

.readthedocs.yaml

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

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,14 @@ Steps:
138138
- create a new folder : `staged-recipes/recipes/samplepackagename`
139139
- copy your `meta.yaml` file into this folder, remove the `meta.yaml` from wherever it was generated.
140140
- commit and push your changes to your fork, and in the main [repository](https://github.com/conda-forge/staged-recipes) open a PR.
141-
13) Set up ReadTheDocs for the documentation website
142-
- log into ReadTheDocs using your GitHub account.
143-
- click `Add project` and ssearch for your repository.
144-
- Chose your project name, ideally its the same as your package name, but it doesn't have to be. If it's different, update the badge below: `[rtd-link]: https://samplepackagename.readthedocs.io/en/latest/?badge=latest`
145-
- Go to `settings` to update anything you'd like
146-
- check `Build pull requests for this project`.
147-
- for each commit to main, ReadTheDocs should automatically update the documentation website. Also, in PR's there should be a link to view the new docs to check them before merging the PR.
141+
13) Set up GitHub Pages to host the documentation website
142+
- this will only work for a public repository
143+
- On GitHub, go to your repositories settings
144+
- for `Source`, choose "Deplot from a branch"
145+
- for `Branch`, choose "gh-pages"
146+
- for `Select folder`, choose "root"
147+
- optionally choose a custom URL and hit save
148+
- for every push to `main` (from a PR), the site will be updated
148149
14) Finalize
149150
- remove all the above instructions and raise any issues in this template's repository if you have any suggestion or found any errors in this template!
150151
- if you want, please submit a PR to this repository to add your package to this list at the top of this README to showcase it!
@@ -153,7 +154,7 @@ Steps:
153154
Short description of your package.
154155
155156
[![Actions Status][actions-badge]][actions-link]
156-
[![Documentation Status][rtd-badge]][rtd-link]
157+
[![Documentation Status][website-badge]][website-link]
157158
158159
[![PyPI version][pypi-version]][pypi-link]
159160
[![Conda-Forge][conda-badge]][conda-link]
@@ -173,8 +174,8 @@ Short description of your package.
173174
[pypi-link]: https://pypi.org/project/samplepackagename/
174175
[pypi-platforms]: https://img.shields.io/pypi/pyversions/samplepackagename
175176
[pypi-version]: https://img.shields.io/pypi/v/samplepackagename
176-
[rtd-badge]: https://readthedocs.org/projects/samplepackagename/badge/?version=latest
177-
[rtd-link]: https://samplepackagename.readthedocs.io/en/latest/?badge=latest
177+
[website-badge]: https://github.com/mdtanker/python_package_template/actions/workflows/pages/pages-build-deployment/badge.svg
178+
[website-link]: https://mdtanker.github.io/python_package_template/
178179
179180
<!-- prettier-ignore-end -->
180181

docs/api/packagename.rst

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

docs/api/samplepackagename.rst

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

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"sphinx_copybutton",
1919
# "sphinx.ext.viewcode",
2020
"nbsphinx",
21+
# githubpages just adds a .nojekyll file
22+
"sphinx.ext.githubpages",
2123
]
2224

2325
source_suffix = [".rst", ".md"]

docs/examples/index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Examples
22

3+
<!--
34
```{nbgallery}
45
---
56
---
6-
<!-- Add list of notebooks here -->
7+
notebook1
8+
notebook2
9+
notebook3
710
```
11+
-->

docs/how_to/index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# How-To Guides
22

3+
<!--
34
```{nbgallery}
45
---
56
---
6-
<!-- Add list of notebooks here -->
7+
notebook1
8+
notebook2
9+
notebook3
710
```
11+
-->

0 commit comments

Comments
 (0)