Skip to content

Commit 209f6cd

Browse files
authored
Merge pull request #332 from coderefinery/gh-workflow-solution
Gh workflow solution
2 parents bfbe0b2 + a48fdbb commit 209f6cd

1 file changed

Lines changed: 36 additions & 8 deletions

File tree

content/gh_workflow.md

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ on GitHub and create a copy to your namespace.
4646
4747
**Step 3**: Add the GitHub Action to your new Git repository.
4848
- Add a new file at `.github/workflows/documentation.yml` (either through terminal or web interface), containing:
49-
```yaml
49+
```{code-block} yaml
50+
:linenos:
51+
:emphasize-lines: 16,19
5052
name: documentation
5153
5254
on: [push, pull_request, workflow_dispatch]
@@ -75,8 +77,11 @@ jobs:
7577
publish_dir: _build/
7678
force_orphan: true
7779
```
78-
- You don't need to understand all of the above, but you
79-
might spot familiar commands in the `run:` sections.
80+
- You don't need to understand all of the above
81+
-- you should mainly pay attention the highlighted lines
82+
which are shell commands (we know this because they are part of a `run: |` section).
83+
The first uses `pip` to install the dependencies and the second runs `sphinx-build`
84+
to actually build the documentation (as we saw in the previous episode).
8085
- After the file has been committed (and pushed),
8186
check the action at `https://github.com/USER/documentation-example/actions`
8287
(replace `USER` with your GitHub username).
@@ -98,23 +103,46 @@ jobs:
98103
- Commit some changes to your documentation
99104
- Verify that the documentation website refreshes after your changes (can take few seconds or a minute)
100105
````
106+
101107
## Exercise - Sphinx documentation on GitHub Pages
102-
````{exercise} GH-Pages-2: Deploy Sphinx documentation to GitHub Pages
108+
````{exercise} GH-Pages-2: Putting it all together
109+
103110
1. Follow the above instructions to create a new repository with a Sphinx documentation project;
104111
2. Try adding one or more of the following to your Sphinx project:
105-
a. API documentation (see [previous exercise](#api-exercise) on API references)
106-
b. a Jupyter notebook (see [previous exercise](#jupyter-exercise) on Jupyter notebooks)
107-
c. change the theme (see the end of [the quickstart](#quickstart))
112+
1. API documentation (see [previous exercise](#api-exercise) on API references) which requires the `sphinx-autodoc2` package.
113+
2. a Jupyter notebook (see [previous exercise](#jupyter-exercise) on Jupyter notebooks) which requires the `myst-nb` package.
114+
3. change the theme (see the end of [the quickstart](#quickstart)). You can browse themes and find their package names on the [Sphinx themes gallery](https://sphinx-themes.org/#themes).
108115
109116
```{important}
110117
The computer on which the GitHub actions run is *not* your local machine,
111118
and might not have the libraries you need to build the project.
112119
Make sure you update the dependencies (installed with `pip` in the demonstration) appropriately.
113120
```
114121
```{important}
115-
Make sure the correct file paths are used where appropriate.
122+
Make sure the correct file paths are used. This will require adjusting paths from the example from the previous episode to the new layout. Note many paths, including e.g. the `autodoc2_packages` preference are now relative to the `doc/` directory.
116123
```
117124
What do you need to change in the workflow file?
125+
126+
```{solution} Solution
127+
1. **API documentation**
128+
1. Change line 16 of `.github/workflows/documentation.yml` from `pip install sphinx sphinx_rtd_theme myst_parser` to `pip install sphinx sphinx_rtd_theme myst_parser sphinx-autodoc2`.
129+
2. Follow the instructions in [Sphinx-3](#api-exercise) changing paths so that:
130+
1. `multiply.py` is `src/multiply.py` and is specified as `../src/multiply.py` in the `autodoc2_packages` preference in `conf.py`
131+
2. `conf.py` is `doc/conf.py`
132+
3. `index.md` is `doc/index.md`.
133+
3. Commit and push your changes, verify the action has run successfully, and view the built site in your browser.
134+
2. **a Jupyter notebook**
135+
1. Change line 16 of `.github/workflows/documentation.yml` from `pip install sphinx sphinx_rtd_theme myst_parser` to `pip install sphinx sphinx_rtd_theme myst_parser myst-nb`.
136+
2. Follow the instructions in [Sphinx-4](#jupyter-exercise) changing paths so that:
137+
1. `flower.md` is `docs/flower.md`
138+
2. `conf.py` is `doc/conf.py`
139+
3. `index.md` is `doc/index.md`.
140+
3. Commit and push your changes, verify the action has run successfully, and view the built site in your browser.
141+
3. **change the theme**
142+
1. Change line 16 of `.github/workflows/documentation.yml` and add the theme package if necessary.
143+
2. In `docs/config.py` change `html_theme = 'sphinx_rtd_theme'` to the name of your chosen theme.
144+
3. Commit and push your changes, verify the action has run successfully, and view the built site in your browser.
145+
```
118146
````
119147

120148
## Alternatives to GitHub Pages

0 commit comments

Comments
 (0)