Skip to content

Commit f15eff8

Browse files
berodatkoyama010
andauthored
Format only rst files with blackdoc (pyvista#6994)
* Format only rst files with blackdoc * Auto fix some rst files * Fix some code blocks --------- Co-authored-by: Tetsuo Koyama <[email protected]>
1 parent 9a5a2b7 commit f15eff8

19 files changed

+183
-140
lines changed

.pre-commit-config.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ repos:
1010
hooks:
1111
- id: blackdoc
1212
args: ["--skip-string-normalization"]
13-
files: '\.py$'
14-
exclude: pyvista/plotting/charts.py
13+
types_or: [rst]
1514

1615
- repo: https://github.com/codespell-project/codespell
1716
rev: v2.3.0

CITATION.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ visibility by citing our work.
1414

1515
BibTex:
1616

17-
.. code::
17+
.. code:: latex
1818

1919
@article{sullivan2019pyvista,
2020
doi = {10.21105/joss.01450},

CONTRIBUTING.rst

+32-29
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Python <https://www.python.org/dev/peps/pep-0020/>`_. When in doubt:
221221

222222
.. code:: python
223223
224-
import this
224+
import this
225225
226226
PyVista uses `pre-commit`_ to enforce PEP8 and other styles
227227
automatically. Please see the `Style Checking section <#style-checking>`_ for
@@ -243,14 +243,14 @@ and partially enforced for Python source files.
243243
These rules are enforced through the use of `Vale <https://vale.sh/>`_ via our
244244
GitHub Actions, and you can run Vale locally with:
245245

246-
.. code::
246+
.. code:: bash
247247
248248
pip install vale
249249
vale --config doc/.vale.ini doc pyvista examples ./*.rst --glob='!*{_build,AUTHORS.rst}*'
250250
251251
If you are on Linux or macOS, you can run:
252252

253-
.. code::
253+
.. code:: bash
254254
255255
make docstyle
256256
@@ -387,6 +387,7 @@ directive.
387387
import warnings
388388
from pyvista.core.errors import PyVistaDeprecationWarning
389389
390+
390391
def addition(a, b):
391392
"""Add two numbers.
392393
@@ -410,7 +411,7 @@ directive.
410411
# deprecated 0.37.0, convert to error in 0.40.0, remove 0.41.0
411412
warnings.warn(
412413
'`addition` has been deprecated. Use pyvista.add instead',
413-
PyVistaDeprecationWarning
414+
PyVistaDeprecationWarning,
414415
)
415416
add(a, b)
416417
@@ -621,15 +622,14 @@ the ``verify_image_cache`` fixture can be utilized:
621622

622623
.. code:: python
623624
624-
625-
def test_add_background_image_not_global(verify_image_cache):
626-
verify_image_cache.skip = True # Turn off caching
627-
plotter = pyvista.Plotter()
628-
plotter.add_mesh(sphere)
629-
plotter.show()
630-
# Turn on caching for further plotting
631-
verify_image_cache.skip = False
632-
...
625+
def test_add_background_image_not_global(verify_image_cache):
626+
verify_image_cache.skip = True # Turn off caching
627+
plotter = pyvista.Plotter()
628+
plotter.add_mesh(sphere)
629+
plotter.show()
630+
# Turn on caching for further plotting
631+
verify_image_cache.skip = False
632+
...
633633
634634
This ensures that immediately before the plotter is closed, the current
635635
render window will be verified against the image in CI. If no image
@@ -720,7 +720,7 @@ included in a single ``.py`` file. The test cases are all stored in
720720

721721
The tests can be executed with:
722722

723-
.. code:: python
723+
.. code:: bash
724724
725725
pytest tests/core/typing
726726
@@ -965,11 +965,14 @@ download the dataset in ``pyvista/examples/downloads.py``. This might be as easy
965965

966966
.. code:: python
967967
968-
def download_my_new_mesh(load=True):
969-
"""Download my new mesh."""
970-
return _download_dataset(_dataset_my_new_mesh, load=load)
968+
def download_my_new_mesh(load=True):
969+
"""Download my new mesh."""
970+
return _download_dataset(_dataset_my_new_mesh, load=load)
971+
971972
972-
_dataset_my_new_mesh = _SingleFileDownloadableDatasetLoader('mydata/my_new_mesh.vtk')
973+
_dataset_my_new_mesh = _SingleFileDownloadableDatasetLoader(
974+
'mydata/my_new_mesh.vtk'
975+
)
973976
974977
Note that a separate dataset loading object, ``_dataset_my_new_mesh``, should
975978
first be defined outside of the function (with module scope), and the new
@@ -1004,21 +1007,21 @@ For example:
10041007

10051008
.. code:: python
10061009
1007-
def download_my_new_mesh(load=True):
1008-
"""Download my new mesh.
1010+
def download_my_new_mesh(load=True):
1011+
"""Download my new mesh.
10091012
1010-
Examples
1011-
--------
1012-
>>> from pyvista import examples
1013-
>>> dataset = examples.download_my_new_mesh()
1014-
>>> dataset.plot()
1013+
Examples
1014+
--------
1015+
>>> from pyvista import examples
1016+
>>> dataset = examples.download_my_new_mesh()
1017+
>>> dataset.plot()
10151018
1016-
.. seealso::
1019+
.. seealso::
10171020
1018-
:ref:`My New Mesh Dataset <my_new_mesh_dataset>`
1019-
See this dataset in the Dataset Gallery for more info.
1021+
:ref:`My New Mesh Dataset <my_new_mesh_dataset>`
1022+
See this dataset in the Dataset Gallery for more info.
10201023
1021-
"""
1024+
"""
10221025
10231026
.. note::
10241027

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ visibility by citing our work.
284284

285285
BibTex:
286286

287-
.. code::
287+
.. code:: latex
288288

289289
@article{sullivan2019pyvista,
290290
doi = {10.21105/joss.01450},

doc/source/api/core/pointsets.rst

+32-18
Original file line numberDiff line numberDiff line change
@@ -221,24 +221,38 @@ initializing.
221221
>>> import numpy as np
222222
>>> import pyvista
223223
>>> from pyvista import CellType
224-
>>> cells = np.array([8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15])
225-
>>> cell_type = np.array([CellType.HEXAHEDRON, CellType.HEXAHEDRON], np.int8)
226-
>>> cell1 = np.array([[0, 0, 0],
227-
... [1, 0, 0],
228-
... [1, 1, 0],
229-
... [0, 1, 0],
230-
... [0, 0, 1],
231-
... [1, 0, 1],
232-
... [1, 1, 1],
233-
... [0, 1, 1]], dtype=np.float32)
234-
>>> cell2 = np.array([[0, 0, 2],
235-
... [1, 0, 2],
236-
... [1, 1, 2],
237-
... [0, 1, 2],
238-
... [0, 0, 3],
239-
... [1, 0, 3],
240-
... [1, 1, 3],
241-
... [0, 1, 3]], dtype=np.float32)
224+
>>> cells = np.array(
225+
... [8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15]
226+
... )
227+
>>> cell_type = np.array(
228+
... [CellType.HEXAHEDRON, CellType.HEXAHEDRON], np.int8
229+
... )
230+
>>> cell1 = np.array(
231+
... [
232+
... [0, 0, 0],
233+
... [1, 0, 0],
234+
... [1, 1, 0],
235+
... [0, 1, 0],
236+
... [0, 0, 1],
237+
... [1, 0, 1],
238+
... [1, 1, 1],
239+
... [0, 1, 1],
240+
... ],
241+
... dtype=np.float32,
242+
... )
243+
>>> cell2 = np.array(
244+
... [
245+
... [0, 0, 2],
246+
... [1, 0, 2],
247+
... [1, 1, 2],
248+
... [0, 1, 2],
249+
... [0, 0, 3],
250+
... [1, 0, 3],
251+
... [1, 1, 3],
252+
... [0, 1, 3],
253+
... ],
254+
... dtype=np.float32,
255+
... )
242256
>>> points = np.vstack((cell1, cell2))
243257
>>> grid = pyvista.UnstructuredGrid(cells, cell_type, points)
244258
>>> grid

doc/source/api/plotting/plotting.rst

+9-1
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,16 @@ values change through time:
127127
128128
129129
plotter = pvqt.BackgroundPlotter()
130-
plotter.add_mesh(globe, lighting=False, show_edges=True, texture=texture, scalars='scalars')
130+
plotter.add_mesh(
131+
globe,
132+
lighting=False,
133+
show_edges=True,
134+
texture=texture,
135+
scalars='scalars',
136+
)
131137
plotter.view_isometric()
132138
139+
133140
# shrink globe in the background
134141
def shrink():
135142
for i in range(50):
@@ -138,6 +145,7 @@ values change through time:
138145
globe.point_data['scalars'] = np.random.rand(globe.n_points)
139146
time.sleep(0.5)
140147
148+
141149
thread = Thread(target=shrink)
142150
thread.start()
143151

doc/source/api/utilities/utilities.rst

+11-18
Original file line numberDiff line numberDiff line change
@@ -131,28 +131,21 @@ PyVista Version Information
131131
The PyVista library provides a way of getting the version installed in your
132132
environment.
133133

134-
.. code:: python
135-
136-
Output the version of PyVista.
137-
138-
>>> import pyvista
139-
>>> pyvista.version_info
140-
(0, 44, 0)
134+
>>> # Output the version of PyVista.
135+
>>> import pyvista
136+
>>> pyvista.version_info
137+
(0, 44, 0)
141138

142139
VTK Version Information
143140
~~~~~~~~~~~~~~~~~~~~~~~
144141
The PyVista library is heavily dependent on VTK and provides an easy
145142
way of getting the version of VTK in your environment.
146143

147-
.. code:: python
148-
149-
Output the version of VTK.
150-
151-
>>> import pyvista
152-
>>> pyvista.vtk_version_info
153-
VTKVersionInfo(major=9, minor=1, micro=0)
154-
155-
Get the major version of VTK
144+
>>> # Output the version of VTK.
145+
>>> import pyvista
146+
>>> pyvista.vtk_version_info
147+
VTKVersionInfo(major=9, minor=1, micro=0)
156148

157-
>>> pyvista.vtk_version_info.major
158-
9
149+
>>> # Get the major version of VTK
150+
>>> pyvista.vtk_version_info.major
151+
9

doc/source/extras/plot_directive.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ You can generate static and interactive scenes of pyvista plots using the
88

99
.. code:: python
1010
11-
extensions = [
12-
"pyvista.ext.plot_directive",
13-
"pyvista.ext.viewer_directive",
14-
"sphinx_design",
15-
]
11+
extensions = [
12+
"pyvista.ext.plot_directive",
13+
"pyvista.ext.viewer_directive",
14+
"sphinx_design",
15+
]
1616
1717
You can then issue the plotting directive within your sphinx
1818
documentation files::

doc/source/getting-started/index.rst

+9-6
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,11 @@ through a range of examples and tutorials.
106106
:include-source: False
107107
:context:
108108

109-
>>> bunny_cpos = [( 0.14826, 0.275729, 0.4215911),
110-
... (-0.01684, 0.110154, -0.0015369),
111-
... (-0.15446, 0.939031, -0.3071841)]
109+
>>> bunny_cpos = [
110+
... (0.14826, 0.275729, 0.4215911),
111+
... (-0.01684, 0.110154, -0.0015369),
112+
... (-0.15446, 0.939031, -0.3071841),
113+
... ]
112114

113115

114116
.. grid:: 2
@@ -123,9 +125,10 @@ through a range of examples and tutorials.
123125

124126
.. code:: python
125127
126-
import pyvista
127-
mesh = pyvista.read('bunny.stl')
128-
mesh.plot()
128+
import pyvista
129+
130+
mesh = pyvista.read('bunny.stl')
131+
mesh.plot()
129132
130133
.. pyvista-plot::
131134
:include-source: False

doc/source/getting-started/installation.rst

+10-8
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ should be displayed in JupyterLab.
318318
.. code-block:: python
319319
320320
import pyvista
321+
321322
pl = pyvista.Plotter(shape=(1, 2))
322323
actor = pl.add_mesh(pyvista.Cube())
323324
pl.subplot(0, 1)
@@ -335,6 +336,7 @@ In your ``conf.py``, add the following:
335336
.. code-block:: python
336337
337338
import pyvista
339+
338340
# necessary when building the sphinx gallery
339341
pyvista.BUILDING_GALLERY = True
340342
pyvista.OFF_SCREEN = True
@@ -344,15 +346,15 @@ In your ``conf.py``, add the following:
344346
pyvista.global_theme.window_size = np.array([1024, 768]) * 2
345347
346348
extensions = [
347-
...
349+
...,
348350
"sphinx_gallery.gen_gallery",
349351
]
350352
351353
# Add the PyVista image scraper to SG
352354
sphinx_gallery_conf = {
353-
...
354-
"image_scrapers": ('pyvista', ..., ),
355-
...
355+
...: ...,
356+
"image_scrapers": ('pyvista', ...),
357+
...: ...,
356358
}
357359
358360
We also have a Sphinx-Gallery scraper for embedding dynamic 3D scenes
@@ -375,14 +377,14 @@ the string ``'pyvista'`` above and by registering the
375377
pyvista.global_theme.window_size = np.array([1024, 768]) * 2
376378
377379
extensions = [
378-
...
380+
...,
379381
"sphinx_gallery.gen_gallery",
380382
"pyvista.ext.viewer_directive",
381383
]
382384
383385
# Add the PyVista image scraper to SG
384386
sphinx_gallery_conf = {
385-
...
386-
"image_scrapers": (DynamicScraper(), ..., ),
387-
...
387+
...: ...,
388+
"image_scrapers": (DynamicScraper(), ...),
389+
...: ...,
388390
}

doc/source/getting-started/why.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ requires a few lines of code.
4141
:include-source: False
4242
:context:
4343

44-
>>> bunny_cpos = [( 0.14826, 0.275729, 0.4215911),
45-
... (-0.01684, 0.110154, -0.0015369),
46-
... (-0.15446, 0.939031, -0.3071841)]
44+
>>> bunny_cpos = [
45+
... (0.14826, 0.275729, 0.4215911),
46+
... (-0.01684, 0.110154, -0.0015369),
47+
... (-0.15446, 0.939031, -0.3071841),
48+
... ]
4749

4850
+----------------------------------------------------+-------------------------------------+
4951
| Read and plot STL file using `vtk`_ | Read an STL file using PyVista |

0 commit comments

Comments
 (0)