Skip to content

Commit 4bdbcb6

Browse files
DOC: Handle missing nbconvert in html build (#16330)
Closes #16329
1 parent 4cd8458 commit 4bdbcb6

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

doc/make.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,28 @@ def maybe_exclude_notebooks():
115115
notebooks = [os.path.join(base, 'source', nb)
116116
for nb in ['style.ipynb']]
117117
contents = {}
118-
try:
119-
import nbconvert
120-
nbconvert.utils.pandoc.get_pandoc_version()
121-
except (ImportError, nbconvert.utils.pandoc.PandocMissing):
122-
print("Warning: Pandoc is not installed. Skipping Notebooks.")
118+
119+
def _remove_notebooks():
123120
for nb in notebooks:
124121
with open(nb, 'rt') as f:
125122
contents[nb] = f.read()
126123
os.remove(nb)
124+
125+
# Skip notebook conversion if
126+
# 1. nbconvert isn't installed, or
127+
# 2. nbconvert is installed, but pandoc isn't
128+
try:
129+
import nbconvert
130+
except ImportError:
131+
print("Warning: nbconvert not installed. Skipping notebooks.")
132+
_remove_notebooks()
133+
else:
134+
try:
135+
nbconvert.utils.pandoc.get_pandoc_version()
136+
except nbconvert.utils.pandoc.PandocMissing:
137+
print("Warning: Pandoc is not installed. Skipping notebooks.")
138+
_remove_notebooks()
139+
127140
yield
128141
for nb, content in contents.items():
129142
with open(nb, 'wt') as f:

0 commit comments

Comments
 (0)