-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Examples gallery for napari-threedee (#104)
* Move example scripts into docs directory, is a limitation of mkdocs-gallery * Docstrings with RST headings are required for mkdocs-gallery * Correct name of plugin widget for example script * Update gallery readme headings * Include ALL example script directories in gallery * Shorter headings that fit in docs sidebar * Pin mkdocs to 1.2.4 due to mkdocs-gallery issue smarie/mkdocs-gallery#57 * Add issue link as comment, so we know when to remove the pin * Fix merge conflict * Run mesh_headlight examples now bug is fixed * Verbose output of installed packages in CI * Add napari to dev requirments, we need it to build the examples gallery * Remember to install a backend for napari * Use Talley's github action to setup qt properly in remote env * Use Ashley Anderson's headless GUI action for napari on CI * Fix .github workflow formatting error * Try to fix github CI workflow formatting again * Make docs build strict about any errors * Prevent filename conflicts with example scripts * mkdocs-gallery uses recursive search, don't duplicate directories here * Add link to example gallery from README
- Loading branch information
1 parent
3c83e96
commit 1aa50dd
Showing
25 changed files
with
195 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ docs/_build/ | |
|
||
# MkDocs documentation | ||
/site/ | ||
/docs/generated/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Gallery for napari-threedee | ||
|
||
Gallery of examples built with napari-threedee. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Library examples | ||
|
||
Examples where napari-threedee is used as a library. |
7 changes: 7 additions & 0 deletions
7
examples/library/camera_spline.py → ...examples/library/camera_spline_library.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/library/layer_manipulator.py → ...ples/library/layer_manipulator_library.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/library/mesh_headlight.py → ...xamples/library/mesh_headlight_library.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/library/point_annotator.py → ...amples/library/point_annotator_library.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/library/render_plane_manipulator.py → ...brary/render_plane_manipulator_library.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/library/sphere_annotator.py → ...mples/library/sphere_annotator_library.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/library/spline_annotator.py → ...mples/library/spline_annotator_library.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/library/surface_annotator.py → ...ples/library/surface_annotator_library.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Plugin examples | ||
|
||
Examples where napari-threedee is used as a napari plugin. |
7 changes: 7 additions & 0 deletions
7
examples/plugin/camera_spline.py → docs/examples/plugin/camera_spline_plugin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/plugin/layer_manipulator.py → ...amples/plugin/layer_manipulator_plugin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/plugin/mesh_headlight.py → .../examples/plugin/mesh_headlight_plugin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/plugin/plane_point_annotator.py → ...examples/plugin/point_annotator_plugin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
examples/plugin/points_manipulator.py → ...mples/plugin/points_manipulator_plugin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/plugin/render_plane_manipulator.py → ...plugin/render_plane_manipulator_plugin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/plugin/spline_annotator.py → ...xamples/plugin/spline_annotator_plugin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from pathlib import Path | ||
import warnings | ||
|
||
from mkdocs_gallery.scrapers import figure_md_or_html, matplotlib_scraper | ||
from mkdocs_gallery.gen_data_model import GalleryScript | ||
import napari | ||
import qtgallery | ||
|
||
warnings.filterwarnings("ignore", category=DeprecationWarning) | ||
|
||
|
||
def napari_image_scraper(block, script: GalleryScript): | ||
"""Scrape screenshots from napari windows. | ||
Parameters | ||
---------- | ||
block : tuple | ||
A tuple containing the (label, content, line_number) of the block. | ||
script : GalleryScript | ||
Script being run | ||
Returns | ||
------- | ||
md : str | ||
The ReSTructuredText that will be rendered to HTML containing | ||
the images. This is often produced by :func:`figure_md_or_html`. | ||
""" | ||
viewer = napari.current_viewer() | ||
if viewer is not None: | ||
image_path = next(script.run_vars.image_path_iterator) | ||
screenshot = viewer.screenshot(canvas_only=False, flash=False, path=image_path) | ||
viewer.close() | ||
return figure_md_or_html([image_path], script) | ||
else: | ||
return "" | ||
|
||
|
||
def _reset_napari(gallery_conf, file: Path): | ||
# Close all open napari windows and reset theme | ||
while napari.current_viewer() is not None: | ||
napari.current_viewer().close() | ||
settings = napari.settings.get_settings() | ||
settings.appearance.theme = 'dark' | ||
# qtgallery manages the event loop so it | ||
# is not completely blocked by napari.run() | ||
qtgallery.reset_qapp(gallery_conf, file) | ||
|
||
|
||
conf = { | ||
"image_scrapers": [napari_image_scraper, matplotlib_scraper], | ||
"reset_modules": [_reset_napari], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters