Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 522735f

Browse files
committedApr 29, 2022
Add API docs
1 parent 50575af commit 522735f

File tree

8 files changed

+74
-30
lines changed

8 files changed

+74
-30
lines changed
 

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ instance/
6060
# Sphinx documentation
6161
docs/_build/
6262
docs/auto_examples
63+
docs/api
6364

6465
# MkDocs documentation
6566
/site/

‎docs/api.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
API reference
2+
=============
3+
This section documents the internal API of ``napari-matplotlib`` classes.
4+
Most users shouldn't need this, and will just directly interact with the
5+
plots though the napari user interface.
6+
7+
8+
.. automodapi:: napari_matplotlib
9+
10+
.. automodapi:: napari_matplotlib.base
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
HistogramWidget
2+
===============
3+
4+
.. currentmodule:: napari_matplotlib
5+
6+
.. autoclass:: HistogramWidget
7+
:show-inheritance:
8+
9+
.. rubric:: Methods Summary
10+
11+
.. autosummary::
12+
13+
~HistogramWidget.hist_current_layer
14+
~HistogramWidget.update_layer
15+
16+
.. rubric:: Methods Documentation
17+
18+
.. automethod:: hist_current_layer
19+
.. automethod:: update_layer

‎docs/conf.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,20 @@
2727
# Add any Sphinx extension module names here, as strings. They can be
2828
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
2929
# ones.
30-
extensions = ["sphinx_gallery.gen_gallery"]
30+
extensions = [
31+
"numpydoc",
32+
"sphinx_gallery.gen_gallery",
33+
"sphinx_automodapi.automodapi",
34+
]
3135

3236
sphinx_gallery_conf = {
3337
"filename_pattern": ".",
3438
"image_scrapers": (qtgallery.qtscraper,),
3539
"reset_modules": (qtgallery.reset_qapp,),
3640
}
3741

42+
numpydoc_show_class_members = False
43+
3844
# Add any paths that contain templates here, relative to this directory.
3945
templates_path = ["_templates"]
4046

‎docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Welcome to matplotlib-napari's documentation!
1111
:caption: Contents:
1212

1313
auto_examples/index
14+
api
1415

1516

1617

‎setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ napari.manifest =
4949

5050
[options.extras_require]
5151
docs =
52+
numpydoc
5253
pydata-sphinx-theme
5354
qtgallery
5455
sphinx
56+
sphinx-automodapi
5557
sphinx-gallery
5658
testing =
5759
napari[pyqt5]

‎src/napari_matplotlib/_widget.py

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,9 @@
11
import napari
22
import numpy as np
3-
from matplotlib.backends.backend_qt5agg import FigureCanvas
4-
from matplotlib.figure import Figure
5-
from qtpy.QtWidgets import QVBoxLayout, QWidget
6-
7-
__all__ = ["HistogramWidget"]
83

4+
from .base import NapariMPLWidget
95

10-
class NapariMPLWidget(QWidget):
11-
"""
12-
Attributes
13-
----------
14-
viewer : napari.viewer.Viewer
15-
Main napari viewer.
16-
figure : matplotlib.figure.Figure
17-
Matplotlib figure.
18-
canvas : matplotlib.backends.backend_qt5agg.FigureCanvas
19-
Matplotlib canvas.
20-
axes : matplotlib.axes.Axes
21-
Matplotlib axes.
22-
"""
23-
24-
def __init__(self, napari_viewer: napari.viewer.Viewer):
25-
super().__init__()
26-
27-
self.viewer = napari_viewer
28-
self.figure = Figure(figsize=(5, 3), tight_layout=True)
29-
self.canvas = FigureCanvas(self.figure)
30-
self.axes = self.canvas.figure.subplots()
31-
32-
self.setLayout(QVBoxLayout())
33-
self.layout().addWidget(self.canvas)
6+
__all__ = ["HistogramWidget"]
347

358

369
class HistogramWidget(NapariMPLWidget):

‎src/napari_matplotlib/base.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import napari
2+
from matplotlib.backends.backend_qt5agg import FigureCanvas
3+
from matplotlib.figure import Figure
4+
from qtpy.QtWidgets import QVBoxLayout, QWidget
5+
6+
__all__ = ["NapariMPLWidget"]
7+
8+
9+
class NapariMPLWidget(QWidget):
10+
"""
11+
Attributes
12+
----------
13+
viewer : napari.viewer.Viewer
14+
Main napari viewer.
15+
figure : matplotlib.figure.Figure
16+
Matplotlib figure.
17+
canvas : matplotlib.backends.backend_qt5agg.FigureCanvas
18+
Matplotlib canvas.
19+
axes : matplotlib.axes.Axes
20+
Matplotlib axes.
21+
"""
22+
23+
def __init__(self, napari_viewer: napari.viewer.Viewer):
24+
super().__init__()
25+
26+
self.viewer = napari_viewer
27+
self.figure = Figure(figsize=(5, 3), tight_layout=True)
28+
self.canvas = FigureCanvas(self.figure)
29+
self.axes = self.canvas.figure.subplots()
30+
31+
self.setLayout(QVBoxLayout())
32+
self.layout().addWidget(self.canvas)

0 commit comments

Comments
 (0)
Please sign in to comment.