You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/gh_workflow.md
+36-8Lines changed: 36 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,9 @@ on GitHub and create a copy to your namespace.
46
46
47
47
**Step 3**: Add the GitHub Action to your new Git repository.
48
48
- 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
50
52
name: documentation
51
53
52
54
on: [push, pull_request, workflow_dispatch]
@@ -75,8 +77,11 @@ jobs:
75
77
publish_dir: _build/
76
78
force_orphan: true
77
79
```
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).
80
85
- After the file has been committed (and pushed),
81
86
check the action at `https://github.com/USER/documentation-example/actions`
82
87
(replace `USER` with your GitHub username).
@@ -98,23 +103,46 @@ jobs:
98
103
- Commit some changes to your documentation
99
104
- Verify that the documentation website refreshes after your changes (can take few seconds or a minute)
100
105
````
106
+
101
107
## 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
+
103
110
1. Follow the above instructions to create a new repository with a Sphinx documentation project;
104
111
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).
108
115
109
116
```{important}
110
117
The computer on which the GitHub actions run is *not* your local machine,
111
118
and might not have the libraries you need to build the project.
112
119
Make sure you update the dependencies (installed with `pip` in the demonstration) appropriately.
113
120
```
114
121
```{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.
116
123
```
117
124
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.
0 commit comments