Skip to content

Commit 5102341

Browse files
authored
Optionally use make in build sphinx docs (#58)
* Use `make` in build sphinx docs * Update documentation * Add commadn to change dir before running `make` in README.md * Make the use of `make` optional in `build_sphinx_docs` * Update documentation * Add `use-make` option in `deploy_sphinx_docs`
1 parent a57f8d3 commit 5102341

5 files changed

Lines changed: 44 additions & 6 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,14 @@ build_sphinx_docs:
101101
with:
102102
python-version: 3.10
103103
check-links: false
104+
use-make: false
104105
```
105106
The `python-version` input is optional and defaults to `3.x` (where `x` is the latest stable version of Python 3 available on the GitHub Actions platform)
106107

107108
The `check-links` input is also optional and defaults to `true`. If set to `true`, the action will use the Sphinx linkcheck builder to check the integrity of all **external** links.
108109

110+
The `use-make` input is optional and defaults to `false`. If set to `true`, the action will use the `make` utility with a custom `docs/Makefile` to build the pages from `SOURCEDIR` to `BUILDDIR` as defined in the Makefile. If set to `false`, the action will use `sphinx-build` to build the pages from `docs/source` to `docs/build`.
111+
109112
## Publish Sphinx documentation
110113
Deploys pre-built documentation to GitHub Pages.
111114

@@ -122,7 +125,9 @@ deploy_sphinx_docs:
122125
- uses: neuroinformatics-unit/actions/deploy_sphinx_docs@main
123126
with:
124127
secret_input: ${{ secrets.GITHUB_TOKEN }}
128+
use-make: false
125129
```
130+
The `use-make` input is optional and defaults to `false`. If set to `true`, the action will assume that the Sphinx documentation is built using `make` and will use the `./docs/build/html` directory as the publish directory. If set to `false`, it will use the `./docs/build/` directory instead.
126131

127132
## Full Workflows
128133
* An example workflow, including linting, testing and release can be found at [example_test_and_deploy.yml](./example_test_and_deploy.yml).

build_sphinx_docs/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ The various steps include:
77
* the version can be specified via the `python-version` input, and defaults to `3.x`
88
* installing pip and setting up pip cache
99
* pip installing build dependencies (themes, build tools, etc.) from `docs/requirements.txt`
10-
* Checking that external links in the documentation are not broken
10+
* checking that external links in the documentation are not broken
1111
* optional, defaults to `true` (i.e. links are checked), see the [warning](#warning) below for more information
12-
* building the html pages from `docs/source` (should contain Sphinx source files) to `docs/build`
12+
* building the html pages in one of two ways, by setting the `use-make` input (default: `false`)
13+
* (default) using `sphinx-build` to build the pages from `docs/source` (should contain Sphinx source files) to `docs/build`
14+
* (`use-make: true`) using the `make` utility with a custom `docs/Makefile` to build the pages from `SOURCEDIR` to `BUILDDIR` as defined in the Makefile
1315
* uploading the built html pages as an artifact named `docs-build`, for use in other actions
1416

1517
It can be run upon all pull requests, to ensure that documentation still builds.
@@ -22,6 +24,10 @@ You can debug the linkcheck step by running it locally:
2224
```bash
2325
sphinx-build docs/source docs/build -b linkcheck
2426
```
27+
or, if you have `docs/Makefile`:
28+
```bash
29+
cd docs && make linkcheck
30+
```
2531
If the linkcheck step produces "false positives" for your project (i.e. marking valid links as broken), you have two options:
2632

2733
- Adding the following to `conf.py` (replace with the problematic URLs).

build_sphinx_docs/action.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ inputs:
1212
required: false
1313
type: boolean
1414
default: true
15+
use-make:
16+
description: 'Use `make` with linkcheck and building html'
17+
required: false
18+
type: boolean
19+
default: false
1520

1621
runs:
1722
using: 'composite'
@@ -49,12 +54,22 @@ runs:
4954
- name: Check links
5055
if: ${{ inputs.check-links == 'true' }}
5156
shell: bash
52-
run: sphinx-build docs/source docs/build -b linkcheck
57+
run: |
58+
if [ ${{ inputs.use-make }} == 'true' ]; then
59+
cd docs && make linkcheck
60+
else
61+
sphinx-build docs/source docs/build -b linkcheck
62+
fi
5363
5464
# needs to have sphinx.ext.githubpages in conf.py extensions list
5565
- name: Building documentation
5666
shell: bash
57-
run: sphinx-build docs/source docs/build -b html
67+
run: |
68+
if [ ${{ inputs.use-make }} == 'true' ]; then
69+
cd docs && make html
70+
else
71+
sphinx-build docs/source docs/build -b html
72+
fi
5873
5974
- name: Upload the content for deployment
6075
uses: actions/upload-artifact@v4

deploy_sphinx_docs/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@ The docs are then published (by default at `https://<username>.github.io/<repo>/
55
The various steps include:
66
* Removing any previous builds, if present in `docs/build`
77
* downloading the built html pages (artifact named `docs-build`) into the `docs/build` folder (see the [Build Sphinx Docs action](../build_sphinx_docs/README.md))
8-
* deploying the`html` pages to the `gh-pages` branch. This step uses [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages).
8+
* deploying the`html` pages to the `gh-pages` branch. This step uses [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages).
9+
10+
The `use-make` input is optional and defaults to `false`.
11+
As this input helps to identify the location of the built documentation for deployment, it should match the `use-make` value specified in the [Build Sphinx Docs action](../build_sphinx_docs/README.md).
12+
If set to `true`, it is assumed that the documentation is built using `make` and the `./docs/build/html` directory will be used as the publish directory.
13+
If set to `false`, the `./docs/build/` directory will be used instead.

deploy_sphinx_docs/action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ inputs:
55
secret_input:
66
description: 'The secret input for the GitHub token'
77
required: true
8+
use-make:
9+
description: |
10+
Specify whether `make` is used in the `build_sphinx_docs` action,
11+
so that the correct publish directory is used
12+
required: false
13+
type: boolean
14+
default: false
815

916
runs:
1017
using: 'composite'
@@ -28,4 +35,4 @@ runs:
2835
uses: peaceiris/actions-gh-pages@v4
2936
with:
3037
github_token: ${{ env.GITHUB_TOKEN }}
31-
publish_dir: ./docs/build
38+
publish_dir: ${{ inputs.use-make == 'true' && './docs/build/html' || './docs/build/' }}

0 commit comments

Comments
 (0)