Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c19c3ed

Browse files
committed
Update doc build.
- Add copied depsy_badge to gitignore. - In conf.py, move all dependency checks together. - In conf.py and doc-requirements.txt, added dependency on scipy (for animation/bayes_update.py, animation/double_pendulum_animated.py). - In conf.py, update copyright years. - Fix error when invoking make.py without a target.
1 parent bed999e commit c19c3ed

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
@@ -38,48 +38,40 @@
3838

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

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

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

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

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

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

10288
autosummary_generate = True
10389

@@ -134,7 +120,7 @@
134120
project = 'Matplotlib'
135121
copyright = ('2002 - 2012 John Hunter, Darren Dale, Eric Firing, '
136122
'Michael Droettboom and the Matplotlib development '
137-
'team; 2012 - 2016 The Matplotlib development team')
123+
'team; 2012 - 2017 The Matplotlib development team')
138124

139125
# The default replacements for |version| and |release|, also used in various
140126
# 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)