Skip to content

[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

Closed
wants to merge 11 commits into from
Closed

[MRG] MAINT moving to modern way of building docs. #9402

wants to merge 11 commits into from

Conversation

NelleV
Copy link
Member

@NelleV NelleV commented Oct 14, 2017

  • Switching to Makefile to build the documentation like the rest of the Python
    ecosystem.
  • Related to MEP10

closes #5798

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer
Copy link
Contributor

anntzer commented Oct 14, 2017

A recent sphinx will generate a much simpler makefile

# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS    =
SPHINXBUILD   = python -msphinx
SPHINXPROJ    = foo
SOURCEDIR     = .
BUILDDIR      = _build

# Put it first so that "make" without argument is like "make help".
help:
	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

I would suggest sticking to it (basically sphinx already provides all the necessary machinery), and changing the CI build to use

make SPHINXOPTS=-W html

(disallow warnings -- when building locally I'd much rather have the build go to the end and give me all warnings)
and likewise document

make SPHINXOPTS=-Dplot_gallery=0 html

(which can be combined more easily with -W)

and add the secondary targets manually to the makefile.
(on Windows -- does anyone build the docs from Windows? set SPHINXOPTS=-W & make should work)

But in general I agree with the idea.

@@ -34,9 +34,9 @@ generated.

You can build the documentation with several options:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options -> targets

@choldgraf
Copy link
Contributor

I think this is a great idea...not really any specific complaint from me so long as the docs build fine on the tests/CI. I'm 50/50 on including both a Makefile and a .bat makefile...I know that the .bat is how you'd build the docs on windows, but I can envision someone making changes to one without remembering to change the other...

Copy link
Contributor

@choldgraf choldgraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve pending tests/CI pass

Copy link
Contributor

@anntzer anntzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to dismiss this if you really don't want to switch to the shorter, newer makefile (but why?).

@tacaswell tacaswell added this to the 2.2 milestone Oct 15, 2017
DEPSY_DEFAULT = "_static/depsy_badge_default.svg"


def fetch_depsy_badge():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be ported over as well? This works around depsy not having an https end point which results in matplotlib.org warning about non-secure resources.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also ok with just removing the depsy badge, it seems to not have been updated recently.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll deal with that once I figure out the examples not running issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favor of removing all the badges that we have. We have a problem of signal to noise ratio on the website, so we need to think about what is necessary and what can be remove, and I think this can safely been remove (basically, those badges are only understood by people who already know this information).

Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 in principle, but I think the depsy badge handling needs to be ported.

DEPSY_DEFAULT = "_static/depsy_badge_default.svg"


def fetch_depsy_badge():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also ok with just removing the depsy badge, it seems to not have been updated recently.

* `-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.
Copy link
Member

Choose a reason for hiding this comment

The 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....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd guess the correct invocation is make SPHINXOPTS=-j$N ...


# Change directory to the one containing this file
current_dir = os.getcwd()
os.chdir(os.path.dirname(os.path.join(current_dir, __file__)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that this line is the source of the import failures.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old make.py compiles fine without those lines, so I don't think that this is the problem.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened a PR on sphinx-gallery that "fixes" the problem. I have no clue how the old make.py managed to build the examples considering the sphinx-gallery code I patched.

I would not be surprised that my patch gets rejected, as it opens the door to examples that are not self contained (which is our problem). I think the correct solution would be to make the units examples self-contained and easier to understand.

@tacaswell
Copy link
Member

I am also getting local failures

WARNING: /home/tcaswell/source/p/matplotlib/examples/units/radian_demo.py failed to execute correctly: Traceback (most recent call last):                                                                                                                                                                                                                                                                                               
  File "/home/tcaswell/source/p/matplotlib/examples/units/radian_demo.py", line 17, in <module>
    from basic_units import radians, degrees, cos
ModuleNotFoundError: No module named 'basic_units'

WARNING: /home/tcaswell/source/p/matplotlib/examples/units/units_sample.py failed to execute correctly: Traceback (most recent call last):                                                                                                                                                                                                                                                                                              
  File "/home/tcaswell/source/p/matplotlib/examples/units/units_sample.py", line 16, in <module>
    from basic_units import cm, inch
ModuleNotFoundError: No module named 'basic_units'

WARNING: /home/tcaswell/source/p/matplotlib/examples/units/units_scatter.py failed to execute correctly: Traceback (most recent call last):                                                                                                                                                                                                                                                                                             
  File "/home/tcaswell/source/p/matplotlib/examples/units/units_scatter.py", line 15, in <module>
    from basic_units import secs, hertz, minutes
ModuleNotFoundError: No module named 'basic_units'

WARNING: /home/tcaswell/source/p/matplotlib/examples/units/bar_demo2.py failed to execute correctly: Traceback (most recent call last):                                                                                                                                                                                                                                                                                                 
  File "/home/tcaswell/source/p/matplotlib/examples/units/bar_demo2.py", line 17, in <module>
    from basic_units import cm, inch
ModuleNotFoundError: No module named 'basic_units'

WARNING: /home/tcaswell/source/p/matplotlib/examples/units/annotate_with_units.py failed to execute correctly: Traceback (most recent call last):                                                                                                                                                                                                                                                                                       
  File "/home/tcaswell/source/p/matplotlib/examples/units/annotate_with_units.py", line 15, in <module>
    from basic_units import cm
ModuleNotFoundError: No module named 'basic_units'

WARNING: /home/tcaswell/source/p/matplotlib/examples/units/bar_unit_demo.py failed to execute correctly: Traceback (most recent call last):                                                                                                                                                                                                                                                                                             
  File "/home/tcaswell/source/p/matplotlib/examples/units/bar_unit_demo.py", line 15, in <module>
    from basic_units import cm, inch
ModuleNotFoundError: No module named 'basic_units'

WARNING: /home/tcaswell/source/p/matplotlib/examples/units/artist_tests.py failed to execute correctly: Traceback (most recent call last):                                                                                                                                                                                                                                                                                              
  File "/home/tcaswell/source/p/matplotlib/examples/units/artist_tests.py", line 23, in <module>
    from basic_units import cm, inch
ModuleNotFoundError: No module named 'basic_units'

WARNING: /home/tcaswell/source/p/matplotlib/examples/units/ellipse_with_units.py failed to execute correctly: Traceback (most recent call last):                                                                                                                                                                                                                                                                                        
  File "/home/tcaswell/source/p/matplotlib/examples/units/ellipse_with_units.py", line 12, in <module>
    from basic_units import cm
ModuleNotFoundError: No module named 'basic_units'

generating gallery for gallery/units... [100%] basic_uni

@NelleV
Copy link
Member Author

NelleV commented Oct 15, 2017

@tacaswell I'm not getting local failures. Which version of sphinx & sphinx-gallery are you using? Are you using some form of virtual environments (conda, virtualenv)?

@tacaswell
Copy link
Member

This is venv

23:07 $ pip list | grep -i sphinx
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
Sphinx (1.6.3)
sphinx-gallery (0.1.13)
sphinx-rtd-theme (0.2.4)
sphinxcontrib-websupport (1.0.1)

I think this is the same issue that we are seeing on circle.

@NelleV
Copy link
Member Author

NelleV commented Oct 15, 2017

@tacaswell Yes. I'm reproducing the errors locally. Thanks

@NelleV NelleV changed the title MAINT moving to modern way of building docs. [WIP] MAINT moving to modern way of building docs. Oct 15, 2017
@NelleV NelleV changed the title [WIP] MAINT moving to modern way of building docs. [MRG] MAINT moving to modern way of building docs. Oct 20, 2017
@NelleV
Copy link
Member Author

NelleV commented Oct 20, 2017

This PR is ready to be reviewed.

Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few questions. Still a bit unclear how -j 4 would make it in for parallel builds.

colorspacious
ipython
mock
numpydoc
pillow
sphinx-gallery>=0.1.12
sphinx-gallery
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why drop the pinning on this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a mistake… putting it back.

@@ -28,6 +28,35 @@ apt-run: &apt-install
libgeos-dev \
otf-freefont

conda36-run: &conda36-install
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Contributor

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 that python -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.

command: |
export PATH="$HOME/miniconda/bin:$PATH"
source activate testenv
pip install -ve .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do the docs build with a non-editable installation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should. I can switch to pip install -v . if you prefer.

@tacaswell tacaswell dismissed their stale review October 20, 2017 15:17

Concern about depsy badge addressed.

@NelleV
Copy link
Member Author

NelleV commented Oct 20, 2017

@tacaswell I'm not sure what you mean by the parallel build. make -j N is how you parallelize with make, and sphinx-build pulls in this information. Here are all the options supported by make (notice the last one :) ):

-b  Builder to use; defaults to html. See the full list of builders above.
-a Generate output for all files; without this option only output for new and changed files is generated.
-E Ignore cached files, forces to re-read all source files from disk.
-d  Path to cached files; defaults to /.doctrees.
-j  Build in parallel with N processes where possible.
-c  Locate the conf.py file in the specified path instead of .
-C Specify that no conf.py file at all is to be used. Configuration can only be set with the -D option.
-D <setting=value>
  Override a setting from the configuration file.
-t  Define tag for use in “only” blocks.
-A <name=value>
  Pass a value into the HTML templates (only for HTML builders).
-n Run in nit-picky mode, warn about all missing references.
-v Increase verbosity (can be repeated).
-N Prevent colored output.
-q Quiet operation, just print warnings and errors on stderr.
-Q Very quiet operation, don’t print anything except for errors.
-w  Write warnings and errors into the given file, in addition to stderr.
-W Turn warnings into errors.
-T Show full traceback on exception.
-P Run Pdb on exception.

@NelleV
Copy link
Member Author

NelleV commented Oct 20, 2017

@tacaswell never mind… I just understood your question.
I'll look into that.

Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate templating should be removed.

conda create -n testenv --yes --quiet python
source activate testenv

conda27-run: &conda27-install
Copy link
Member

Choose a reason for hiding this comment

The 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 NUMPY variable for example).

@NelleV NelleV closed this Oct 21, 2017
@choldgraf
Copy link
Contributor

choldgraf commented Oct 21, 2017

is there a reason this was closed? seems like it is getting close!

@NelleV
Copy link
Member Author

NelleV commented Oct 21, 2017

I'm not going to have time to fix the current blockers for merge anytime soon.

@NelleV NelleV deleted the 5798_makefile branch November 7, 2017 20:08
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Makefile for sphinx build
5 participants