Skip to content

Commit 841e1dd

Browse files
seankmartinmelissawm
authored andcommitted
Plugin docs restructure of content (napari#203)
# Description I've reorganised the content of /plugins following napari#153. I'm interested to see what you think! I was very heavy handed with the use of grids for the index pages, because they are the best I could think of. Open to other options as always. I also fixed a small number links on other pages outside of /plugins because I broke a lot of links with this restructure and I wasn't exactly sure what I caused and what was already broken - thought it was safer to just fix them. Here is what the homepage of plugins would look like: ![image](https://github.com/napari/docs/assets/21295664/f4d732a3-d485-4186-89e7-1f40a7d93c96) ## Type of change - [x] Fixes or improves existing content - [x] Adds new content page(s) ## Final checklist: - [x] My PR is the minimum possible work for the desired functionality ## Addendum A small number of my commits got associated with my bot account (I set the wrong email in my git config because I deleted my config before creating napari#201 🙈). I genuinely don't know how to fix that. If it is going to be an issue I could make a new branch and squash all the commits into one big commit from my seankmartin account.
1 parent 37504e8 commit 841e1dd

File tree

28 files changed

+497
-311
lines changed

28 files changed

+497
-311
lines changed

docs/_toc.yml

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,32 +75,48 @@ subtrees:
7575
- file: plugins/index
7676
subtrees:
7777
- entries:
78-
- file: plugins/find_and_install_plugin
79-
- file: plugins/first_plugin
80-
- file: plugins/manifest
81-
- file: plugins/contributions
82-
- file: plugins/guides
83-
- file: plugins/test_deploy
84-
- file: plugins/best_practices
85-
- file: plugins/debug_plugins
86-
- file: plugins/npe2_migration_guide
87-
- file: plugins/npe1
88-
- file: plugins/testing_workshop_docs/index
78+
- file: plugins/start_using_plugins/index
8979
subtrees:
9080
- entries:
91-
- file: plugins/testing_workshop_docs/1-pythons-assert-keyword
92-
- file: plugins/testing_workshop_docs/2-pytest-testing-frameworks
93-
- file: plugins/testing_workshop_docs/3-readers-and-fixtures
94-
- file: plugins/testing_workshop_docs/4-test-coverage
95-
- file: plugins/testing_workshop_docs/testing-resources
96-
- file: plugins/virtual_environment_docs/index
81+
- file: plugins/start_using_plugins/finding_and_installing_plugins
82+
- file: plugins/building_a_plugin/index
9783
subtrees:
9884
- entries:
99-
- file: plugins/virtual_environment_docs/1-virtual-environments
100-
- file: plugins/virtual_environment_docs/2-deploying-your-plugin
101-
- file: plugins/virtual_environment_docs/3-version-management
102-
- file: plugins/virtual_environment_docs/4-developer-tools
103-
- file: plugins/virtual_environment_docs/5-survey
85+
- file: plugins/building_a_plugin/first_plugin
86+
- file: plugins/building_a_plugin/guides
87+
- file: plugins/building_a_plugin/debug_plugins
88+
- file: plugins/building_a_plugin/best_practices
89+
- file: plugins/virtual_environment_docs/index
90+
subtrees:
91+
- entries:
92+
- file: plugins/virtual_environment_docs/1-virtual-environments
93+
- file: plugins/virtual_environment_docs/2-deploying-your-plugin
94+
- file: plugins/virtual_environment_docs/3-version-management
95+
- file: plugins/virtual_environment_docs/4-developer-tools
96+
- file: plugins/virtual_environment_docs/5-survey
97+
- file: plugins/testing_and_publishing/index
98+
subtrees:
99+
- entries:
100+
- file: plugins/testing_and_publishing/test
101+
- file: plugins/testing_and_publishing/deploy
102+
- file: plugins/testing_workshop_docs/index
103+
subtrees:
104+
- entries:
105+
- file: plugins/testing_workshop_docs/1-pythons-assert-keyword
106+
- file: plugins/testing_workshop_docs/2-pytest-testing-frameworks
107+
- file: plugins/testing_workshop_docs/3-readers-and-fixtures
108+
- file: plugins/testing_workshop_docs/4-test-coverage
109+
- file: plugins/testing_workshop_docs/testing-resources
110+
- file: plugins/advanced_topics/index
111+
subtrees:
112+
- entries:
113+
- file: plugins/advanced_topics/npe2_migration_guide
114+
- file: plugins/advanced_topics/npe1
115+
- file: plugins/technical_references/index
116+
subtrees:
117+
- entries:
118+
- file: plugins/technical_references/manifest
119+
- file: plugins/technical_references/contributions
104120
- file: community/index
105121
subtrees:
106122
- titlesonly: True

docs/developers/documentation/docs_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,4 @@ words to capitalize in your headings (spoiler - we use sentence case for our hea
144144
## Next steps
145145
- Use this section to link to other (maybe more advanced?) tutorials, further reading on any complex topics you mentioned,
146146
or other relevant documentation
147-
- Now that you've written your document, you can proceed with [updating the TOC](./index.md#2-update-toc)
147+
- Now that you've written your document, you can proceed with [updating the TOC](update-toc)

docs/developers/documentation/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ We will use Ubuntu for this guide since it is the default WSL distribution, easy
461461
6. You can test that all of this OpenGL setup is working by running `glxgears` from the Ubuntu terminal. You should see a window with some gears spinning.
462462
7. `sudo apt install fontconfig`.
463463
8. `pip install pyqt5-tools`.
464-
9. Fork the napari docs repository and clone it to the same parent folder as the napari repository (see [](#prerequisites)). Then navigate to the napari docs folder via `cd napari-docs`.
464+
9. Fork the napari docs repository and clone it to the same parent folder as the napari repository (see [](prerequisites)). Then navigate to the napari docs folder via `cd napari-docs`.
465465
10. Install `make` with `sudo apt install make`.
466466
11. Run `make docs` or other `make` commands to build the documentation.
467467

docs/plugins/advanced_topics/index.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Advanced Topics
2+
3+
Advanced topics for plugin developers around the deprecated first generation napari plugins, and how to move to the new system.
4+
5+
::::{grid}
6+
:::{grid-item-card} Migration guide to `npe2`
7+
:link: npe2-migration-guide
8+
:link-type: ref
9+
Have a plugin written for the first generation plugin system? This guide will help you migrate to the new plugin system.
10+
11+
:::
12+
13+
:::{grid-item-card} First generation plugin system
14+
:link: napari-plugin-engine
15+
:link-type: ref
16+
17+
A guide to the first generation plugin system. This is now deprecated and should not be used for new plugins.
18+
19+
:::
20+
::::

docs/plugins/npe1.md renamed to docs/plugins/advanced_topics/npe1.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(napari-plugin-engine)=
2-
# 1st Gen Plugin Guide (*Deprecated*)
2+
# First generation plugins (*Deprecated*)
33

44
```{Admonition} DEPRECATED
55
:class: warning
@@ -209,7 +209,7 @@ functionality by simply installing your package along with napari:
209209
(plugin-sharing)=
210210
### Step 4: Deploy your plugin
211211

212-
See [testing and deploying](./test_deploy) your plugin. (This hasn't changed
212+
See [testing and deploying](plugin-test-deploy) your plugin. (This hasn't changed
213213
significantly with the secod generation (`npe2`) plugin engine).
214214

215215

docs/plugins/npe2_migration_guide.md renamed to docs/plugins/advanced_topics/npe2_migration_guide.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(npe2-migration-guide)=
22

3-
# `npe2` migration guide
3+
# Migration to `npe2`
44

55
This document details how to convert a plugin using the first generation
66
`napari-plugin-engine`, to the new `npe2` format.
@@ -9,8 +9,7 @@ The primary difference between the first generation and second generation plugin
99
system relates to how napari *discovers* plugin functionality. In the first
1010
generation plugin engine, napari had to *import* plugin modules to search for
1111
hook implementations decorated with `@napari_hook_implementation`. In `npe2`,
12-
plugins declare their contributions *statically* with a [manifest
13-
file](./manifest).
12+
plugins declare their contributions *statically* with a [manifest file](../technical_references/manifest).
1413

1514
## Migrating using the `npe2` command line tool
1615

@@ -77,7 +76,7 @@ Executing `npe2 convert .` will **modify** the current directory!
7776
The `npe2 convert` command will:
7877

7978
1. Inspect your plugin for hook implementations, and generate an npe2-compatible
80-
[manifest file](./manifest), called `napari.yaml`.
79+
[manifest file](../technical_references/manifest), called `napari.yaml`.
8180
2. **Modify** your `setup.cfg` to use the new `napari.manifest` entry point, and
8281
include the manifest file in your package data.
8382

@@ -93,7 +92,7 @@ If you have any napari_plugin_engine imports or hook_implementation decorators,
9392
```
9493

9594
You are encouraged to inspect the newly-generated `napari.yaml` file. Refer to
96-
the [manifest](./manifest) and [contributions](./contributions) references pages
95+
the [manifest](../technical_references/manifest) and [contributions](../technical_references/contributions) references pages
9796
for details on each field in the manifest.
9897

9998
```{note}
@@ -124,14 +123,14 @@ The next time napari is run, your plugin should be discovered as an
124123
> *This section goes into detail on the differences between first-generation and
125124
second-generation implementations. In many cases, this will be more detail than
126125
you need. If you are still struggling with a specific conversion after using
127-
`npe2 convert` and reading the [contributions](./contributions) reference and
128-
[guides](./guides), this section may be of help.*
126+
`npe2 convert` and reading the [contributions](../technical_references/contributions) reference and
127+
[guides](../building_a_plugin/guides), this section may be of help.*
129128

130129

131130
Existing `napari-plugin-engine` plugins expose functionality via *hook
132131
implementations*. These are functions decorated to indicate they fullfil a
133132
*hook specification* described by napari. Though there are some exceptions,
134-
most *hook implementations* can be straightforwardly mapped to npe2 [contributions](./contributions)
133+
most *hook implementations* can be straightforwardly mapped to npe2 [contributions](../technical_references/contributions)
135134

136135
`npe2` provides a command-line tool that will generate plugin manifests by
137136
inspecting exposed *hook implementations*. Below, we will walk through the
@@ -140,7 +139,7 @@ kinds of migrations `npe2 convert` helps with.
140139
For each type of *hook specification* there is a corresponding section below
141140
with migration tips. Each lists the *hook specifications* that are relevant to
142141
that section and an example manifest. For details, refer to the
143-
[Contributions references](./contributions).
142+
[Contributions references](../technical_references/contributions).
144143

145144
### Readers
146145

docs/plugins/best_practices.md renamed to docs/plugins/building_a_plugin/best_practices.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ dedicated to the stability of your plugin. Aim for 100%!
209209
Of course, simply having 100% coverage doesn't mean your code is bug-free, so
210210
make sure that you test all of the various ways that your code might be called.
211211

212-
See our [Tips for testing napari plugins](plugin-testing-tips).
212+
See [Tips for testing napari plugins](plugin-testing-tips).
213213

214214
### How to check test coverage?
215215

docs/plugins/debug_plugins.md renamed to docs/plugins/building_a_plugin/debug_plugins.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ To quickly get started with debugging your plugin, you can do the following:
3535
4. Run the created napari launch script in debug mode. For example, in VSCode, you can do this by opening the script in the editor, [selecting your napari virtual environment as the python interpreter](https://code.visualstudio.com/docs/python/environments) and then clicking the `Run and Debug` button in the left hand toolbar, selecting `Python: File` as the run configuration.
3636
5. At a breakpoint or exception (in VSCode, tick the `Raised Exceptions` box in the bottom left under the `Breakpoints` menu to see exceptions) you can then step through the code, inspect variables, and see the state of the napari viewer and your plugin. When you are done done debugging hit the continue button and napari will resume normal execution. See the image below for an example of a napari plugin debugging session in VSCode paused on a breakpoint.
3737

38-
![debugging_in_vscode](../images/vs_code_debug.png)
38+
![debugging_in_vscode](../../images/vs_code_debug.png)
3939

4040
## Debugging plugin start-up issues
4141

@@ -199,7 +199,7 @@ Running `python reproduce_issue.py` will run our widget for the inputs `False, 0
199199

200200
## Isolate the issue from napari
201201

202-
This solution ties in with the idea of test-driven development (see the [napari testing guidelines](./test_deploy.md#prefer-smaller-unit-tests-when-possible)). The idea is to trust that napari will provide the information you expect it to, and test your widgets independently of the viewer. In the case above we can verify that input values work as expected like so:
202+
This solution ties in with the idea of test-driven development (see the [napari testing guidelines](../testing_and_publishing/test.md#prefer-smaller-unit-tests-when-possible)). The idea is to trust that napari will provide the information you expect it to, and test your widgets independently of the viewer. In the case above we can verify that input values work as expected like so:
203203

204204
```Python
205205
# test_print.py
@@ -216,7 +216,7 @@ if __name__ == "__main__":
216216
test_false_inputs()
217217
```
218218

219-
Then, for `python test_print.py` you can use any of your usual debugging tools - such as the visual debugger provided by a Python IDE (e.g. PyCharm, VSCode, or Spyder). Further, an isolated test like this can be integrated into a [testing suite for your napari plugin](test_deploy).
219+
Then, for `python test_print.py` you can use any of your usual debugging tools - such as the visual debugger provided by a Python IDE (e.g. PyCharm, VSCode, or Spyder). Further, an isolated test like this can be integrated into a [testing suite for your napari plugin](plugin-test-deploy).
220220

221221
## Logging and user messages in napari
222222

docs/plugins/first_plugin.md renamed to docs/plugins/building_a_plugin/first_plugin.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Your First Plugin
1+
(your-first-plugin)=
2+
# Your first plugin
23

34
In this tutorial, we'll step through the fundamental concepts for building a
45
**bare minimum** "hello napari" plugin from scratch.
@@ -33,8 +34,8 @@ installing napari.
3334

3435
Napari plugins are just Python packages. *Minimally*, they must:
3536

36-
1. Include a static [plugin manifest](./manifest) file that details the
37-
[contributions](./contributions) contained in the plugin.
37+
1. Include a static [plugin manifest](../technical_references/manifest) file that details the
38+
[contributions](../technical_references/contributions) contained in the plugin.
3839
2. Declare a `napari.manifest` [entry point][entry_points] that allows
3940
napari to detect the plugin at runtime.
4041

@@ -177,7 +178,7 @@ autogeneration capabilities to turn this function into a widget)*
177178
### Add a `napari.yaml` manifest
178179

179180

180-
If you haven't already, create an empty [plugin manifest](./manifest) file at `napari_hello/napari.yaml`
181+
If you haven't already, create an empty [plugin manifest](../technical_references/manifest) file at `napari_hello/napari.yaml`
181182
We will use this file to tell napari:
182183

183184
1. That our plugin contributes a [**command**](contributions-commands)
@@ -293,11 +294,11 @@ cookiecutter https://github.com/napari/cookiecutter-napari-plugin
293294

294295
Plugins can do a lot more than just say hi! You can see the complete list
295296
of available contributions and their fields in the
296-
[Contributions Reference](./contributions), and learn more about each
297-
specific contribution type in the [Guides](./guides).
297+
[Contributions Reference](../technical_references/contributions), and learn more about each
298+
specific contribution type in the [Guides](../building_a_plugin/guides).
298299

299-
Review the [Best Practices](./best_practices) when developing plugins and,
300-
when you're ready to share your plugin, see [Testing and Deployment](./test_deploy).
300+
Review the [Best Practices](../building_a_plugin/best_practices) when developing plugins and,
301+
when you're ready to share your plugin, see [Testing and Publishing](../testing_and_publishing/index).
301302

302303
[miniconda]: https://docs.conda.io/projects/conda/en/latest/user-guide/install/download.html
303304
[python_env]: https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-python

docs/plugins/guides.md renamed to docs/plugins/building_a_plugin/guides.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
# Contribution Guides
1+
(plugin-contribution-guides)=
2+
# Plugin contributions
23

34
This page provides guides on many of the plugin contribution patterns.
45
Each provides a general overview of the purpose of the contribution and
56
an example implementation. For details on the type and meaning of each
67
field in a specific contribution, See the
7-
[contributions reference](./contributions)
8+
[contributions reference](../technical_references/contributions)
89

910

10-
```{include} _npe2_readers_guide.md
11+
```{include} ../_npe2_readers_guide.md
1112
```
1213
----------------
1314

14-
```{include} _npe2_writers_guide.md
15+
```{include} ../_npe2_writers_guide.md
1516
```
1617
----------------
1718

18-
```{include} _npe2_widgets_guide.md
19+
```{include} ../_npe2_widgets_guide.md
1920
```
2021
----------------
2122

22-
```{include} _npe2_sample_data_guide.md
23+
```{include} ../_npe2_sample_data_guide.md
2324
```
2425
----------------
2526

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
(how-to-build-a-plugin)=
2+
# Building a plugin
3+
4+
Plugins allow developers to customize and extend napari. This includes
5+
6+
- Adding file format support with [readers] and [writers]
7+
- Adding custom [widgets] and user interface elements
8+
- Providing [sample data][sample_data]
9+
- Changing the look of napari with a color [theme]
10+
11+
::::{grid}
12+
:::{grid-item-card} Your first plugin
13+
:link: your-first-plugin
14+
:link-type: ref
15+
If you're just getting started with napari plugins, try our tutorial to build your first plugin!
16+
17+
:::
18+
19+
:::{grid-item-card} Plugin functionality
20+
:link: plugin-contribution-guides
21+
:link-type: ref
22+
23+
New pieces of functionality are termed contributions. To understand what plugins can add to napari, see the plugin contributions guide.
24+
25+
:::
26+
::::
27+
28+
::::{grid}
29+
:::{grid-item-card} Best practices
30+
:link: best-practices
31+
:link-type: ref
32+
33+
There are a few best practices to keep in mind when building a plugin. See the best practices guide for details.
34+
35+
:::
36+
37+
:::{grid-item-card} Testing and publishing
38+
:link: plugin-test-deploy
39+
:link-type: ref
40+
41+
Testing your plugin is an important step before publishing. Once your plugin is ready, you can publish it to PyPI, conda-forge and the napari-hub. See the testing and publishing guide for details.
42+
:::
43+
::::
44+
45+
```{admonition} Introducing npe2
46+
:class: important
47+
48+
We introduced a new plugin engine [`npe2`][npe2] in December 2021.
49+
50+
Unless otherwise stated, most of the documentation herein pertains
51+
to the new npe2 format (which uses a static `napari.yaml` manifest)
52+
53+
Plugins targeting the first generation `napari-plugin-engine`
54+
(using `@napari_hook_implementation` decorators, see [npe1]) will
55+
continue to work for at least the first half of 2022, but we
56+
recommend migrating to `npe2`. See the
57+
[migration guide](npe2-migration-guide) for details.
58+
```
59+
60+
[npe1]: https://github.com/napari/napari-plugin-engine
61+
[npe2]: https://github.com/napari/npe2
62+
[readers]: contributions-readers
63+
[writers]: contributions-writers
64+
[widgets]: contributions-widgets
65+
[sample_data]: contributions-sample-data
66+
[theme]: contributions-themes

docs/plugins/contributions.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)