Skip to content

Commit e634704

Browse files
melissawmlucyleeowjni
authored
Update docs contribution guide for two-repo setup (#5)
Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Juan Nunez-Iglesias <jni@fastmail.com> Closes #3
1 parent 05ace56 commit e634704

File tree

5 files changed

+148
-74
lines changed

5 files changed

+148
-74
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: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
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/
612
rm -rf docs/api/napari*.rst
7-
rm -rf docs/gallery/*
813
rm -rf docs/_tags
14+
rm -rf docs/gallery/
915

1016
docs-install:
1117
python -m pip install -qr requirements.txt
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)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# napari docs
22

3-
This repository contains the sources for the napari documentation. This includes tutorials, how-tos, the examples gallery and the autogenerated API documentation extracted from the source code docstrings.
3+
This repository contains the sources for the napari documentation. This includes tutorials, how-tos and other narrative documentation. The autogenerated API documentation is extracted from the source code docstrings, which live on https://github.com/napari/napari
44

55
## mission, values, and roadmap
66

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ def reset_napari_theme(gallery_conf, fname):
189189
settings.appearance.theme = 'dark'
190190
qtgallery.reset_qapp(gallery_conf, fname)
191191

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

docs/developers/documentation/index.md

Lines changed: 134 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,112 @@
11
(docs_contributing_guide)=
22
# Contributing Documentation
33

4-
This guide will teach you how to submit new documents to napari's usage documentation.
4+
This guide will teach you how to submit new documents to napari's usage
5+
documentation.
6+
7+
## Organization of the documentation
8+
9+
The napari documentation is built from sources located at the
10+
[napari/docs](https://github.com/napari/docs) repository on GitHub. That
11+
repository is where all the narrative documentation (e.g. tutorials, how-to
12+
guides) pull requests should be made. Meanwhile, changes to docstrings or to the
13+
[examples gallery](https://napari.org/gallery) should be made to the
14+
[napari/napari](https://github.com/napari/napari) repository.
515

616
## Prerequisites
717

8-
Prerequisites depend on the type of contribution you wish to make. In general
18+
Prerequisites depend on the type of contribution you wish to make. In general,
919
you will require:
1020

11-
- Some familiarity with [`git`](https://git-scm.com)
12-
- A [GitHub](https://github.com) account
21+
- Some familiarity with [`git`](https://git-scm.com);
22+
- A [GitHub](https://github.com) account.
23+
24+
You should first [fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo)
25+
and clone the [napari/docs](https://github.com/napari/docs) repo to your
26+
machine, and navigate to the resulting folder:
27+
28+
```bash
29+
git clone git@github.com:<your-username>/docs.git napari-docs
30+
cd napari-docs/
31+
```
32+
33+
````{note}
34+
To reduce confusion and possible conflicts, the `docs` fork is being cloned into
35+
a local repository folder named `napari-docs`. Alternately, you could also
36+
rename the repository when forking `napari/docs`.
37+
```
1338
14-
If you wish to add/amend documentation that does not contain code, you
15-
will also require:
39+
- **If you wish to add/amend documentation that does not contain code, you will
40+
require a clean conda environment with napari docs dependencies installed.**
1641
17-
- A clean conda environment with napari docs dependencies installed:
42+
Starting at the folder where you cloned the `napari/docs` repository, and
43+
after activating your clean `conda` environment, you can install these with
44+
`python -m pip install -r requirements.txt`.
1845
19-
- You can install these with `pip install "napari[docs]"`
20-
- These dependencies will allow you to preview your document locally, as it would appear on `napari.org`
21-
- They will also install `jupytext`, which you will need to contribute documents containing code or viewer interactions
46+
These dependencies will allow you to preview your document locally, as it
47+
would appear on `napari.org`, and they will also install `jupytext`, which you
48+
will need to contribute documents containing code or viewer interactions.
2249
23-
If you wish to add/amend documentation that does contain code, you will also require:
50+
- **If you wish to add/amend documentation that does contain code, you will also
51+
require a clean conda environment with napari docs dependencies installed, but
52+
with a development installation of napari.**
2453
25-
- A clean conda environment with a development installation of napari, see
26-
the [contributor guide](dev-installation)
27-
for details
28-
- [Jupyter notebook](https://jupyter.org/) installed
29-
- Familiarity with Jupyter notebooks (code cells and markdown cells)
30-
- Familiarity with using napari through a Jupyter notebook
54+
See the [contributor guide](dev-installation) for details. You should have
55+
[Jupyter notebook](https://jupyter.org/) installed. Familiarity with Jupyter
56+
notebooks (code cells and markdown cells) as well as using napari through a
57+
Jupyter notebook is recommended.
3158
3259
## 0. Before you start
3360
34-
If you'd like to contribute a brand new document to our usage section, it might be worth [opening an issue](https://github.com/napari/napari/issues/new?assignees=&labels=documentation&template=documentation.md&title=)
35-
on our repository first to discuss the content you'd like to see and get some early feedback from the community.
36-
The napari team can also suggest what type of document would be best suited, and whether there are already
37-
existing documents that could be expanded to include the content you think is lacking.
61+
If you'd like to contribute a brand new document to our usage section, it might
62+
be worth [opening an issue](https://github.com/napari/napari/issues/new?assignees=&labels=documentation&template=documentation.md&title=)
63+
on our repository first to discuss the content you'd like to see and get some
64+
early feedback from the community. The napari team can also suggest what type of
65+
document would be best suited, and whether there are already existing documents
66+
that could be expanded to include the content you think is lacking.
3867
39-
Go to your local napari folder to find examples of documents you might want to contribute. The paths are listed in parentheses below.
68+
Go to your local `napari/docs` folder to find examples of documents you might
69+
want to contribute. The paths are listed in parentheses below.
4070
41-
- [**Explanations**](../../guides/index) (in [`napari/docs/guides`](https://github.com/napari/napari/tree/main/docs/guides)):
71+
- [**Explanations**](../../guides/index) (in [`napari/docs/guides`](https://github.com/napari/docs/tree/main/docs/guides)):
4272
in depth content about napari architecture, development choices and some complex features
43-
- [**Tutorials**](../../tutorials/index) (in [`napari/docs/tutorials`](https://github.com/napari/napari/tree/main/docs/tutorials)):
73+
- [**Tutorials**](../../tutorials/index) (in [`napari/docs/tutorials`](https://github.com/napari/docs/tree/main/docs/tutorials)):
4474
detailed, reproducible step by step guides, usually combining multiple napari features to complete a potentially complex task
45-
- [**How-tos**](../../howtos/index) (in [`napari/docs/howtos/`](https://github.com/napari/napari/tree/main/docs/howtos)):
75+
- [**How-tos**](../../howtos/index) (in [`napari/docs/howtos/`](https://github.com/napari/docs/tree/main/docs/howtos)):
4676
simple step by step guides demonstrating the use of common features
47-
- [**Examples**](../../gallery) (in [`napari/examples/`](https://github.com/napari/napari/tree/main/examples)):
48-
code examples of how to use napari
49-
- [**Getting started**](../../tutorials/start_index) (in [`napari/docs/tutorials/fundamentals`](https://github.com/napari/napari/tree/main/docs/tutorials/fundamentals):
77+
- [**Getting started**](../../tutorials/start_index) (in [`napari/docs/tutorials/fundamentals`](https://github.com/napari/docs/tree/main/docs/tutorials/fundamentals):
5078
these documents are a mix of tutorials and how-tos covering the fundamentals of installing and working with napari for beginners
5179
80+
The [**Examples gallery**](../../gallery) sources are in the [main `napari/napari` repository](https://github.com/napari/napari/tree/main/examples)
81+
and show code examples of how to use napari.
82+
5283
```{admonition} Got materials for a workshop?
5384
:class: tip
5485
55-
If you already have teaching materials e.g. recordings, slide decks or jupyter notebooks
86+
If you already have teaching materials e.g. recordings, slide decks or Jupyter notebooks
5687
hosted somewhere, you can add links to these on our [napari workshops](../../further-resources/napari-workshops.md) page.
5788
```
5889
5990
## 1. Write your documentation
6091
61-
Fork and clone [our repository](https://github.com/napari/napari). If you are
62-
amending existing documentation, you can do so in your preferred text editor.
63-
If you wish to add a new tutorial or a how-to, we recommend you use our
64-
[template](./docs_template).
65-
66-
Our goal is that all tutorials and how-tos are easily downloadable and executable by our users.
67-
This helps ensure that they are reproducible and makes them easier to maintain.
68-
We therefore provide a notebook template for our documents. Inside the template
69-
you'll find handy tips for taking screenshots of the viewer, hiding code cells,
70-
using style guides and what to include in the required prerequisites section.
71-
72-
[Jupyter notebooks](https://jupyter.org/) are a great option for our documents, because they allow you to easily combine code and well formatted text in markdown.
73-
However, their [raw JSON format](https://numpy.org/numpy-tutorials/content/pairing.html#background) is not great for version control, so we use [MyST Markdown](https://myst-parser.readthedocs.io/en/latest/) documents in our repository and on napari.org.
74-
75-
Make a copy of `napari/docs/developers/documentation/docs_template.md`.
76-
You can edit the template directly in Jupyter notebook, or in your preferred text editor.
92+
Our goal is that all tutorials and how-tos are easily downloadable and
93+
executable by our users. This helps ensure that they are reproducible and makes
94+
them easier to maintain. [Jupyter notebooks](https://jupyter.org/) are a great
95+
option for our documents, because they allow you to easily combine code and well
96+
formatted text in markdown and can be executed automatically. However, their
97+
[raw JSON format](https://numpy.org/numpy-tutorials/content/pairing.html#background)
98+
is not great for version control, so we use [MyST Markdown](https://myst-parser.readthedocs.io/en/latest/)
99+
documents in our repository and on [napari.org](https://napari.org).
100+
101+
If you are amending existing documentation, you can do so in your preferred text
102+
editor. If you wish to add a new tutorial or a how-to, we recommend you use our
103+
[template](./docs_template). Inside the template you'll find handy tips for
104+
taking screenshots of the viewer, hiding code cells, using style guides and what
105+
to include in the required prerequisites section.
106+
107+
To use the template, make a copy of `docs/developers/documentation/docs_template.md`
108+
and rename it to match your content. You can edit the template directly in
109+
Jupyter notebook, or in your preferred text editor.
77110
78111
```{admonition} Already have a notebook?
79112
:class: tip
@@ -92,24 +125,25 @@ some steps:
92125
93126
* If you are adding new documentation and would prefer a simpler workflow,
94127
you can you can use the
95-
[GitHub web interface to open your pull request](https://docs.github.com/en/repositories/working-with-files/managing-files/adding-a-file-to-a-repository). A member of the maintenance
128+
[GitHub web interface to open your pull request](https://docs.github.com/en/repositories/working-with-files/managing-files/adding-a-file-to-a-repository).
129+
A member of the maintenance
96130
team will help with updating TOC and making sure your documentation has built
97131
correctly. You will also be able to preview the documentation yourself by
98132
downloading the built documentation via a link provided by a comment from the
99-
'github-actions' bot.
133+
`github-actions` bot.
100134
* If you are amending an existing document you can skip straight
101135
to [Step #3 - Preview your document](#3-preview-your-document)
102-
* For all other documentation changes, follow the steps below
136+
* For all other documentation changes, follow the steps below.
103137
104138
## 2. Update TOC
105139
106140
If you are adding a new documentation file, you will need to add your document
107141
to the correct folder based on its content (see the [list above](#0-before-you-start)
108-
for common locations), and update `napari/docs/_toc.yml`.
142+
for common locations), and update `docs/_toc.yml`.
109143
110144
If you're adding a document
111145
to an existing group, simply add a new `- file:` entry in the appropriate spot. For example, if I wanted to add
112-
a `progress_bars.md` how to guide, I would place it in `napari/docs/howtos` and update `_toc.yml` as below:
146+
a `progress_bars.md` how to guide, I would place it in `docs/howtos` and update `_toc.yml` as below:
113147
114148
```yaml
115149
- file: howtos/index
@@ -135,7 +169,7 @@ subtrees:
135169
```
136170
137171
To create a new subheading, you need a `subtrees` entry. For example, if I wanted to add `geo_tutorial1.md` and `geo_tutorial2.md`
138-
to a new `geosciences` subheading in tutorials, I would place my documents in a new folder `napari/docs/tutorials/geosciences`,
172+
to a new `geosciences` subheading in tutorials, I would place my documents in a new folder `docs/tutorials/geosciences`,
139173
together with an `index.md` that describes what these tutorials would be about, and then update `_toc.yml` as below:
140174
141175
```yaml
@@ -175,41 +209,75 @@ also be caught when previewing the built documentation. If your documentation
175209
change does not include code, you only need the napari docs dependencies
176210
installed.
177211
178-
There are two ways you can preview the documentation website, by building
179-
locally or downloading the GitHub Actions built documentation when you submit
212+
There are two ways you can preview the documentation website: by building
213+
locally, or downloading the GitHub Actions built documentation when you submit
180214
your pull request.
181215
182-
To build the documentation locally, run `make docs` from the root of
183-
the `napari` repository (assuming you've installed the [docs prerequisites](#prerequisites)).
216+
To build the documentation locally, run `make docs` from the root of your local
217+
clone of the `napari/docs` repository (assuming you've installed the
218+
[docs prerequisites](#prerequisites)).
184219
185220
```bash
186221
make docs
187222
```
188223
189-
The rendered HTML will be placed in `napari/docs/_build`. Find `index.html` in this folder and drag it
190-
into a browser to preview the website with your new document.
224+
````{note}
225+
The `make docs` command above assumes your have a local clone of the
226+
[`napari/napari`](https://github.com/napari/napari) repo at the same level as
227+
the `napari/docs` clone. If that's not the case, you can specify the location of
228+
the examples gallery folder by executing
229+
230+
```bash
231+
make docs GALLERY_PATH=<path-to-examples-folder>
232+
```
233+
234+
The `GALLERY_PATH` option must be given relative to the `docs` folder. If your
235+
folder structure is
236+
237+
```
238+
├── napari-docs
239+
│ └── docs
240+
├── napari
241+
│ ├── binder
242+
│ ├── examples
243+
│ ├── napari
244+
│ ├── napari_builtins
245+
│ ├── resources
246+
│ └── tools
247+
```
248+
249+
Then the command would be
250+
```bash
251+
make docs GALLERY_PATH=../../napari/examples
252+
```
253+
254+
````
255+
256+
The rendered HTML will be placed in `docs/_build`. Find `index.html` in this
257+
folder and drag it into a browser to preview the website with your new document.
191258

192-
Alternatively, When you submit your pull request, napari continuous integration
193-
includes a GitHub action that builds the documentation and saves the artifact
194-
for you to download. This is another way to check that your built documentation
195-
looks as you expect. To download the built documentation, go to your PR, scroll
196-
down to the continuous integration tests, then:
259+
Alternatively, when you submit your pull request, the napari docs repository
260+
continuous integration includes a GitHub action that builds the documentation
261+
and saves the artifact for you to download. This is another way to check that
262+
your built documentation looks as you expect. To download the built
263+
documentation, go to your PR, scroll down to the continuous integration tests,
264+
then:
197265

198-
1. click on 'details' next to 'Build Docs / Build & Upload Artifact (pull_request)'
266+
1. Click on **Details** next to `Build PR Docs / Build & Upload Artifact (pull_request)`:
199267

200268
![doc-continuous-integration-1](images/doc-ci-1.png)
201269

202-
2. click on 'summary' on the top left corner
270+
2. Click on **Summary** on the top left corner:
203271

204272
![doc-continuous-integration-1](images/doc-ci-2.png)
205273

206-
3. scroll down to 'artifacts' and click on 'docs' to download the built documentation
274+
3. Scroll down to **Artifacts** and click on **docs** to download the built documentation:
207275

208276
![doc-continuous-integration-1](images/doc-ci-3.png)
209277

210278
## 4. Submit your pull request
211279

212-
Once you have written and previewed your document, it's time to open a pull request to [napari's main repository](https://github.com/napari/napari) and contribute it to our codebase.
280+
Once you have written and previewed your document, it's time to open a pull request to [napari's docs repository](https://github.com/napari/docs) and contribute it to our codebase.
213281

214282
If you are simply contributing one file (e.g., a tutorial or how-to page) you
215283
can use the [GitHub web interface to open your pull request](https://docs.github.com/en/repositories/working-with-files/managing-files/adding-a-file-to-a-repository). Ensure you

0 commit comments

Comments
 (0)