Skip to content

Add sphinx-gallery to builds an HTML gallery of examples #374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e3fd331
Add sphinx-gallery to builds an HTML gallery of examples
tkoyama010 Aug 31, 2024
d1aaa7f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 31, 2024
6ad2a7d
Update conf.py
tkoyama010 Aug 31, 2024
ca6fa9c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 31, 2024
9102764
Update conf.py
tkoyama010 Aug 31, 2024
1d46a39
Update
tkoyama010 Aug 31, 2024
3bbb61f
Update pyproject.toml
tkoyama010 Aug 31, 2024
da1b535
Update requirements.txt
tkoyama010 Aug 31, 2024
02e63ac
Update pyproject.toml
tkoyama010 Aug 31, 2024
1720cd6
Update pyproject.toml
tkoyama010 Aug 31, 2024
689d4aa
Update pyproject.toml
tkoyama010 Aug 31, 2024
6290792
Update pyproject.toml
tkoyama010 Aug 31, 2024
0ca8281
Update pyproject.toml
tkoyama010 Aug 31, 2024
d0ca73c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 31, 2024
8151ca6
Delete docs/requirements.txt
tkoyama010 Aug 31, 2024
c870eda
Update .readthedocs.yaml
tkoyama010 Aug 31, 2024
2c1b94c
Update pyproject.toml
tkoyama010 Aug 31, 2024
65f11c7
Create README.rst
tkoyama010 Aug 31, 2024
49cce22
Update polygon_with_hole.py
tkoyama010 Aug 31, 2024
0bb9b76
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 31, 2024
b92e65f
Delete examples/__init__.py
tkoyama010 Aug 31, 2024
c69bc08
Update cylinder.py
tkoyama010 Aug 31, 2024
eb6eeca
Update polygon_with_hole.py
tkoyama010 Aug 31, 2024
9fe1ec7
Update pyproject.toml
tkoyama010 Aug 31, 2024
1535001
Update
tkoyama010 Aug 31, 2024
ac61ad6
Update cylinder.py
tkoyama010 Aug 31, 2024
adc5ba1
Update polygon_with_hole.py
tkoyama010 Aug 31, 2024
ba7c827
Update pyproject.toml
tkoyama010 Aug 31, 2024
d8ea100
Update pyproject.toml
tkoyama010 Aug 31, 2024
dc7675d
Update conf.py
tkoyama010 Aug 31, 2024
914a11b
Update conf.py
tkoyama010 Aug 31, 2024
b5b0c80
Update conf.py
tkoyama010 Aug 31, 2024
33273b3
Update conf.py
tkoyama010 Aug 31, 2024
8e49207
Update conf.py
tkoyama010 Aug 31, 2024
d003572
Update cylinder.py
tkoyama010 Aug 31, 2024
237defe
Update polygon_with_hole.py
tkoyama010 Aug 31, 2024
f8257c2
Update cylinder.py
tkoyama010 Aug 31, 2024
ff773cb
Update polygon_with_hole.py
tkoyama010 Aug 31, 2024
5efcdbf
Update cylinder.py
tkoyama010 Aug 31, 2024
a7d5c8a
Update cylinder.py
tkoyama010 Aug 31, 2024
de9607a
Update
tkoyama010 Aug 31, 2024
94deecb
Update conf.py
tkoyama010 Aug 31, 2024
2aef217
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 31, 2024
e574459
Update
tkoyama010 Aug 31, 2024
9c975bd
Update
tkoyama010 Aug 31, 2024
7d343a6
Update conf.py
tkoyama010 Aug 31, 2024
a9788e8
Merge branch 'main' into maint/sphinx-gallery
tkoyama010 Aug 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ python:
path: .
extra_requirements:
- docs
- requirements: docs/requirements.txt
31 changes: 29 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
import os
from pathlib import Path

import pyvista
from pyvista.plotting.utilities.sphinx_gallery import DynamicScraper

pyvista.set_error_output_file("errors.txt")
pyvista.OFF_SCREEN = True # Not necessary - simply an insurance policy
pyvista.set_plot_theme("document")
pyvista.BUILDING_GALLERY = True
os.environ["PYVISTA_BUILDING_GALLERY"] = "true"

if os.environ.get("READTHEDOCS") or os.environ.get("CI"):
pyvista.start_xvfb()

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

Expand Down Expand Up @@ -39,8 +51,7 @@
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ["myst_parser"]

extensions = ["myst_parser", "pyvista.ext.plot_directive", "pyvista.ext.viewer_directive", "sphinx_design", "sphinx_gallery.gen_gallery"]
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

Expand Down Expand Up @@ -123,3 +134,19 @@
"substitution",
"tasklist",
]

# -- sphinx_gallery settings -------------------------------------------------

sphinx_gallery_conf = {
"backreferences_dir": None,
"doc_module": "pyvista",
"download_all_examples": False,
"examples_dirs": ["../examples/"],
"filename_pattern": r"\.py",
"first_notebook_cell": ("%matplotlib inline\n" "from pyvista import set_plot_theme\n" "set_plot_theme('document')\n"),
"gallery_dirs": ["./examples"],
"image_scrapers": (DynamicScraper(), "matplotlib"),
"pypandoc": True,
"remove_config_comments": True,
"reset_modules_order": "both",
}
3 changes: 0 additions & 3 deletions docs/requirements.txt

This file was deleted.

7 changes: 7 additions & 0 deletions examples/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. _examples:

Examples
========

A gallery of examples. Coarse meshes are used whenever possible to make the examples run
fast. Some examples require external packages to be installed.
1 change: 0 additions & 1 deletion examples/__init__.py

This file was deleted.

16 changes: 13 additions & 3 deletions examples/cylinder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
"""scikit-gmsh package for 3D mesh generation test."""
r"""
Cylinder geometry example
-------------------------

Cylinder geometry example.

"""

from __future__ import annotations

Expand All @@ -9,5 +15,9 @@
edge_source = pv.Cylinder(resolution=16)
edge_source.merge(pv.PolyData(edge_source.points), merge_points=True, inplace=True)
edge_source.plot(show_edges=True)
delaunay_3d = sg.Delaunay3D(edge_source)
delaunay_3d.mesh.shrink(0.9).plot(show_edges=True)

# %%
# Generate the mesh.

alg = sg.Delaunay3D(edge_source)
alg.mesh.plot(show_edges=True)
23 changes: 15 additions & 8 deletions examples/polygon_with_hole.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
"""scikit-gmsh package for polygon with hole mesh generation test."""
r"""
Polygon with hole geometry example
----------------------------------

from __future__ import annotations
Polygon with hole geometry example.

"""

from shapely import Polygon
from __future__ import annotations

import skgmsh as sg

polygon_with_hole = Polygon(
[(0, 0, 0), (0, 10, 0), (10, 10, 0), (10, 0, 0), (0, 0, 0)], holes=[[(2, 2, 0), (2, 4, 0), (4, 4, 0), (4, 2, 0), (2, 2, 0)]]
)
shell = [(0, 0, 0), (0, 10, 0), (10, 10, 0), (10, 0, 0), (0, 0, 0)]
holes = [[(2, 2, 0), (2, 4, 0), (4, 4, 0), (4, 2, 0), (2, 2, 0)]]
alg = sg.Delaunay2D(shell=shell, holes=holes)

# %%
# Generate the mesh.

delaunay2d = sg.Delaunay2D(polygon_with_hole)
delaunay2d.mesh.plot(show_edges=True, color="white", cpos="xy")
mesh = alg.mesh
mesh.plot(show_edges=True, color="white", cpos="xy")
14 changes: 12 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = [
'gmsh<4.12.3',
'meshio<5.3.6',
'pygmsh<7.1.18',
'pyvista',
'pyvista[all]<0.44.2',
'scooby<0.9.3',
'setuptools<69.0.4',
'shapely<2.0.6'
Expand All @@ -20,14 +20,23 @@ dependencies = [
'gmsh<4.12.3',
'meshio<5.3.6',
'pygmsh<7.1.18',
'pyvista',
'pyvista[all]<0.44.2',
'scooby<0.9.3',
'shapely<2.0.6'
]
requires-python = '>=3.9'

[project.optional-dependencies]
test = ['pytest==8.0.0']
docs = [
'myst-parser==4.0.0',
'sphinx==8.0.2',
'sphinx-book-theme==1.1.3',
'sphinx-copybutton==0.5.2',
'sphinx-design==0.6.1',
'sphinx-gallery==0.17.1',
'sphinx-toolbox==3.8.0'
]

[tool.mypy]
ignore_missing_imports = true
Expand Down Expand Up @@ -78,6 +87,7 @@ force-single-line = true
[tool.ruff.lint.per-file-ignores]
"docs/**" = ["INP001"]
"tests/**" = ["INP001", "S101"]
"examples/**" = ["D205", "D400", "D415", "INP001"]

[tool.ruff.lint.pyupgrade]
# Preserve types, even if a file imports `from __future__ import annotations`.
Expand Down