diff --git a/.circleci/config.yml b/.circleci/config.yml index 4055ba0380ea..33757dedd842 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,6 +28,35 @@ apt-run: &apt-install libgeos-dev \ otf-freefont +conda36-run: &conda36-install + name: Install conda + command: | + wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \ + -O miniconda.sh + chmod +x miniconda.sh && ./miniconda.sh -b -p $HOME/miniconda + export PATH="$HOME/miniconda/bin:$PATH" + echo $PATH + conda update --yes --quiet conda + + # Configure the conda environment and put it in the path using the + # provided versions + conda create -n testenv --yes --quiet python + source activate testenv + +conda27-run: &conda27-install + name: Install conda + command: | + wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh \ + -O miniconda.sh + chmod +x miniconda.sh && ./miniconda.sh -b -p $HOME/miniconda + export PATH="$HOME/miniconda/bin:$PATH" + conda update --yes --quiet conda + + # Configure the conda environment and put it in the path using the + # provided versions + conda create -n testenv --yes --quiet python + source activate testenv + fonts-run: &fonts-install name: Install custom fonts # We manually install Humor-Sans using the package from Ubuntu 14.10. @@ -52,23 +81,40 @@ pip-run: &pip-install # Upgrade pip and setuptools and wheel to get as clean an install as possible name: Upgrade pip, setuptools, wheel command: | - pip install --upgrade --user pip - pip install --upgrade --user wheel - pip install --upgrade --user setuptools + export PATH="$HOME/miniconda/bin:$PATH" + source activate testenv + pip install --upgrade pip + pip install --upgrade wheel + pip install --upgrade setuptools deps-run: &deps-install name: Install Python dependencies command: | - pip install --user python-dateutil numpy${NUMPY_VERSION} pyparsing!=2.1.6 cycler codecov coverage sphinx pillow - pip install --user -r doc-requirements.txt + export PATH="$HOME/miniconda/bin:$PATH" + source activate testenv + pip install python-dateutil numpy${NUMPY_VERSION} pyparsing!=2.1.6 cycler codecov coverage + pip install -r doc-requirements.txt mpl-run: &mpl-install name: Install Matplotlib - command: pip install --user -ve . + command: | + export PATH="$HOME/miniconda/bin:$PATH" + source activate testenv + pip install -ve . + +linkchecker-run: &linkchecker-install + name: Install linkchecker + command: | + export PATH="$HOME/miniconda/bin:$PATH" + source activate testenv + pip install $PRE requests==2.9.2 linkchecker doc-run: &doc-build name: Build documentation - command: python make.py html + command: | + export PATH="$HOME/miniconda/bin:$PATH" + source activate testenv + make working_directory: doc doc-bundle-run: &doc-bundle @@ -82,13 +128,14 @@ doc-bundle-run: &doc-bundle # jobs: - docs-python35: + docs-python36: docker: - - image: circleci/python:3.5 + - image: circleci/python:3.6 steps: - checkout - run: *apt-install + - run: *conda36-install - run: *fonts-install - run: *pip-install @@ -122,6 +169,7 @@ jobs: - checkout - run: *apt-install + - run: *conda27-install - run: *fonts-install - run: *pip-install @@ -131,7 +179,7 @@ jobs: NUMPY_VERSION: "==1.7.1" # Linkchecker only works with python 2.7 for the time being. # Linkchecker is currently broken with requests 2.10.0 so force an earlier version. - - run: pip install --user $PRE requests==2.9.2 linkchecker + - run: *linkchecker-install - run: *mpl-install - run: *doc-build @@ -142,7 +190,10 @@ jobs: # Linkchecker only works with python 2.7 for the time being - run: name: linkchecker - command: ~/.local/bin/linkchecker build/html/index.html + command: | + export PATH="$HOME/miniconda/bin:$PATH" + source activate testenv + linkchecker build/html/index.html working_directory: doc - run: *doc-bundle @@ -165,5 +216,5 @@ workflows: version: 2 build: jobs: - - docs-python35 + - docs-python36 - docs-python27 diff --git a/.gitignore b/.gitignore index 8191bc39e393..4f987a10b8d4 100644 --- a/.gitignore +++ b/.gitignore @@ -67,7 +67,6 @@ doc/tutorials 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 ded1a2df68ba..5339d6a726e7 100644 --- a/doc-requirements.txt +++ b/doc-requirements.txt @@ -6,10 +6,10 @@ # Install the documentation requirements with: # pip install -r doc-requirements.txt # -sphinx>=1.3,!=1.5.0 +sphinx>=1.3,!=1.5.0,!=1.6.4 colorspacious ipython mock numpydoc pillow -sphinx-gallery>=0.1.12 +sphinx-gallery diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 000000000000..6c38fcd45a70 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,121 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD ?= sphinx-build +PAPER = +BUILDDIR = build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml pickle json latex latexpdf changes linkcheck doctest optipng + +all: html + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + -rm -rf gallery/ + -rm -rf tutorials/ + -rm -rf api/_as_gen/ + -rm -rf generated/* + -rm -rf modules/generated/* + -rm -rf _static/matplotlibrc + -rm -rf _templates/gallery.html + -rm -rf users/installing.rst + +html: prepare + # These two lines make the build a bit more lengthy, and the + # the embedding of images more robust + rm -rf $(BUILDDIR)/html/_images + #rm -rf _build/doctrees/ + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) -W $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html" + + +html-allow-warnings: prepare + # These two lines make the build a bit more lengthy, and the + # the embedding of images more robust + rm -rf $(BUILDDIR)/html/_images + #rm -rf _build/doctrees/ + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html" + + +html-noplot: prepare + $(SPHINXBUILD) -D plot_gallery=0 -b html -W $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: prepare + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +pickle: prepare + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: prepare + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +latex: prepare + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: prepare + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + make -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +changes: prepare + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: prepare + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: prepare + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +prepare: _static/matplotlibrc users/installing.rst + +.SECONDARY: + +############################################# +# Matplotlib needs to copy paste stuff around +_static/matplotlibrc: ../lib/matplotlib/mpl-data/matplotlibrc + cp $< $@ + +users/installing.rst: ../INSTALL.rst + cp $< $@ diff --git a/doc/README.txt b/doc/README.txt index 3ac8e84205df..faf56c38e6e6 100644 --- a/doc/README.txt +++ b/doc/README.txt @@ -25,7 +25,7 @@ or all of them via conda and pip:: sphinx-gallery pip install colorspacious -To build the HTML documentation, type ``python make.py html`` in this +To build the HTML documentation, type ``make html`` in this directory. The top file of the results will be ./build/html/index.html **Note that Sphinx uses the installed version of the package to build the @@ -34,9 +34,9 @@ generated. You can build the documentation with several options: -* `--small` saves figures in low resolution. -* `--allowsphinxwarnings`: Don't turn Sphinx warnings into errors. -* `-n N` enables parallel build of the documentation using N process. +* `make html-noplot` doesn't save the gallery's images. Allows for fast build. +* `make html-allow-warnings`: Don't turn Sphinx warnings into errors. +* `make -j N` enables parallel build of the documentation using N process. Organization ------------- @@ -57,7 +57,7 @@ python documentation system built on top of ReST. This directory contains * mpl_toolkits - documentation of individual toolkits that ship with Matplotlib -* make.py - the build script to build the html or PDF docs +* Makefile - the build script to build the html or PDF docs * index.rst - the top level include document for Matplotlib docs diff --git a/doc/_templates/badgesidebar.html b/doc/_templates/badgesidebar.html index 1067b5cb9ad7..66d58808aec5 100644 --- a/doc/_templates/badgesidebar.html +++ b/doc/_templates/badgesidebar.html @@ -4,12 +4,6 @@
- - - - -
- Travis-CI: diff --git a/doc/devel/documenting_mpl.rst b/doc/devel/documenting_mpl.rst index cd91aaaea7a8..8aeac7b54584 100644 --- a/doc/devel/documenting_mpl.rst +++ b/doc/devel/documenting_mpl.rst @@ -54,23 +54,19 @@ The documentation sources are found in the :file:`doc/` directory in the trunk. To build the users guide in html format, cd into :file:`doc/` and do:: - python make.py html + make html -or:: +There are many other targets you can pass to ``make``, and you can see the +full list inside that file. Here are some useful ones: - ./make.py html - -There are many other flags you can pass to ``make.py``, and you can see the -full list inside that file. Here are two useful ones: - -* ``clean`` will delete the built Sphinx files. Use this command if you're getting strange +* ``make html-noplots`` will build the documentation without writing the gallery + images. This is much faster than ``make html``. +* ``make clean`` will delete the built Sphinx files. Use this command if you're getting strange errors about missing paths or broken links, particularly if you move files around. -* ``latex`` builds a PDF of the documentation. - -In addition, these are useful flags: - -* ``--help`` will (among other things) display the allowed commands for ``make.py``. -* ``--allowsphinxwarnings`` will allow the docs to continue building even if Sphinx +* ``make latex`` builds a PDF of the documentation. +* ``make help`` will (among other things) display the allowed commands for + ``make``. +* ``make-allow-warnings`` will allow the docs to continue building even if Sphinx throws a warning. This is useful for debugging and spot-checking many warnings at once. diff --git a/doc/devel/release_guide.rst b/doc/devel/release_guide.rst index b26627633dd5..3a074e27bf7c 100644 --- a/doc/devel/release_guide.rst +++ b/doc/devel/release_guide.rst @@ -54,7 +54,7 @@ temporarily comment out the include and toctree glob; re-instate these after a release. Finally, make sure that the docs build cleanly :: pushd doc - python make.py html latex -n 16 + make html latex popd After the docs are built, check that all of the links, internal and external, are still @@ -214,7 +214,7 @@ build the docs from the ``ver-doc`` branch. An easy way to arrange this is:: git checkout v2.0.0-doc git clean -xfd cd doc - python make.py html latex -n 16 + make html latex which will build both the html and pdf version of the documentation. diff --git a/doc/make.bat b/doc/make.bat new file mode 100644 index 000000000000..fa8e7171ea7e --- /dev/null +++ b/doc/make.bat @@ -0,0 +1,120 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +set SPHINXBUILD=sphinx-build +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. changes to make an overview over all changed/added/deprecated items + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + echo. html-noplot to make HTML files using Windows + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "html-noplot" ( + %SPHINXBUILD% -D plot_gallery=0 -b html %ALLSPHINXOPTS% %BUILDDIR%/html + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\scikit-learn.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\scikit-learn.ghc + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +:end diff --git a/doc/make.py b/doc/make.py deleted file mode 100755 index c23335334d18..000000000000 --- a/doc/make.py +++ /dev/null @@ -1,232 +0,0 @@ -#!/usr/bin/env python -"""Wrapper script for calling Sphinx. """ - -from __future__ import print_function -import glob -import os -import shutil -import sys -import re -import argparse -import subprocess -import matplotlib -import six - - -def copy_if_out_of_date(original, derived): - """Copy file only if newer as target or if target does not exist. """ - if (not os.path.exists(derived) or - os.stat(derived).st_mtime < os.stat(original).st_mtime): - try: - shutil.copyfile(original, derived) - except IOError: - if os.path.basename(original) == 'matplotlibrc': - msg = "'%s' not found. " % original + \ - "Did you run `python setup.py build`?" - raise IOError(msg) - else: - raise - - -def check_build(): - """Create target build directories if necessary. """ - build_dirs = ['build', 'build/doctrees', 'build/html', 'build/latex', - 'build/texinfo', '_static', '_templates'] - for d in build_dirs: - try: - os.mkdir(d) - except OSError: - pass - - -def doctest(): - """Execute Sphinx 'doctest' target. """ - subprocess.call( - [sys.executable] - + '-msphinx -b doctest -d build/doctrees . build/doctest'.split()) - - -def linkcheck(): - """Execute Sphinx 'linkcheck' target. """ - subprocess.call( - [sys.executable] - + '-msphinx -b linkcheck -d build/doctrees . build/linkcheck'.split()) - -DEPSY_PATH = "_static/depsy_badge.svg" -DEPSY_URL = "http://depsy.org/api/package/pypi/matplotlib/badge.svg" -DEPSY_DEFAULT = "_static/depsy_badge_default.svg" - - -def fetch_depsy_badge(): - """Fetches a static copy of the depsy badge. - - If there is any network error, use a static copy from git. - - This is to avoid a mixed-content warning when serving matplotlib.org - over https, see https://github.com/Impactstory/depsy/issues/77 - - The downside is that the badge only updates when the documentation - is rebuilt.""" - try: - request = six.moves.urllib.request.urlopen(DEPSY_URL) - try: - data = request.read().decode('utf-8') - with open(DEPSY_PATH, 'w') as output: - output.write(data) - finally: - request.close() - except six.moves.urllib.error.URLError: - shutil.copyfile(DEPSY_DEFAULT, DEPSY_PATH) - - -def html(buildername='html'): - """Build Sphinx 'html' target. """ - check_build() - fetch_depsy_badge() - - rc = '../lib/matplotlib/mpl-data/matplotlibrc' - default_rc = os.path.join(matplotlib._get_data_path(), 'matplotlibrc') - if not os.path.exists(rc) and os.path.exists(default_rc): - rc = default_rc - copy_if_out_of_date(rc, '_static/matplotlibrc') - - options = ['-j{}'.format(n_proc), - '-b{}'.format(buildername), - '-dbuild/doctrees'] - if small_docs: - options += ['-Dplot_formats=png:100'] - if warnings_as_errors: - options += ['-W'] - if subprocess.call( - [sys.executable, '-msphinx', '.', 'build/{}'.format(buildername)] - + options): - raise SystemExit("Building HTML failed.") - - # Clean out PDF files from the _images directory - for filename in glob.glob('build/%s/_images/*.pdf' % buildername): - os.remove(filename) - - -def htmlhelp(): - """Build Sphinx 'htmlhelp' target. """ - html(buildername='htmlhelp') - # remove scripts from index.html - with open('build/htmlhelp/index.html', 'r+') as fh: - content = fh.read() - fh.seek(0) - content = re.sub(r'', '', content, - flags=re.MULTILINE | re.DOTALL) - fh.write(content) - fh.truncate() - - -def latex(): - """Build Sphinx 'latex' target. """ - check_build() - # figs() - if sys.platform != 'win32': - # LaTeX format. - if subprocess.call( - [sys.executable] - + '-msphinx -b latex -d build/doctrees . build/latex'.split()): - raise SystemExit("Building LaTeX failed.") - - # Produce pdf. - # Call the makefile produced by sphinx... - if subprocess.call("make", cwd="build/latex"): - raise SystemExit("Rendering LaTeX failed with.") - else: - print('latex build has not been tested on windows') - - -def texinfo(): - """Build Sphinx 'texinfo' target. """ - check_build() - # figs() - if sys.platform != 'win32': - # Texinfo format. - if subprocess.call( - [sys.executable] - + '-msphinx -b texinfo -d build/doctrees . build/texinfo'.split()): - raise SystemExit("Building Texinfo failed.") - - # Produce info file. - # Call the makefile produced by sphinx... - if subprocess.call("make", cwd="build/texinfo"): - raise SystemExit("Rendering Texinfo failed with.") - else: - print('texinfo build has not been tested on windows') - - -def clean(): - """Remove generated files. """ - shutil.rmtree("build", ignore_errors=True) - shutil.rmtree("tutorials", ignore_errors=True) - shutil.rmtree("api/_as_gen", ignore_errors=True) - for pattern in ['_static/matplotlibrc', - '_templates/gallery.html', - 'users/installing.rst']: - for filename in glob.glob(pattern): - if os.path.exists(filename): - os.remove(filename) - - -def build_all(): - """Build Sphinx 'html' and 'latex' target. """ - # figs() - html() - latex() - - -funcd = { - 'html': html, - 'htmlhelp': htmlhelp, - 'latex': latex, - 'texinfo': texinfo, - 'clean': clean, - 'all': build_all, - 'doctest': doctest, - 'linkcheck': linkcheck, - } - - -small_docs = False -warnings_as_errors = True -n_proc = 1 - -# Change directory to the one containing this file -current_dir = os.getcwd() -os.chdir(os.path.dirname(os.path.join(current_dir, __file__))) -copy_if_out_of_date('../INSTALL.rst', 'users/installing.rst') - -parser = argparse.ArgumentParser(description='Build matplotlib docs') -parser.add_argument("cmd", help=("Command to execute. Can be multiple. " - "Valid options are: %s" % (funcd.keys())), nargs='*') -parser.add_argument("--small", - help="Smaller docs with only low res png figures", - action="store_true") -parser.add_argument("--allowsphinxwarnings", - help="Don't turn Sphinx warnings into errors", - action="store_true") -parser.add_argument("-n", - help="Number of parallel workers to use") - -args = parser.parse_args() -if args.small: - small_docs = True -if args.allowsphinxwarnings: - warnings_as_errors = False -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 {}. {}" - .format(command, _valid_commands)) - func() -else: - raise SystemExit(_valid_commands) -os.chdir(current_dir) diff --git a/examples/units/annotate_with_units.py b/examples/units/annotate_with_units.py index cd4e47ddaf12..dd4aae8b9e5d 100644 --- a/examples/units/annotate_with_units.py +++ b/examples/units/annotate_with_units.py @@ -10,6 +10,10 @@ This example requires :download:`basic_units.py ` """ +# We have to modify the path at run time for sphinx-gallery to compile. +import sys +import os +sys.path.insert(0, os.getcwd()) import matplotlib.pyplot as plt from basic_units import cm diff --git a/examples/units/artist_tests.py b/examples/units/artist_tests.py index 0b078ce5cb6f..263bca96e6a2 100644 --- a/examples/units/artist_tests.py +++ b/examples/units/artist_tests.py @@ -14,6 +14,13 @@ This example requires :download:`basic_units.py ` """ + +# We have to modify the path at run time for sphinx-gallery to compile. +import sys +import os +sys.path.insert(0, os.getcwd()) + + import random import matplotlib.lines as lines import matplotlib.patches as patches diff --git a/examples/units/bar_demo2.py b/examples/units/bar_demo2.py index d18f81b77535..17ae72e9f417 100644 --- a/examples/units/bar_demo2.py +++ b/examples/units/bar_demo2.py @@ -13,6 +13,13 @@ This example requires :download:`basic_units.py ` """ + +# We have to modify the path at run time for sphinx-gallery to compile. +import sys +import os +sys.path.insert(0, os.getcwd()) + + import numpy as np from basic_units import cm, inch import matplotlib.pyplot as plt diff --git a/examples/units/bar_unit_demo.py b/examples/units/bar_unit_demo.py index a4f0bdf17612..01435843b916 100644 --- a/examples/units/bar_unit_demo.py +++ b/examples/units/bar_unit_demo.py @@ -10,6 +10,10 @@ This example requires :download:`basic_units.py ` """ +# We have to modify the path at run time for sphinx-gallery to compile. +import sys +import os +sys.path.insert(0, os.getcwd()) import numpy as np from basic_units import cm, inch diff --git a/examples/units/ellipse_with_units.py b/examples/units/ellipse_with_units.py index 4377d91d9d58..0389956c012f 100644 --- a/examples/units/ellipse_with_units.py +++ b/examples/units/ellipse_with_units.py @@ -9,6 +9,12 @@ This example requires :download:`basic_units.py ` """ + +# We have to modify the path at run time for sphinx-gallery to compile. +import sys +import os +sys.path.insert(0, os.getcwd()) + from basic_units import cm import numpy as np from matplotlib import patches diff --git a/examples/units/evans_test.py b/examples/units/evans_test.py index 85b6dbef1c78..506385e130e2 100644 --- a/examples/units/evans_test.py +++ b/examples/units/evans_test.py @@ -9,6 +9,8 @@ is entirely agnostic to what kind of units client packages use. """ + + from matplotlib.cbook import iterable import matplotlib.units as units import matplotlib.ticker as ticker diff --git a/examples/units/radian_demo.py b/examples/units/radian_demo.py index d6d960e2da1b..03696b5ac47d 100644 --- a/examples/units/radian_demo.py +++ b/examples/units/radian_demo.py @@ -13,6 +13,11 @@ This example requires :download:`basic_units.py ` """ +# We have to modify the path at run time for sphinx-gallery to compile. +import sys +import os +sys.path.insert(0, os.getcwd()) + import numpy as np from basic_units import radians, degrees, cos from matplotlib.pyplot import figure, show diff --git a/examples/units/units_sample.py b/examples/units/units_sample.py index 3ab5a9730bb5..2cb5a56c0b02 100644 --- a/examples/units/units_sample.py +++ b/examples/units/units_sample.py @@ -13,6 +13,13 @@ This example requires :download:`basic_units.py ` """ + +# We have to modify the path at run time for sphinx-gallery to compile. +import sys +import os +sys.path.insert(0, os.getcwd()) + + from basic_units import cm, inch import matplotlib.pyplot as plt import numpy as np diff --git a/examples/units/units_scatter.py b/examples/units/units_scatter.py index 7850adef7e33..f31235a6cf25 100644 --- a/examples/units/units_scatter.py +++ b/examples/units/units_scatter.py @@ -10,6 +10,13 @@ This example requires :download:`basic_units.py ` """ + +# We have to modify the path at run time for sphinx-gallery to compile. +import sys +import os +sys.path.insert(0, os.getcwd()) + + import numpy as np import matplotlib.pyplot as plt from basic_units import secs, hertz, minutes