Skip to content

Conversation

@emmanuelle
Copy link
Member

This PR ports our gallery examples to sphinx-gallery (http://sphinx-gallery.readthedocs.io/en/latest/).
This PR addresses #1973.

Several modifications were required to use sphinx-gallery, such as

  • using .rst instead of .txt for all source files (including generated api)
  • modifiying blocks of comments in the example files

I also had to include the source code of sphinx-gallery, since I needed to do a slight modification to one of these files. I opened a PR on sphinx-gallery (sphinx-gallery/sphinx-gallery#119), if it gets merged in their next release we'll remove our local copy.

Modified comments in some gallery examples for compatibility with
sphinx-gallery parsing. Also modified some links in the narrative doc
since image file names have changed.
I had to make a slightly modification in one of sphinx-gallery's files to
make it work with scikit-image. I opened a pull request on sphinx-gallery
github, hopefully we can delete the local copy after their next release.
@emmanuelle
Copy link
Member Author

I haven't been able to use yet all the cool features of sphinx-gallery. One of them is the possibility to link automatically to examples in the API reference, see http://sphinx-gallery.readthedocs.io/en/latest/advanced_configuration.html#references-to-examples

All projects using this feature of sphinx-gallery (such as nilearn, mne-python) seem to rely on templates for the generation of their API. In scikit-image, we use apigen.py, but not templates. Before hacking apigen.py, I'd like to get feedback from sphinx experts: what are the pros and cons of using either apigen.py or templates?

@soupault soupault added 📄 type: Documentation Updates, fixes and additions to documentation new feature 💪 Work in progress labels May 10, 2016
@emmanuelle
Copy link
Member Author

@scikit-image/core I know that this PR is breaking Travis, but I would still welcome comments, in particular about the API generation (see my previous comment). Thanks!

@emmanuelle
Copy link
Member Author

Regarding Travis' cause of failure, I've opened an issue (sphinx-gallery/sphinx-gallery#120) on sphinx-gallery, since the error is weird: the image file is mentioned as "not readable", but is correctly included in the html page...

Any idea about this weird error?

@stefanv
Copy link
Member

stefanv commented May 19, 2016

This is a great step forward, thanks Emmanuelle! Can you explain what you
mean by "template"? At the moment, apigen.py just imports scikit-image and
traverses the submodule tree, figuring which functions to autodoc, so that
we don't have to keep an index up to date when new functionality is added.

On Wed, 18 May 2016 at 22:41 Emmanuelle Gouillart [email protected]
wrote:

Regarding Travis' cause of failure, I've opened an issue (
sphinx-gallery/sphinx-gallery#120
sphinx-gallery/sphinx-gallery#120) on
sphinx-gallery, since the error is weird: the image file is mentioned as
"not readable", but is correctly included in the html page...

Any idea about this weird error?


You are receiving this because you are on a team that was mentioned.

Reply to this email directly or view it on GitHub
#2078 (comment)

@emmanuelle
Copy link
Member Author

Yeah, I'm super excited about it :-). Having the little pop-up when hovering over thumbnails, or links to the API in the examples, is really cool. I just have to solve this sphinx warning/error now :-/.

About templates, what I meant is that (from what I understand), the content of API is generated by apigen.ApiDocWriter.generate_api_doc (am I wrong maybe?) when make calls python tools/build_modref_templates.py. generate_api_doc builds a rst string for the objects of a given module.

On the other hand, other packages (sphinx-gallery, nilearn) use templates as in https://raw.githubusercontent.com/nilearn/nilearn/master/doc/templates/function.rst
In particular, .. include:: {{module}}.{{objname}}.examples is used to include a small gallery of thumbnails of examples using a given function.

@emmanuelle
Copy link
Member Author

Travis is happy now, so I would be happy to get reviews :-).

######################################################################
# We can use these functions as we would normally use them, but now they work
# with both gray-scale and color images. Let's plot the results with a color
# image:
Copy link
Member

Choose a reason for hiding this comment

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

@emmanuelle sorry, I haven't been following this PR, but is this format change necessary? I think it's way uglier to read!

Copy link
Member Author

Choose a reason for hiding this comment

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

@jni it is necessary indeed (strings within triple quotes are not transformed to text blocks but appear in the code). The rationale between this is that it's better to teach users to put comments with # than within triple quotes (see the discussion in sphinx-gallery/sphinx-gallery#120), since triple quotes should be docstrings.

But it's a bit ugly to read indeed, and it was a pain to implement :-).

@emmanuelle
Copy link
Member Author

@sciunto @jni all the files in ext/sphinx-gallery are directly copied from the sphinx_gallery package. Any changes that we make should be submitted as pull requests to the original package.

"""
######################################################################
#As you can see, the 10-pixel wide black square is highlighted since
Copy link
Member

Choose a reason for hiding this comment

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

Also here and below :).

@soupault
Copy link
Member

soupault commented Jun 2, 2016

@sciunto of course, sorry. Worth trying to run your scanner on 0.11 then ( IMO :) ).

@emmanuelle sorry for attacking your patience 😃. I've added just a couple of concluding remarks.

@emmanuelle
Copy link
Member Author

@soupault no worries, thank you for the additional review. I removed the commented lines. About the missing spaces, it's some sphinx / sphinx-gallery magic: the layout is broken if I add the spaces. Maybe someone else can figure out if this can be improved. At the moment I'm in the middle of a 24/7 synchrotron campaign, so catching up with PRs is not easy. I let you guys decide if it can be merged as such.

@soupault
Copy link
Member

soupault commented Jun 5, 2016

@emmanuelle this builds and works fine for me https://gist.github.com/soupault/170e3065384431ae438e3793ac185fc2 . You have whitespaces after # for any other example, haven't you?

@emmanuelle
Copy link
Member Author

If you can improve this, it's perfect, but I have no time to fix it in the next few days (experiments running 24/7). Could you please submit a pull request to my branch, or if the PR can be merged with this minor style problem, file a separate PR later on? Thanks!

@soupault
Copy link
Member

soupault commented Jun 5, 2016

@emmanuelle I understood. Examples will need an extra review anyways, for me it is a no blocker.

I think the PR is finalized in it's essential part. As we have 👍 from @sciunto and several new PRs are starting to depend on this, I'm going for a merge.

@emmanuelle thank you a lot for this awesome work, and sorry again for any offense made! 🍷

@soupault
Copy link
Member

soupault commented Jun 5, 2016

@emmanuelle could you squash the commits, please? It is not possible to do this via GitHub interface ('Not enabled for this repository' 😕 )

Removed a clumsy workaround (about paths)

Fixed links to image files to fix sphinx warning.

Removed non-ascii character

Another non ascii character

And another non-ascii character... (to be squashed later on)

Corrected some typos in the docstrings of sphinx-gallery files

These corrections have also been submitted as a patch to the original
sphinx-gallery project (scikit-image#121)

Corrected the appearance of two examples of the gallery

Tweaked CSS for larger images

Added sphinx-gallery's license and a README.txt about the origin of
this directory.

Edited gabor_from_astronaut example for nicer popup

PEP 8 + minor fixes

Removed commented lines of code
@emmanuelle
Copy link
Member Author

@soupault I squashed most commits together, I only left the most important ones at the beginning because it may be important to keep a bit of granularity for an important move.

@soupault
Copy link
Member

soupault commented Jun 6, 2016

@emmanuelle Build fails on OS X.
Maybe worth squashing also 94d051c and d998e7e as the former is performing files' renaming while the latter is undoing it.

@sciunto
Copy link
Member

sciunto commented Jun 6, 2016

It's a latex problem


�[31;01mWarning, treated as error:�[39;49;00m

WARNING: display latex '\\sqrt{2}sigma': latex exited with error

[stdout]

This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=latex)

 restricted \write18 enabled.

entering extended mode

(./math.tex

LaTeX2e <2016/03/31>

Babel <3.9r> and hyphenation patterns for 22 language(s) loaded.

(/usr/local/texlive/2016basic/texmf-dist/tex/latex/base/article.cls

Document Class: article 2014/09/29 v1.4h Standard LaTeX document class

(/usr/local/texlive/2016basic/texmf-dist/tex/latex/base/size12.clo))

(/usr/local/texlive/2016basic/texmf-dist/tex/latex/base/inputenc.sty



! LaTeX Error: File `utf8x.def' not found.



Type X to quit or <RETURN> to proceed,

or enter new name. (Default extension: def)



Enter file name: 

! Emergency stop.

<read *> 



l.158 \endinput

               ^^M

No pages of output.

Transcript written on math.log.

@sciunto
Copy link
Member

sciunto commented Jun 7, 2016

@soupault Looks like it's travis. Same problem here #2129

@soupault
Copy link
Member

soupault commented Jun 7, 2016

This is passing now.
Builds on OS X started to fail 2 days ago, not sure that is the cause... Let's give a life to this PR and then investigate that issue.

😨

@soupault soupault merged commit 47d0aa9 into scikit-image:master Jun 7, 2016
@emmanuelle
Copy link
Member Author

Thank you !!!

@stefanv
Copy link
Member

stefanv commented Jun 7, 2016

This was a massive amount of work; thank you so much @emmanuelle and @soupault for diligent reviewing.

@stefanv
Copy link
Member

stefanv commented Jun 7, 2016

Quick question: is this kind of output expected?

plotting code blocks in ../examples/transform/plot_seam_carving.py
 - time elapsed : 0.12 sec
plotting code blocks in ../examples/transform/plot_seam_carving.py
 - time elapsed : 0.12 sec
plotting code blocks in ../examples/transform/plot_seam_carving.py
 - time elapsed : 1.2 sec
plotting code blocks in ../examples/transform/plot_seam_carving.py
 - time elapsed : 0.11 sec
plotting code blocks in ../examples/transform/plot_seam_carving.py

@emmanuelle
Copy link
Member Author

Yes, this output comes from sphinx_gallery. It can be useful to detect examples that take a lot of time to build. If you think that this is too verbose, we could submit a PR to sphinx_gallery so that this output can be optional only.

@emmanuelle
Copy link
Member Author

@soupault do you mean that building the doc (make html) is failing for you on OS X?

@soupault
Copy link
Member

soupault commented Jun 8, 2016

@emmanuelle no, not for me. There were some issues with our OS X Travis build (actually, I think that was Travis bug). See #2078 (comment) for the error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📄 type: Documentation Updates, fixes and additions to documentation 🙏 Feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants