Skip to content

Conversation

@Titan-C
Copy link
Member

@Titan-C Titan-C commented Dec 21, 2016

This replaces #133
As brought back to life by #186, Sphinx-Gallery does not handle the cases when the documentation structure is in a different place than the location of the makefile and the conf.py files.

This PR aims to fix that and preceding issues stated in #40 #50 #115 #119 #120

For test completeness I know build in circle CI the documentation in various location, with different commands a different themes.

As can be seen from the build logs(https://circleci.com/gh/Titan-C/sphinx-gallery/12?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link). The examples are run only on the first build, later builds can take advantage of the cached files as they are referenced in the same locations and the output to the described location. For review. This are the 3 builds

Since it is possible I have missed cases where links/images/references/etc are not well resolved, the links above point to different places of the documentation I have checked, but please help me explore. And even better tell me if we can elaborate a way to test on this.

There is an issue with circle ci and the cached conda installation that is addressed in #189

# cd to the appropriate directory regardless of sphinx configuration
working_dir = os.getcwd()
os.chdir(app.builder.srcdir)
# os.chdir(app.builder.srcdir)
Copy link

Choose a reason for hiding this comment

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

You probably want to remove this. :)

@sciunto
Copy link

sciunto commented Dec 22, 2016

This patch works well for scikit-image: scikit-image/scikit-image#2395

@sciunto
Copy link

sciunto commented Jan 3, 2017

@Titan-C Do you plan to release a new version soon? That would be helpful for scikit-image.

PS: just realized that we are in the same building :)

@Titan-C Titan-C changed the title Better path handling [MRG] Better path handling Jan 3, 2017
@lesteve
Copy link
Member

lesteve commented Jan 6, 2017

I was on holiday around Christmas and I am currently going through the backlog. I'll look at this one today.

Copy link
Member

@lesteve lesteve left a comment

Choose a reason for hiding this comment

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

Looks good in general. I have a few comments though:

[build_sphinx]
source-dir = docs/
build-dir = docs/_build
source-dir = doc/
Copy link
Member

Choose a reason for hiding this comment

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

This was broken before right, which would mean nobody is relying on it?

I would rather remove this section from setup.cfg and use an explicit sphinx-build command in circle.yml.

If there is a good reason to keep it (maybe this is generated by sphinx-quickstart), this should do the same as cd doc; make html in order not to confuse users.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this was always broken as it is the setup to build the docs from setuptools, and setup tools launches the build from where setup.py is called. So this never worked, you can even see that it has the old docs path, because it was never used, and thus never took care of updating.
But now that we can call sphinx-build from any place I thought to make use of this. Because if setuptools can build the docs it can also directly upload them to pythonhosted.org when uploading the package to PyPI. Of course we stopped hosting the docs in pythonhosted long ago in favor of readthedocs.
In circle.yml all 3 statements in the test do the same, is only to test the build from different places a calling from different commands.

Copy link
Member

@lesteve lesteve Jan 16, 2017

Choose a reason for hiding this comment

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

But now that we can call sphinx-build from any place I thought to make use of this.

I think that is what I have an issue with, python setup.py build_sphinx should build the doc in the same place as cd doc && make html (principle of least surprise). In circle.yml use explicit sphinx-build commands to test out different locations and themes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, least surprise in the doc builds. Travis will do the cd doc && make html to build from the Makefile path. In CircleCI python setup.py build_sphinx will do it from the project root but build in our default location doc/_build/html, additionally `sphinx-build is called for 2 different themes that output in different directories.

----------
figure_list : list of figures absolute paths
sources_dir : str absolute path of Sphinx documentation sources
"""
Copy link
Member

Choose a reason for hiding this comment

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

Maybe document the return type via a Returns section since from the current docstring it is not clear that it returns a tuple

failing_examples = set([os.path.normpath(path) for path in
gallery_conf['failing_examples']])
expected_failing_examples = set([os.path.normpath(path) for path in
failing_examples = {os.path.normpath(path): traceback
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this change is it related to this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes this is entirely related to the PR. The thing is now I pass the absolute path of the files during execution. But at the end when I verify which examples failed I'm matching strings containing the path and those paths must be equal and thus can't have the ../ entries that tend to appear when joining relative paths(Which is how we configure the gallery, relative to conf.py) so the way I found to fix this is to normalize the paths at the end.

Copy link
Member Author

Choose a reason for hiding this comment

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

while debugging my other PR I realized I don't need this.

Copy link
Member

Choose a reason for hiding this comment

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

while debugging my other PR I realized I don't need this.

Can you remove this change if it is not needed?

fname_template = os.path.join(gallery_conf['gallery_dir'], 'image{0}.png')
image_rst, fig_num = sg.save_figures(fname_template, 0, gallery_conf)
assert_equal(fig_num, 2)
assert re.search('/image1.png', image_rst)
Copy link
Member

Choose a reason for hiding this comment

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

I pushed a change to use in which is simpler for simple string comparisons

@Titan-C
Copy link
Member Author

Titan-C commented Jan 12, 2017

Comments have been addressed.

This allows Sphinx-Gallery to be build by a direct call to
sphinx-build, specifying the sources directory and the build output
directory. There is no more the constrain to launch the build from the
makefile is the sources directory.

- Correct relative path when embedding links
- Correct path during build
- Summary of failing examples to work on relative path builds
- Update tests
- Update docs clean and build configs
- Figure test for mayavi
gallery_conf.update(
abort_on_example_error=app.builder.config.abort_on_example_error)

# this assures I can call the config in other places
Copy link
Member

Choose a reason for hiding this comment

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

This comment is related to the line app.config.sphinx_gallery_conf = gallery_conf, isn't it?

@Titan-C
Copy link
Member Author

Titan-C commented Jan 17, 2017 via email

@Titan-C
Copy link
Member Author

Titan-C commented Jan 17, 2017 via email

@Titan-C
Copy link
Member Author

Titan-C commented Jan 17, 2017

I just realized a last minute bug thanks to @chsasank, the zip downloads were using the wrong path. Now it is good.

failing_examples = set([os.path.normpath(path) for path in
gallery_conf['failing_examples']])
expected_failing_examples = set([os.path.normpath(path) for path in
failing_examples = gallery_conf['failing_examples']
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you reverted all the unnecessary changes. Keep failing_examples as it was previously.

Keep the \n\nExamples if you wish.

@Titan-C
Copy link
Member Author

Titan-C commented Jan 17, 2017 via email

@lesteve
Copy link
Member

lesteve commented Jan 17, 2017

@Titan-C
Copy link
Member Author

Titan-C commented Jan 17, 2017 via email

@Titan-C
Copy link
Member Author

Titan-C commented Jan 17, 2017 via email

@lesteve
Copy link
Member

lesteve commented Jan 17, 2017

I fixed the orphan in PR #198

Nice, thanks for doing that in a separate PR!

@lesteve
Copy link
Member

lesteve commented Jan 17, 2017

LGTM, I pushed some cosmetic changes. I'll merge this if this is green.

@lesteve
Copy link
Member

lesteve commented Jan 17, 2017

Green, merging, thanks a lot this is some very nice work to fix in a neat way a long-standing bug!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants