diff --git a/.gitignore b/.gitignore index c438a51629c0..ad8d8f8b9e98 100644 --- a/.gitignore +++ b/.gitignore @@ -64,6 +64,7 @@ doc/examples doc/modules doc/pyplots/tex_demo.png doc/users/installing.rst +doc/_static/depsy_badge.svg doc/_static/matplotlibrc lib/dateutil examples/*/*.pdf diff --git a/doc-requirements.txt b/doc-requirements.txt index 9af746509bae..e0e378a264dc 100644 --- a/doc-requirements.txt +++ b/doc-requirements.txt @@ -7,9 +7,10 @@ # pip install -r doc-requirements.txt # sphinx>=1.3,!=1.5.0 -numpydoc +colorspacious ipython mock -colorspacious +numpydoc pillow +scipy sphinx-gallery diff --git a/doc/conf.py b/doc/conf.py index fa3acd05d5a0..a75d834377ac 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -38,48 +38,40 @@ exclude_patterns = ['api/api_changes/*', 'users/whats_new/*'] -# Use IPython's console highlighting by default -try: - from IPython.sphinxext import ipython_console_highlighting -except ImportError: - raise ImportError( - "IPython must be installed to build the Matplotlib docs") -else: - extensions.append('IPython.sphinxext.ipython_console_highlighting') - extensions.append('IPython.sphinxext.ipython_directive') - -try: - import numpydoc -except ImportError: - raise ImportError("No module named numpydoc - you need to install " - "numpydoc to build the documentation.") - -try: - import sphinx_gallery -except ImportError: - raise ImportError("No module named sphinx_gallery - you need to install " - "sphinx_gallery to build the documentation.") - -try: - import colorspacious -except ImportError: - raise ImportError("No module named colorspacious - you need to install " - "colorspacious to build the documentation") +def _check_deps(): + names = ["colorspacious", + "IPython.sphinxext.ipython_console_highlighting", + "matplotlib", + "numpydoc", + "PIL.Image", + "scipy", + "sphinx_gallery"] + if sys.version_info < (3, 3): + names.append("mock") + missing = [] + for name in names: + try: + __import__(name) + except ImportError: + missing.append(name) + if missing: + raise ImportError( + "The following dependencies are missing to build the " + "documentation: {}".format(", ".join(missing))) + +_check_deps() + +import matplotlib try: from unittest.mock import MagicMock except ImportError: - try: - from mock import MagicMock - except ImportError: - raise ImportError("No module named mock - you need to install " - "mock to build the documentation") + from mock import MagicMock -try: - from PIL import Image -except ImportError: - raise ImportError("No module named Image - you need to install " - "pillow to build the documentation") + +# Use IPython's console highlighting by default +extensions.extend(['IPython.sphinxext.ipython_console_highlighting', + 'IPython.sphinxext.ipython_directive']) if six.PY2: from distutils.spawn import find_executable @@ -92,12 +84,6 @@ "No binary named dot - you need to install the Graph Visualization " "software (usually packaged as 'graphviz') to build the documentation") -try: - import matplotlib -except ImportError: - msg = "Error: Matplotlib must be installed before building the documentation" - sys.exit(msg) - autosummary_generate = True @@ -134,7 +120,7 @@ project = 'Matplotlib' copyright = ('2002 - 2012 John Hunter, Darren Dale, Eric Firing, ' 'Michael Droettboom and the Matplotlib development ' - 'team; 2012 - 2016 The Matplotlib development team') + 'team; 2012 - 2017 The Matplotlib development team') # The default replacements for |version| and |release|, also used in various # other places throughout the built documents. diff --git a/doc/make.py b/doc/make.py index 0db0553224dd..e4fead0beeed 100755 --- a/doc/make.py +++ b/doc/make.py @@ -301,13 +301,14 @@ def build_all(): if args.n is not None: n_proc = int(args.n) +_valid_commands = "Valid targets are: {}".format(", ".join(sorted(funcd))) if args.cmd: for command in args.cmd: func = funcd.get(command) if func is None: - raise SystemExit(('Do not know how to handle %s; valid commands' - ' are %s' % (command, funcd.keys()))) + raise SystemExit("Do not know how to handle {}. {}" + .format(command, _valid_commands)) func() else: - all() + raise SystemExit(_valid_commands) os.chdir(current_dir)