-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Migration to sphinx-gallery #8247
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
b918016
b110b1f
ba6d268
c908f98
c61c856
eaaf182
4f92501
40eab47
9738124
8f8d316
55a5840
9bf91a8
f50ab00
7c79b12
1ed25aa
8bc4597
d5583f8
8f5f185
9d805a1
4a13444
8b764e7
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 |
---|---|---|
|
@@ -12,3 +12,4 @@ ipython | |
mock | ||
colorspacious | ||
pillow | ||
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. we need to add graphviz to this list 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. unfortunately, we can't as this file is meant to be used by pip, and graphviz is not pip installable. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,8 @@ <h1>Introduction</h1> | |
<p>Matplotlib tries to make easy things easy and hard things possible. | ||
You can generate plots, histograms, power spectra, bar charts, | ||
errorcharts, scatterplots, etc., with just a few lines of code. | ||
For a sampling, see the <a href="{{ pathto('users/screenshots') }}">screenshots</a>, <a href="{{ pathto('gallery') }}">thumbnail</a> gallery, and | ||
For a sampling, see the <a href="{{ pathto('users/screenshots') | ||
}}">screenshots</a>, <a href="{{ pathto('auto_examples/index') }}">thumbnail</a> gallery, and | ||
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 assume the linebreak does not affect the templating? 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. No, it works fine |
||
<a href="{{ pathto('examples/index') }}">examples</a> directory</p> | ||
|
||
<p>For simple plotting the <tt>pyplot</tt> module provides a | ||
|
@@ -99,7 +100,7 @@ <h1>Documentation</h1> | |
</script> | ||
|
||
<p>Trying to learn how to do a particular kind of plot? Check out | ||
the <a href="{{ pathto('gallery') }}">gallery</a>, <a href="{{ pathto('examples/index') }}">examples</a>, | ||
the <a href="{{ pathto('auto_examples/index') }}">gallery</a>, <a href="{{ pathto('examples/index') }}">examples</a>, | ||
or the <a href="{{ pathto('api/pyplot_summary') }}">list of plotting | ||
commands</a>.</p> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,9 +29,10 @@ | |
extensions = ['matplotlib.sphinxext.mathmpl', 'sphinxext.math_symbol_table', | ||
'sphinx.ext.autodoc', 'matplotlib.sphinxext.only_directives', | ||
'sphinx.ext.doctest', 'sphinx.ext.autosummary', | ||
'matplotlib.sphinxext.plot_directive', | ||
'sphinx.ext.inheritance_diagram', | ||
'sphinxext.gen_gallery', 'sphinxext.gen_rst', | ||
'sphinx_gallery.gen_gallery', | ||
'sphinxext.gen_rst', | ||
'matplotlib.sphinxext.plot_directive', | ||
'sphinxext.github', | ||
'numpydoc'] | ||
|
||
|
@@ -53,6 +54,12 @@ | |
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: | ||
|
@@ -96,6 +103,16 @@ | |
|
||
autodoc_docstring_signature = True | ||
|
||
|
||
# Sphinx gallery configuration | ||
sphinx_gallery_conf = { | ||
# path to your examples scripts | ||
'examples_dirs' : '../examples', | ||
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. Does this mean we can delete the 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. Not yet. Our plot directive writes into mpl_examples, and unfortunately we have a bit more work to do before getting rid of this (including more examples to migrate). This will be my next step. |
||
# path where to save gallery generated examples | ||
'gallery_dirs' : 'auto_examples'} | ||
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. Can we not put it in Whatever it becomes, I don't like the 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. It's the default and is a convention followed by many (if not all) the projects. I'd rather stick with it for consistency. 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'm not sure those are compelling reasons. I went back through the blame 7 years and couldn't find any reasoning behind it (that's not to say that there wasn't one.) My reasoning here is that URLs should be discoverable, simple, and at least try to give some semantic meaning. A user might go to And what does the "auto_" prefix mean? It means that the rst was automatically generated from the example Python code. This is a meaningless distinction to a user. When they see "auto", they see "automatically generated" aka "not hand-written" aka "not very good". I'm not going to claim that all of our examples are 100% clear, but they've all been hand-written in some fashion, and some of them are even quite amazing. In fact, for that same reasoning, I've just talked myself into retracting the "mpl_examples" suggestion, since the "mpl_" prefix is redundant and meaningless in this context. Also, our existing site uses 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. For the time being, the folder cannot be neither "examples" nor "mpl_examples", and this will not change in the foreseeable future considering the state of our examples (unless we remove all examples that are not SG compatible). 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. It's not possible to rename the current examples/mpl_examples to make room for the gallery-based examples? I strongly dislike the 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. Will this end up exposed in the URL? If so, I think we should pick something either a) shorter (ex 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 does show up in the URL, for example this is our gallery at MNE-python. It does have auto-examples in the page, though that's sorta become the convention with sphinx-gallery (same goes for scikit-learn: http://scikit-learn.org/stable/auto_examples/index.html). I seem to remember conversations with folks that this was a non-trivial thing to change but I could be wrong...it's been working out well enough for us. If you want you could use an 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. Nope, it's completely trivial to change: https://unidata.github.io/MetPy/examples/index.html I'm going to argue one more time NOT to use 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. It's not that trivial, because matplotlib somehow does I don't know what in the plot directive that makes this a pain in the butt to change. Which is why I asked for feedback a month ago. 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. FWIW I'll give this a shot to change the name to |
||
|
||
plot_gallery = True | ||
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. Blank line after. |
||
|
||
# Add any paths that contain templates here, relative to this directory. | ||
templates_path = ['_templates'] | ||
|
||
|
@@ -234,7 +251,6 @@ | |
# Additional templates that should be rendered to pages, maps page names to | ||
# template names. | ||
html_additional_pages = {'index': 'index.html', | ||
'gallery':'gallery.html', | ||
'citing': 'citing.html'} | ||
|
||
# If false, no module index is generated. | ||
|
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.
Does parallel build not work?
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.
No, but ironically, the parallel build doesn't change the run time :D
We can easily activate the flags in sphinx-gallery to make it parallel-safe, but considering there is no gain at all, I haven't created the PR yet.
Actually making the code parallel requires more work, but should be doable.
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 I have definitely seen good speed up on building the docs (as they are now) but have found you need to use ~2x the number of workers compared to the number of core.