Skip to content

Commit 6a49856

Browse files
authored
Merge pull request #8536 from anntzer/update-doc-build
Update doc build.
2 parents e69bdaa + c19c3ed commit 6a49856

File tree

4 files changed

+38
-49
lines changed

4 files changed

+38
-49
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ doc/examples
6464
doc/modules
6565
doc/pyplots/tex_demo.png
6666
doc/users/installing.rst
67+
doc/_static/depsy_badge.svg
6768
doc/_static/matplotlibrc
6869
lib/dateutil
6970
examples/*/*.pdf

doc-requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
# pip install -r doc-requirements.txt
88
#
99
sphinx>=1.3,!=1.5.0
10-
numpydoc
10+
colorspacious
1111
ipython
1212
mock
13-
colorspacious
13+
numpydoc
1414
pillow
15+
scipy
1516
sphinx-gallery

doc/conf.py

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -37,48 +37,40 @@
3737

3838
exclude_patterns = ['api/api_changes/*', 'users/whats_new/*']
3939

40-
# Use IPython's console highlighting by default
41-
try:
42-
from IPython.sphinxext import ipython_console_highlighting
43-
except ImportError:
44-
raise ImportError(
45-
"IPython must be installed to build the Matplotlib docs")
46-
else:
47-
extensions.append('IPython.sphinxext.ipython_console_highlighting')
48-
extensions.append('IPython.sphinxext.ipython_directive')
49-
50-
try:
51-
import numpydoc
52-
except ImportError:
53-
raise ImportError("No module named numpydoc - you need to install "
54-
"numpydoc to build the documentation.")
55-
56-
try:
57-
import sphinx_gallery
58-
except ImportError:
59-
raise ImportError("No module named sphinx_gallery - you need to install "
60-
"sphinx_gallery to build the documentation.")
61-
62-
try:
63-
import colorspacious
64-
except ImportError:
65-
raise ImportError("No module named colorspacious - you need to install "
66-
"colorspacious to build the documentation")
6740

41+
def _check_deps():
42+
names = ["colorspacious",
43+
"IPython.sphinxext.ipython_console_highlighting",
44+
"matplotlib",
45+
"numpydoc",
46+
"PIL.Image",
47+
"scipy",
48+
"sphinx_gallery"]
49+
if sys.version_info < (3, 3):
50+
names.append("mock")
51+
missing = []
52+
for name in names:
53+
try:
54+
__import__(name)
55+
except ImportError:
56+
missing.append(name)
57+
if missing:
58+
raise ImportError(
59+
"The following dependencies are missing to build the "
60+
"documentation: {}".format(", ".join(missing)))
61+
62+
_check_deps()
63+
64+
import matplotlib
6865
try:
6966
from unittest.mock import MagicMock
7067
except ImportError:
71-
try:
72-
from mock import MagicMock
73-
except ImportError:
74-
raise ImportError("No module named mock - you need to install "
75-
"mock to build the documentation")
68+
from mock import MagicMock
7669

77-
try:
78-
from PIL import Image
79-
except ImportError:
80-
raise ImportError("No module named Image - you need to install "
81-
"pillow to build the documentation")
70+
71+
# Use IPython's console highlighting by default
72+
extensions.extend(['IPython.sphinxext.ipython_console_highlighting',
73+
'IPython.sphinxext.ipython_directive'])
8274

8375
if six.PY2:
8476
from distutils.spawn import find_executable
@@ -91,12 +83,6 @@
9183
"No binary named dot - you need to install the Graph Visualization "
9284
"software (usually packaged as 'graphviz') to build the documentation")
9385

94-
try:
95-
import matplotlib
96-
except ImportError:
97-
msg = "Error: Matplotlib must be installed before building the documentation"
98-
sys.exit(msg)
99-
10086

10187
autosummary_generate = True
10288

@@ -133,7 +119,7 @@
133119
project = 'Matplotlib'
134120
copyright = ('2002 - 2012 John Hunter, Darren Dale, Eric Firing, '
135121
'Michael Droettboom and the Matplotlib development '
136-
'team; 2012 - 2016 The Matplotlib development team')
122+
'team; 2012 - 2017 The Matplotlib development team')
137123

138124
# The default replacements for |version| and |release|, also used in various
139125
# other places throughout the built documents.

doc/make.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,14 @@ def build_all():
301301
if args.n is not None:
302302
n_proc = int(args.n)
303303

304+
_valid_commands = "Valid targets are: {}".format(", ".join(sorted(funcd)))
304305
if args.cmd:
305306
for command in args.cmd:
306307
func = funcd.get(command)
307308
if func is None:
308-
raise SystemExit(('Do not know how to handle %s; valid commands'
309-
' are %s' % (command, funcd.keys())))
309+
raise SystemExit("Do not know how to handle {}. {}"
310+
.format(command, _valid_commands))
310311
func()
311312
else:
312-
all()
313+
raise SystemExit(_valid_commands)
313314
os.chdir(current_dir)

0 commit comments

Comments
 (0)