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

Use make in build sphinx docs #58

Merged
merged 6 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,14 @@ build_sphinx_docs:
with:
python-version: 3.10
check-links: false
use-make: false
```
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)

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.

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`.

## Publish Sphinx documentation
Deploys pre-built documentation to GitHub Pages.

Expand All @@ -122,7 +125,9 @@ deploy_sphinx_docs:
- uses: neuroinformatics-unit/actions/deploy_sphinx_docs@main
with:
secret_input: ${{ secrets.GITHUB_TOKEN }}
use-make: false
```
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.

## Full Workflows
* An example workflow, including linting, testing and release can be found at [example_test_and_deploy.yml](./example_test_and_deploy.yml).
Expand Down
10 changes: 8 additions & 2 deletions build_sphinx_docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ The various steps include:
* the version can be specified via the `python-version` input, and defaults to `3.x`
* installing pip and setting up pip cache
* pip installing build dependencies (themes, build tools, etc.) from `docs/requirements.txt`
* Checking that external links in the documentation are not broken
* checking that external links in the documentation are not broken
* optional, defaults to `true` (i.e. links are checked), see the [warning](#warning) below for more information
* building the html pages from `docs/source` (should contain Sphinx source files) to `docs/build`
* building the html pages in one of two ways, by setting the `use-make` input (default: `false`)
* (default) using `sphinx-build` to build the pages from `docs/source` (should contain Sphinx source files) to `docs/build`
* (`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
* uploading the built html pages as an artifact named `docs-build`, for use in other actions

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

- Adding the following to `conf.py` (replace with the problematic URLs).
Expand Down
19 changes: 17 additions & 2 deletions build_sphinx_docs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ inputs:
required: false
type: boolean
default: true
use-make:
description: 'Use `make` with linkcheck and building html'
required: false
type: boolean
default: false

runs:
using: 'composite'
Expand Down Expand Up @@ -49,12 +54,22 @@ runs:
- name: Check links
if: ${{ inputs.check-links == 'true' }}
shell: bash
run: sphinx-build docs/source docs/build -b linkcheck
run: |
if [ ${{ inputs.use-make }} == 'true' ]; then
cd docs && make linkcheck
else
sphinx-build docs/source docs/build -b linkcheck
fi

# needs to have sphinx.ext.githubpages in conf.py extensions list
- name: Building documentation
shell: bash
run: sphinx-build docs/source docs/build -b html
run: |
if [ ${{ inputs.use-make }} == 'true' ]; then
cd docs && make html
else
sphinx-build docs/source docs/build -b html
fi

- name: Upload the content for deployment
uses: actions/upload-artifact@v4
Expand Down
7 changes: 6 additions & 1 deletion deploy_sphinx_docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ The docs are then published (by default at `https://<username>.github.io/<repo>/
The various steps include:
* Removing any previous builds, if present in `docs/build`
* 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))
* deploying the`html` pages to the `gh-pages` branch. This step uses [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages).
* deploying the`html` pages to the `gh-pages` branch. This step uses [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages).

The `use-make` input is optional and defaults to `false`.
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).
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.
If set to `false`, the `./docs/build/` directory will be used instead.
9 changes: 8 additions & 1 deletion deploy_sphinx_docs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ inputs:
secret_input:
description: 'The secret input for the GitHub token'
required: true
use-make:
description: |
Specify whether `make` is used in the `build_sphinx_docs` action,
so that the correct publish directory is used
required: false
type: boolean
default: false

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