Skip to content

Commit

Permalink
Start using vale and move docs source (pyvista#4118)
Browse files Browse the repository at this point in the history
* rename and modify

* add in google style guide

* remove warnings file

* revert and update to Google style guide

* Add newlines-at-end-of-files

---------

Co-authored-by: Andras Deak <[email protected]>
  • Loading branch information
akaszynski and adeak authored Mar 15, 2023
1 parent 50c5eda commit 2b6c604
Show file tree
Hide file tree
Showing 161 changed files with 828 additions and 58 deletions.
18 changes: 9 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ htmlcov
tests/ERROR_OUTPUT.txt

# Sphinx-gallery autogenerated pages
doc/examples/
doc/errors.txt
doc/images/auto-generated
doc/images/charts
doc/source/examples/
doc/source/errors.txt
doc/source/images/auto-generated
doc/source/images/charts
**/myscreenshot.png
api-autogen/
_autosummary/
doc/getting-started/external_examples.rst
doc/api/plotting/charts/pen_line_styles.rst
doc/api/plotting/charts/plot_color_schemes.rst
doc/api/plotting/charts/scatter_marker_styles.rst
doc/api/utilities/colors.rst
doc/source/getting-started/external_examples.rst
doc/source/api/plotting/charts/pen_line_styles.rst
doc/source/api/plotting/charts/plot_color_schemes.rst
doc/source/api/plotting/charts/scatter_marker_styles.rst
doc/source/api/utilities/colors.rst
**/grid.vtu

# flask examples
Expand Down
32 changes: 32 additions & 0 deletions doc/.vale.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Core settings
# =============

# Location of our `styles`
StylesPath = "styles"

# The options are `suggestion`, `warning`, or `error` (defaults to “warning”).
MinAlertLevel = warning

# By default, `code` and `tt` are ignored.
IgnoredScopes = code, tt

# By default, `script`, `style`, `pre`, and `figure` are ignored.
SkippedScopes = script, style, pre, figure

# WordTemplate specifies what Vale will consider to be an individual word.
WordTemplate = \b(?:%s)\b

# List of Packages to be used for our guidelines
Packages = Google

# Define the vocabulary
Vocab = pyvista

[*.{rst}]

# Apply the following styles
BasedOnStyles = Vale, Google

# Removing Google-specific rule - Not applicable under some circumstances
Google.WordList = NO
Google.Colons = NO
18 changes: 9 additions & 9 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SPHINXOPTS =
DEFAULTS = -w sphinx_warnings.txt -W --keep-going
SPHINXBUILD = python -msphinx
SPHINXPROJ = pyvista
SOURCEDIR = .
SOURCEDIR = source
BUILDDIR = _build


Expand All @@ -20,24 +20,24 @@ help:

clean:
rm -rf $(BUILDDIR)/*
rm -rf examples/
rm -rf $(SOURCEDIR)/examples/
rm -f errors.txt
rm -f sphinx_warnings.txt
rm -rf images/auto-generated
rm -f getting-started/external_examples.rst
find . -type d -name "_autosummary" -exec rm -rf {} +
rm -rf $(SOURCEDIR)/images/auto-generated
rm -f $(SOURCEDIR)/getting-started/external_examples.rst
find $(SOURCEDIR) -type d -name "_autosummary" -exec rm -rf {} +

clean-except-examples:
rm -rf $(BUILDDIR)/*
rm -f errors.txt
rm -f sphinx_warnings.txt
rm -rf images/auto-generated
rm -f getting-started/external_examples.rst
find . -type d -name "_autosummary" -exec rm -rf {} +
rm -rf $(SOURCEDIR)/images/auto-generated
rm -f $(SOURCEDIR)/getting-started/external_examples.rst
find $(SOURCEDIR) -type d -name "_autosummary" -exec rm -rf {} +

# remove autosummary files
clean-autosummary:
find . -type d -name "_autosummary" -exec rm -rf {} +
find $(SOURCEDIR) -type d -name "_autosummary" -exec rm -rf {} +

# build html docs in parallel using all available CPUs
# WARNING: this is a resource hog
Expand Down
3 changes: 0 additions & 3 deletions doc/extras/developer_notes.rst

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 13 additions & 10 deletions doc/conf.py → doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,24 +255,27 @@
# NOTE: if these are changed, then doc/intersphinx/update.sh
# must be changed accordingly to keep auto-updated mappings working
intersphinx_mapping = {
'python': ('https://docs.python.org/3', (None, 'intersphinx/python-objects.inv')),
'python': ('https://docs.python.org/3', (None, '../intersphinx/python-objects.inv')),
'scipy': (
'https://docs.scipy.org/doc/scipy/',
(None, 'intersphinx/scipy-objects.inv'),
(None, '../intersphinx/scipy-objects.inv'),
),
'numpy': ('https://numpy.org/doc/stable', (None, '../intersphinx/numpy-objects.inv')),
'matplotlib': (
'https://matplotlib.org/stable',
(None, '../intersphinx/matplotlib-objects.inv'),
),
'numpy': ('https://numpy.org/doc/stable', (None, 'intersphinx/numpy-objects.inv')),
'matplotlib': ('https://matplotlib.org/stable', (None, 'intersphinx/matplotlib-objects.inv')),
'imageio': (
'https://imageio.readthedocs.io/en/stable',
(None, 'intersphinx/imageio-objects.inv'),
(None, '../intersphinx/imageio-objects.inv'),
),
'pandas': (
'https://pandas.pydata.org/pandas-docs/stable',
(None, 'intersphinx/pandas-objects.inv'),
(None, '../intersphinx/pandas-objects.inv'),
),
'pytest': ('https://docs.pytest.org/en/stable', (None, 'intersphinx/pytest-objects.inv')),
'pyvistaqt': ('https://qtdocs.pyvista.org/', (None, 'intersphinx/pyvistaqt-objects.inv')),
'trimesh': ('https://trimsh.org', (None, 'intersphinx/trimesh-objects.inv')),
'pytest': ('https://docs.pytest.org/en/stable', (None, '../intersphinx/pytest-objects.inv')),
'pyvistaqt': ('https://qtdocs.pyvista.org/', (None, '../intersphinx/pyvistaqt-objects.inv')),
'trimesh': ('https://trimsh.org', (None, '../intersphinx/trimesh-objects.inv')),
}
intersphinx_timeout = 10

Expand Down Expand Up @@ -381,7 +384,7 @@ def __repr__(self):
# convert rst to md for ipynb
"pypandoc": True,
# path to your examples scripts
"examples_dirs": ["../examples/"],
"examples_dirs": ["../../examples/"],
# path where to save gallery generated examples
"gallery_dirs": ["examples"],
# Pattern to search for example files
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions doc/source/extras/developer_notes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.. _ref_developer_notes:

.. include:: ../../../CONTRIBUTING.rst
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions doc/extras/flask.rst → doc/source/extras/flask.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Dynamic Example
Python Application ``app.py``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. literalinclude:: ../../examples_flask/dynamic_ex/app.py
.. literalinclude:: ../../../examples_flask/dynamic_ex/app.py


Ajax Template ``index.html``
Expand All @@ -30,7 +30,7 @@ This template returns the ``meshtype`` parameter back to the
``get_img`` method in the flask app, which is used to select the type
of mesh to be plotted.

.. literalinclude:: ../../examples_flask/dynamic_ex/templates/index.html
.. literalinclude:: ../../../examples_flask/dynamic_ex/templates/index.html


Static Example
Expand All @@ -44,7 +44,7 @@ Static Example
Python Application ``app.py``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. literalinclude:: ../../examples_flask/static_ex/app.py
.. literalinclude:: ../../../examples_flask/static_ex/app.py


Ajax Template ``index.html``
Expand All @@ -56,4 +56,4 @@ This template returns the ``meshtype`` parameter back to the
``get_img`` method in the flask app, which is used to select the type
of mesh to be plotted.

.. literalinclude:: ../../examples_flask/static_ex/templates/index.html
.. literalinclude:: ../../../examples_flask/static_ex/templates/index.html
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ section, please be sure to head over to the `Contributors Graph`_.
possible.


.. include:: ../../CITATION.rst
.. include:: ../../../CITATION.rst


.. include:: ../../AUTHORS.rst
.. include:: ../../../AUTHORS.rst



License
-------

.. include:: ../../LICENSE
.. include:: ../../../LICENSE
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Transitioning from VTK to PyVista
VTK is primarily developed in C++ and uses chained setter and getter
commands to access data. Instead, PyVista wraps the VTK data types
into numpy arrays so that users can benefit from its bracket syntax
and fancy indexing. This section demonstrates the difference between
and fancy indexing. This section demonstrates the difference between
the two approaches in a series of examples.

For example, to hard-code points for a `vtk.vtkImageData`_ data
Expand Down Expand Up @@ -41,7 +41,7 @@ structure using VTK Python's bindings, one would write the following:
As you can see, there is quite a bit of boilerplate that goes into
the creation of a simple `vtk.vtkImageData`_ dataset. PyVista provides
much more concise syntax that is more "Pythonic". The equivalent code in
much more concise syntax that is more "Pythonic." The equivalent code in
PyVista is:


Expand All @@ -57,7 +57,7 @@ PyVista is:
>>> x, y = np.meshgrid(xi, xi)
>>> values = 127.5 + (1.0 + np.sin(x/25.0)*np.cos(y/25.0))
Create the grid. Note how the values must use Fortran ordering.
Create the grid. Note how the values must use Fortran ordering.
>>> grid = pyvista.UniformGrid(dimensions=(300, 300, 1))
>>> grid.point_data["values"] = values.flatten(order="F")
Expand All @@ -80,9 +80,9 @@ Here, PyVista has done several things for us:

Furthermore, since we know the container is for uniformly spaced data,
pyvista sets the origin and spacing by default to ``(0, 0, 0)`` and
``(1, 1, 1)``. This is another great thing about PyVista and Python!
``(1, 1, 1)``. This is another great thing about PyVista and Python.
Rather than having to know everything about the VTK library up front,
you can get started very easily! Once you get more familiar with it
you can get started very easily. Once you get more familiar with it
and need to do something more complex, you can dive deeper. For
example, changing the origin and spacing is as simple as:

Expand All @@ -95,12 +95,12 @@ Here, PyVista has done several things for us:
directly in dictionary-style fashion. Also, since VTK stores data
on the heap (linear segments of RAM; a C++ concept), the
data must be flattened and put in Fortran ordering (which controls
how multidimensional data is laid out in physically 1d memory; numpy
how multidimensional data is laid out in physically 1D memory; numpy
uses "C"-style memory layout by default). This is why in our earlier
example, the first argument to ``SetValue()`` was written as
``x*300 + y``. Here, numpy takes care of this for us quite nicely
and it's made more explicit in the code, following the Python best
practice of "Explicit is better than implicit".
practice of "Explicit is better than implicit."

Finally, with PyVista, each geometry class contains methods that allow
you to immediately plot the mesh without also setting up the plot.
Expand Down Expand Up @@ -128,7 +128,7 @@ However, with PyVista you only need:
grid.plot(cpos='xy', show_scalar_bar=False, cmap='coolwarm')
..
This is here so we can generate a plot. We have to repeat
This is here so we can generate a plot. We have to repeat
everything since jupyter-execute doesn't allow for
plain text between command blocks.
Expand All @@ -150,12 +150,12 @@ However, with PyVista you only need:
.. _vtk.vtkImageData: https://vtk.org/doc/nightly/html/classvtkImageData.html


PointSet Construction
PointSet construction
---------------------
PyVista heavily relies on NumPy to efficiently allocate and access
VTK's C arrays. For example, to create an array of points within VTK
VTK's C arrays. For example, to create an array of points within VTK
one would normally loop through all the points of a list and supply
that to a `vtkPoints`_ class. For example:
that to a `vtkPoints`_ class. For example:

.. jupyter-execute::

Expand Down Expand Up @@ -205,9 +205,9 @@ Whereas in VTK you would have to do:
>>> vtk_poly_data = vtk.vtkPolyData()
>>> vtk_poly_data.SetPoints(vtk_points)

The same goes with assigning face or cell connectivity/topology. With
The same goes with assigning face or cell connectivity/topology. With
VTK you would normally have to loop using ``InsertNextCell`` and
``InsertCellPoint``. For example, to create a single cell
``InsertCellPoint``. For example, to create a single cell
(triangle) and then assign it to `vtkPolyData`_:

.. jupyter-execute::
Expand All @@ -231,11 +231,11 @@ access it (or change it) from the :attr:`faces

.. _vtk_vs_pyvista_object_repr:

Object Representation
Object representation
---------------------
Both VTK and PyVista provide representations for their objects.

VTK provides a verbose representation (useful for debugging) of their datatypes
VTK provides a verbose representation (useful for debugging) of their data types
that can be accessed via :func:`print`, as the ``__repr__``
(unlike ``__str__``) only provides minimal information about each object:

Expand All @@ -261,7 +261,7 @@ In this representation we see:
All other attributes like :attr:`lines <pyvista.PolyData.lines>`,
:attr:`point_data <pyvista.DataSet.point_data>`, or
:attr:`cell_data <pyvista.DataSet.cell_data>` can be
accessed directly from the object. This approach was chosen to allow
accessed directly from the object. This approach was chosen to allow
for a brief summary showing key parts of the :class:`DataSet
<pyvista.DataSet>` without overwhelming the user.

Expand All @@ -271,7 +271,7 @@ While most features can, not everything can be simplified without
losing functionality or performance.

In the :class:`collision <pyvista.PolyDataFilters.collision>` filter,
we demonstrate how to calculate the collision between two meshes. For
we demonstrate how to calculate the collision between two meshes. For
example:

.. jupyter-execute::
Expand Down Expand Up @@ -300,17 +300,17 @@ example:
pl.show()

Under the hood, the collision filter detects mesh collisions using
oriented bounding box (OBB) trees. For a single collision, this filter
oriented bounding box (OBB) trees. For a single collision, this filter
is as performant as the VTK counterpart, but when computing multiple
collisions with the same meshes, as in the :ref:`collision_example`
example, it is more efficient to use the `vtkCollisionDetectionFilter
<https://vtk.org/doc/nightly/html/classvtkCollisionDetectionFilter.html>`_,
as the OBB tree is computed once for each mesh. In most cases, pure
as the OBB tree is computed once for each mesh. In most cases, pure
PyVista is sufficient for most data science, but there are times when
you may want to use VTK classes directly.

Note that nothing stops you from using VTK classes and then wrapping
the output with PyVista. For example:
the output with PyVista. For example:

.. jupyter-execute::

Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions doc/styles/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!Vocab
!Vocab/**
!.gitignore
9 changes: 9 additions & 0 deletions doc/styles/Google/AMPM.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends: existence
message: "Use 'AM' or 'PM' (preceded by a space)."
link: 'https://developers.google.com/style/word-list'
level: error
nonword: true
tokens:
- '\d{1,2}[AP]M'
- '\d{1,2} ?[ap]m'
- '\d{1,2} ?[aApP]\.[mM]\.'
Loading

0 comments on commit 2b6c604

Please sign in to comment.