Skip to content

Commit

Permalink
Use try-except to import sphinx-gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Apr 28, 2023
1 parent 71b067a commit fa684fd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pygmt/sphinx_gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
Utilities for using pygmt with sphinx-gallery.
"""

import sphinx_gallery.scrapers
try:
from sphinx_gallery.scrapers import figure_rst
except ImportError:
figure_rst = None
from pygmt.figure import SHOWED_FIGURES


Expand All @@ -29,4 +32,4 @@ def __call__(self, block, block_vars, gallery_conf):
fig = figures.pop(0)
fig.savefig(fname, transparent=True, dpi=200)
image_names.append(fname)
return sphinx_gallery.scrapers.figure_rst(image_names, gallery_conf["src_dir"])
return figure_rst(image_names, gallery_conf["src_dir"])

0 comments on commit fa684fd

Please sign in to comment.