|
38 | 38 |
|
39 | 39 | exclude_patterns = ['api/api_changes/*', 'users/whats_new/*'] |
40 | 40 |
|
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") |
68 | 41 |
|
| 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 |
69 | 66 | try: |
70 | 67 | from unittest.mock import MagicMock |
71 | 68 | 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 |
77 | 70 |
|
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']) |
83 | 75 |
|
84 | 76 | if six.PY2: |
85 | 77 | from distutils.spawn import find_executable |
|
92 | 84 | "No binary named dot - you need to install the Graph Visualization " |
93 | 85 | "software (usually packaged as 'graphviz') to build the documentation") |
94 | 86 |
|
95 | | -try: |
96 | | - import matplotlib |
97 | | -except ImportError: |
98 | | - msg = "Error: Matplotlib must be installed before building the documentation" |
99 | | - sys.exit(msg) |
100 | | - |
101 | 87 |
|
102 | 88 | autosummary_generate = True |
103 | 89 |
|
|
134 | 120 | project = 'Matplotlib' |
135 | 121 | copyright = ('2002 - 2012 John Hunter, Darren Dale, Eric Firing, ' |
136 | 122 | 'Michael Droettboom and the Matplotlib development ' |
137 | | - 'team; 2012 - 2016 The Matplotlib development team') |
| 123 | + 'team; 2012 - 2017 The Matplotlib development team') |
138 | 124 |
|
139 | 125 | # The default replacements for |version| and |release|, also used in various |
140 | 126 | # other places throughout the built documents. |
|
0 commit comments