Skip to content

Commit f6a4685

Browse files
committed
Added GALLERY_PATH option for building examples gallery
1 parent 932a952 commit f6a4685

File tree

4 files changed

+40
-7
lines changed

4 files changed

+40
-7
lines changed

.github/workflows/build_docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
GOOGLE_CALENDAR_ID: ${{ secrets.GOOGLE_CALENDAR_ID }}
4747
GOOGLE_CALENDAR_API_KEY: ${{ secrets.GOOGLE_CALENDAR_API_KEY }}
4848
with:
49-
run: make docs
49+
run: make docs GALLERY_PATH=../examples/
5050

5151
- name: Upload artifact
5252
uses: actions/upload-artifact@v2

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
.PHONY: docs clean
22

3+
# Gallery path must be given relative to the docs/ folder
4+
5+
ifeq ($(GALLERY_PATH),)
6+
GALLERY_PATH := ../../napari/examples
7+
endif
8+
39
clean:
410
echo clean
511
rm -rf docs/_build/
@@ -12,15 +18,15 @@ docs-install:
1218

1319
docs-build:
1420
python docs/_scripts/prep_docs.py
15-
NAPARI_APPLICATION_IPY_INTERACTIVE=0 sphinx-build -b html docs/ docs/_build
21+
NAPARI_APPLICATION_IPY_INTERACTIVE=0 sphinx-build -b html docs/ docs/_build -D sphinx_gallery_conf.examples_dirs=$(GALLERY_PATH)
1622

1723
docs: clean docs-install docs-build
1824

1925
html: clean docs-build
2026

2127
html-noplot: clean
2228
python -qr docs/_scripts/prep_docs.py
23-
NAPARI_APPLICATION_IPY_INTERACTIVE=0 sphinx-build -D plot_gallery=0 -b html docs/ docs/_build
29+
NAPARI_APPLICATION_IPY_INTERACTIVE=0 sphinx-build -D plot_gallery=0 -b html docs/ docs/_build -D sphinx_gallery_conf.examples_dirs=$(GALLERY_PATH)
2430

2531
linkcheck-files:
26-
NAPARI_APPLICATION_IPY_INTERACTIVE=0 sphinx-build -b linkcheck -D plot_gallery=0 --color docs/ docs/_build
32+
NAPARI_APPLICATION_IPY_INTERACTIVE=0 sphinx-build -b linkcheck -D plot_gallery=0 --color docs/ docs/_build -D sphinx_gallery_conf.examples_dirs=$(GALLERY_PATH)

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ def reset_napari_theme(gallery_conf, fname):
190190
qtgallery.reset_qapp(gallery_conf, fname)
191191

192192
sphinx_gallery_conf = {
193-
'examples_dirs': '../../napari/examples', # path to your example scripts
193+
#'examples_dirs': '../../napari/examples', # path to your example scripts
194+
# this value is set in the Makefile
194195
'gallery_dirs': 'gallery', # path to where to save gallery generated output
195196
'filename_pattern': '/*.py',
196197
'ignore_pattern': 'README.rst|/*_.py',

docs/developers/documentation/index.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,37 @@ clone of the `napari/docs` repository (assuming you've installed the
215215
make docs
216216
```
217217

218-
```{note}
218+
````{note}
219219
The `make docs` command above assumes your have a local clone of the
220220
[`napari/napari`](https://github.com/napari/napari) repo at the same level as
221-
the `napari/docs` clone.
221+
the `napari/docs` clone. If that's not the case, you can specify the location of
222+
the examples gallery folder by executing
223+
224+
```bash
225+
make docs GALLERY_PATH=<path-to-examples-folder>
226+
```
227+
228+
The `GALLERY_PATH` option must be given relative to the `docs` folder. If your
229+
folder structure is
230+
222231
```
232+
├── napari-docs
233+
│ └── docs
234+
├── napari
235+
│ ├── binder
236+
│ ├── examples
237+
│ ├── napari
238+
│ ├── napari_builtins
239+
│ ├── resources
240+
│ └── tools
241+
```
242+
243+
Then the command would be
244+
```bash
245+
make docs GALLERY_PATH=../../napari/examples
246+
```
247+
248+
````
223249
224250
The rendered HTML will be placed in `docs/_build`. Find `index.html` in this
225251
folder and drag it into a browser to preview the website with your new document.

0 commit comments

Comments
 (0)