-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[MRG] MAINT moving to modern way of building docs. #9402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cf33384
68cead4
2a7ab00
4aaeed3
11568d4
517de77
3f9399f
2cb396b
77846ee
2ac57d7
712774f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of these are templated so you don't need to write out two copies for Python 3 and 2. There should not be a separate 36 and 27 template. You can use an environment variable to differentiate if necessary (see the |
||
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 . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do the docs build with a non-editable installation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They should. I can switch to |
||
|
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why drop the pinning on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was a mistake… putting it back. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <target>' where <target> 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 $< $@ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. options -> targets |
||
|
||
* `--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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry if this a silly question, but what in the makefile deals with this? It still seems to only use one processor when running locally.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd guess the correct invocation is make SPHINXOPTS=-j$N ... |
||
|
||
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 | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why switch to conda? It looks like all we are using is python and then pip installing everything else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switch to conda only for the environment: we now need to access the scripts "sphinx-build", and not only the library as before. When installing with --user, we either need to change the PYTHONPATH manually, or use conda.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use
python -msphinx
instead? AFAIK sphinx-build is a strict synonym to it, except thatpython -msphinx
looks up PYTHONPATH (which is the same as what we did before in make.py) whereas sphinx-build uses PATH (which may be set differently).This relates to my earlier point about using the shorter/newer makefile generated by recent versions of sphinx.