Skip to content

Commit 1765cc6

Browse files
committed
Use intersphinx everywhere.
1 parent eb41b94 commit 1765cc6

30 files changed

+553
-513
lines changed

docs/source/Figures.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
Figures
22
==================
33

4-
Figures, typically abbreviated to `figs`, are the window that you plot into. This
5-
section outlines:
4+
Figures, typically abbreviated to ``fig``, are the window that you plot into.
5+
This section outlines:
66

77
* Their creation.
88
* General figure management.
99
* Functions for controlling the camera position.
1010
* Screenshotting the figure contents to a frozen image (file).
11-
* Embedding a figure into PyQt5.
11+
* Embedding a figure into PyQt5_.
1212

1313
Overview
1414
--------
1515

16-
Some of this is handled automatically. There is a global "current working figure".
17-
This can be get and set using ``vpl.gcf()`` and ``vpl.scf(fig)``. If it doesn't
16+
Some of this is handled automatically. There is a global *current working figure*.
17+
This can be get and set using `gcf()` and `scf(fig) <scf>`. If it doesn't
1818
exist then it is automatically created. Each plot command will add itself to the
1919
current working figure unless explicitly told not by setting ``fig=None`` or
2020
``fig=alternative_fig`` in the plot command. The figure is shown using
21-
``vpl.show()`` or ``fig.show()``. After the shown figure is closed it ceases to
21+
`vtkplotlib.show` or ``fig.show()``. After the shown figure is closed it ceases to
2222
be the current working figure but you can use it by referencing it explicitly.
2323
Figures can be reshown indefinitely and should be exactly as you left them on
2424
close.
@@ -35,7 +35,7 @@ show
3535
figure
3636
-----------------
3737

38-
.. autoclass:: vtkplotlib.figure
38+
.. autofunction:: vtkplotlib.figure
3939

4040

4141
--------------

docs/source/Interactive.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1+
.. py:currentmodule:: vtkplotlib.interactive
2+
3+
.. module:: vtkplotlib.i
4+
15
.. automodule:: vtkplotlib.interactive
6+

docs/source/Plots.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ polygon
4646
scalar_bar
4747
---------------------
4848

49+
.. py:function:: vtkplotlib.color_bar
4950
.. autofunction:: vtkplotlib.scalar_bar
5051

5152

@@ -110,6 +111,6 @@ legend
110111
custom plots using PolyData
111112
---------------------------
112113

113-
.. autofunction:: vtkplotlib.PolyData
114+
.. autoclass:: vtkplotlib.PolyData
114115

115116

docs/source/conf.py

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# import os
1616
# import sys
1717
# sys.path.insert(0, os.path.abspath('.'))
18+
from sphinx.application import Sphinx
1819

1920
# -- Project information -----------------------------------------------------
2021

@@ -43,6 +44,7 @@
4344
'sphinx.ext.coverage',
4445
'sphinx.ext.mathjax',
4546
'sphinx.ext.githubpages',
47+
'sphinx.ext.intersphinx',
4648
'sphinx_copybutton',
4749
'm2r2',
4850
'sphinx_rtd_theme_configuration',
@@ -89,11 +91,6 @@
8991
#
9092
# html_theme_options = {}
9193

92-
# Add any paths that contain custom static files (such as style sheets) here,
93-
# relative to this directory. They are copied after the builtin static files,
94-
# so a file named "default.css" will overwrite the builtin "default.css".
95-
html_static_path = ['_static']
96-
9794
# Custom sidebar templates, must be a dictionary that maps document names
9895
# to template names.
9996
#
@@ -219,9 +216,56 @@ def add_url(name, url):
219216
.. _namegenerator: https://pypi.org/project/namegenerator/
220217
"""
221218

219+
rst_prolog = """
220+
.. py:currentmodule:: vtkplotlib
221+
"""
222+
222223
# -- Add this file for Google search console ----------
223224
html_extra_path = ["google77eb9775385691af.html"]
224225

225226
# --- Option for autosectionlabel --------
226227

227228
autosectionlabel_prefix_document = True
229+
230+
# --- Intersphinx cross refrerneces ---
231+
232+
# Warn if a cross reference is not found.
233+
nitpicky = True
234+
235+
# Other projects' website roots so that they can be cross referenced.
236+
intersphinx_mapping = {
237+
'python': ('http://docs.python.org/3', None),
238+
'numpy': ('https://numpy.org/doc/stable/', None),
239+
'scipy': ('https://docs.scipy.org/doc/scipy/', None),
240+
'PyQt5': ('https://www.riverbankcomputing.com/static/Docs/PyQt5/', None),
241+
'wxPython': ('https://docs.wxpython.org/', None),
242+
'matplotib': ('https://matplotlib.org', None),
243+
'pillow': ('https://pillow.readthedocs.io/en/stable/', None),
244+
}
245+
246+
247+
def setup(app):
248+
# type: (Sphinx) -> None
249+
250+
# PyQt5 has all its cross reference targets in a special :sip: domain which
251+
# needs to be registered to be used. Don't ask me how this works. It's
252+
# mostly guess work and copy/paste from sphinx.domains.c.CDomain.
253+
254+
import sphinx.roles
255+
from sphinx.domains import Domain, ObjType, _
256+
257+
class SIPDomain(Domain):
258+
name = "sip"
259+
label = "sip"
260+
object_types = {
261+
key: ObjType(_(key), key, 'data', 'identifier', 'type')
262+
for key in "attribute class enum member method module signal".split()
263+
}
264+
265+
app.add_domain(SIPDomain)
266+
for key in SIPDomain.object_types:
267+
app.add_role_to_domain("sip", key, sphinx.roles.XRefRole())
268+
269+
270+
# Set the default interpretation of `foo` to :any:`foo`.
271+
default_role = "any"

docs/source/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
You can adapt this file completely to your liking, but it should at least
44
contain the root `toctree` directive.
55
6+
.. module:: vtkplotlib
7+
68
Welcome to vtkplotlib's documentation!
79
======================================
810

docs/source/lookup_example.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Looking up original data
33
========================
44

5+
.. py:currentmodule:: vtkplotlib.interactive
6+
57
The coordinates given by :attr:`pick.point` interpolate between vertices you
68
have provided. If you require the nearest user-provided coordinate then you must
79
implement this yourself.
@@ -62,7 +64,7 @@ Or, for time-critical applications, using a KDTree from either
6264
6365
fig.show()
6466
65-
Note that having a `MouseMoveEvent` which modifies the contents of a figure and
67+
Note that having a ``MouseMoveEvent`` which modifies the contents of a figure and
6668
therefore requires ``fig.update()`` to be called for every such event requires a
6769
lot of processing power. A better option is to use an output outside of the
68-
renderer such as a :meth:`QtWidgets.QLabel`.
70+
renderer such as a `PyQt5.QtWidgets.QLabel`.

docs/source/quickstart.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Line plots:
161161
import numpy as np
162162
163163
# Create some kind of wiggly shape
164-
# use ``vpl.zip_axes`` to combine (x, y, z) axes
164+
# use ``vpl.zip_axes()`` to combine (x, y, z) axes
165165
t = np.linspace(0, 2 * np.pi, 300)
166166
points = vpl.zip_axes(np.cos(2 * t),
167167
np.sin(3 * t),
@@ -196,7 +196,7 @@ the first.
196196
Mesh plots:
197197
^^^^^^^^^^^^^^^^^^^^^^^
198198

199-
.. autoclass:: vtkplotlib.plots.MeshPlot.MeshPlot
199+
.. autofunction:: vtkplotlib.mesh_plot
200200
:noindex:
201201

202202

docs/source/super_callbacks.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
Super Callbacks
33
***************
44

5-
The methods :meth:`get_super_callback` and :meth:`call_super_callback` get and
5+
.. py:currentmodule:: vtkplotlib.interactive
6+
7+
The methods :func:`get_super_callback` and :func:`call_super_callback` get and
68
call VTK's original responses to user interactions which may have been
79
overwritten. See :ref:`Interactive:Super Callbacks?` for why you need them and
810
where to use them.
911

10-
.. autofunction:: vtkplotlib.interactive.get_super_callback()
12+
.. autofunction:: get_super_callback
1113

12-
.. autofunction:: vtkplotlib.interactive.call_super_callback()
14+
.. autofunction:: call_super_callback
1315

14-
.. autoexception:: vtkplotlib.interactive.SuperError()
16+
.. autoexception:: SuperError
1517
:show-inheritance:
1618

17-
.. autofunction:: vtkplotlib.interactive.null_super_callback()
19+
.. autofunction:: null_super_callback

vtkplotlib/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
def quick_test_plot(fig="gcf"):
6868
"""A quick laziness function to create 30 random spheres.
6969
70-
:param fig: The figure to plot into, can be None, defaults to :meth:`vtkplotlib.gcf`.
71-
:type fig: :class:`vtkplotlib.figure`, :class:`vtkplotlib.QtFigure`, optional
70+
:param fig: The figure to plot into, use `None` for no figure, defaults to the output of `vtkplotlib.gcf()`.
71+
:type fig: :class:`~vtkplotlib.figure` or :class:`~vtkplotlib.QtFigure`
7272
7373
.. code-block:: python
7474

vtkplotlib/_image_io.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,24 @@ def read(path, raw_bytes=None, format=None, convert_to_array=True):
4343
"""Read an image from a file using one of VTK's ``vtkFormatReader`` classes
4444
where ``Format`` is replaced by JPEG, PNG, BMP or TIFF.
4545
46-
:param path: Filename or file handle or ``None`` if using the **raw_bytes** argument.
46+
:param path: Filename or file handle or `None` if using the **raw_bytes** argument.
4747
:type path: str, os.PathLike, io.BytesIO
4848
49-
:param raw_bytes: Image compressed binary data, defaults to ``None``.
50-
:type raw_bytes: bytes, optional
49+
:param raw_bytes: Image compressed binary data.
50+
:type raw_bytes: bytes
5151
52-
:param format: Image format extension (e.g. jpg), not needed if format can be determined from **path**, defaults to ``None``.
53-
:type format: str, optional
52+
:param format: Image format extension (e.g. jpg). This should never be needed.
53+
:type format: str
5454
55-
:param convert_to_array: If true, convert to numpy, otherwise leave as vtkImageData, defaults to ``True``.
56-
:type convert_to_array: bool, optional
55+
:param convert_to_array: If true, convert to `numpy.ndarray`, otherwise leave as vtkImageData_.
56+
:type convert_to_array: bool
5757
5858
:return: Read image.
59-
:rtype: np.ndarray or `vtkImageData`_
59+
:rtype: `numpy.ndarray` or `vtkImageData`_
6060
6161
The file format can be determined automatically from the **path** suffix or the beginning
6262
of **raw_bytes**. **format** can be any of JPEG, PNG, TIFF, BMP. It is case
63-
insensitive, tolerant to preceding '.'s e.g. ``format=".jpg"`` and
63+
insensitive, tolerant to preceding ``'.'`` e.g. ``format=".jpg"`` and
6464
understands the aliases JPG \u21d4 JPEG and TIF \u21d4 TIFF.
6565
6666
The following demonstrates how to use pseudo file objects to avoid temporary
@@ -70,7 +70,7 @@ def read(path, raw_bytes=None, format=None, convert_to_array=True):
7070
7171
import vtkplotlib as vpl
7272
73-
# Link you're image url here
73+
# Link your image url here
7474
url = "https://raw.githubusercontent.com/bwoodsend/vtkplotlib/master/vtkplotlib/data/icons/Right.jpg"
7575
7676
# You can make the url request with either:
@@ -81,7 +81,7 @@ def read(path, raw_bytes=None, format=None, convert_to_array=True):
8181
# import requests
8282
# raw_bytes = requests.get(url).content
8383
84-
# Pass the bytes to :meth:`read` using:
84+
# Pass the bytes to `read()` using:
8585
image = vpl.image_io.read(path=None, raw_bytes=raw_bytes)
8686
8787
# Visualize using matplotlib.
@@ -190,22 +190,22 @@ def write(arr, path, format=None, quality=95):
190190
"""Write an image from a file using one of VTK's ``vtkFormatWriter`` classes
191191
where ``Format`` is replaced by JPEG or PNG.
192192
193-
:param arr: **arr** can be a `vtkImageData`_ or a numpy array.
194-
:type arr: np.ndarray
193+
:param arr: An image array.
194+
:type arr: `numpy.ndarray` or `vtkImageData`_
195195
196196
:param path: File path to write to.
197-
:type path: str, os.Pathlike, io.BytesIO,
197+
:type path: str or os.PathLike or io.BytesIO
198198
199-
:param format: Image format extension (e.g. jpg), not needed if format can be determined from **path**, defaults to ``None``.
200-
:type format: str, optional
199+
:param format: Image format extension (e.g. jpg), not needed if format can be determined from **path**.
200+
:type format: str
201201
202-
:param quality: Lossy compression quality, only applicable to JPEGs, defaults to 95.
203-
:type quality: int from 0 to 100, optional
202+
:param quality: Lossy compression quality (only applicable to JPEGs) between 0 to 100.
203+
:type quality: int
204204
205-
:return: The raw image binary if ``path is None``, ``NotImplemented`` if the filetype is unknown. Otherwise no return value.
205+
:return: The raw image binary if ``path is None``, `NotImplemented` if the filetype is unknown. Otherwise no return value.
206206
:rtype: bytes
207207
208-
See :meth:`read` for more information.
208+
See `read` for more information.
209209
210210
.. note::
211211
@@ -247,7 +247,7 @@ def write(arr, path, format=None, quality=95):
247247
def vtkimagedata_to_array(image_data):
248248
"""Convert a vtkImageData to numpy array.
249249
250-
.. seealso:: :meth:`vtkimagedata_from_array` for the reverse.
250+
.. seealso:: `vtkimagedata_from_array` for the reverse.
251251
252252
"""
253253
points = vtk_to_numpy(image_data.GetPointData().GetScalars())
@@ -265,11 +265,11 @@ def vtkimagedata_to_array(image_data):
265265
def vtkimagedata_from_array(arr, image_data=None):
266266
"""Convert a numpy array to a vtkImageData.
267267
268-
:param arr: Array of colors.
269-
:type arr: np.ndarray with dtype ``np.uint8``
268+
:param arr: An ``uint8`` array of colors.
269+
:type arr: numpy.ndarray
270270
271-
:param image_data: An image data to write into, a new one is created if not specified, defaults to ``None``.
272-
:type image_data: `vtkImageData`_, optional
271+
:param image_data: An image data to write into, a new one is created if not specified.
272+
:type image_data: `vtkImageData`_
273273
274274
:return: A VTK image.
275275
:rtype: `vtkImageData`_
@@ -278,9 +278,9 @@ def vtkimagedata_from_array(arr, image_data=None):
278278
``(m, n, 1)`` for greyscale, ``(m, n, 3)`` for RGB, or ``(m, n, 4)`` for
279279
RGBA.
280280
281-
.. seealso:: :meth:`vtkimagedata_to_array` for the reverse.
281+
.. seealso:: `vtkimagedata_to_array` for the reverse.
282282
283-
.. seealso:: :meth:`as_vtkimagedata` for converting from other types.
283+
.. seealso:: `as_vtkimagedata` for converting from other types.
284284
285285
"""
286286
assert arr.dtype == np.uint8
@@ -308,20 +308,20 @@ def trim_image(arr, background_color, crop_padding):
308308
background.
309309
310310
:param arr: An image array.
311-
:type arr: 3D np.ndarray
311+
:type arr: numpy.ndarray
312312
313313
:param background_color: The color of the portions to crop away.
314-
:type background_color: Strictly an (r, g, b) tuple.
314+
:type background_color: tuple
315315
316-
:param crop_padding: Space to leave, in pixels if int, or relative to image size if float.
316+
:param crop_padding: Space to leave, in pixels if `int`, or relative to image size if `float`.
317317
:type crop_padding: int or float
318318
319-
:return: Smaller image array.
320-
:rtype: 3D np.ndarray
319+
:return: A smaller image array.
320+
:rtype: numpy.ndarray
321321
322322
323323
If you don't want your files smaller you can instead use
324-
:meth:`vtkplotlib.zoom`.
324+
`vtkplotlib.zoom_to_contents`.
325325
326326
"""
327327
if (crop_padding is None) or crop_padding == 0:

0 commit comments

Comments
 (0)