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