Skip to content
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

Symbolic link causes problems with images in output cells #49

Open
twiecki opened this issue May 23, 2016 · 15 comments
Open

Symbolic link causes problems with images in output cells #49

twiecki opened this issue May 23, 2016 · 15 comments

Comments

@twiecki
Copy link

twiecki commented May 23, 2016

For example: http://pymc-devs.github.io/pymc3/notebooks/BEST.html
Tries to link to: http://pymc-devs.github.io/pymc3/notebooks/_build/doctrees/nbsphinx/notebooks_BEST_8_0.png

During compilation I get many warnings like:
/home/wiecki/working/projects/pymc/docs/source/notebooks/survival_analysis.ipynb:193: WARNING: image file not readable: notebooks/../_build/doctrees/nbsphinx/notebooks_survival_analysis_11_0.png

I have seen #9 which looks very related and installed from master to make sure #10 was included but those don't fix this issue.

@springcoil
Copy link

No idea how to debug that - do you want to merge WIP already or wait for the fix?

@mgeier
Copy link
Member

mgeier commented May 23, 2016

I don't think #9 and #10 have anything to do with that.

The problem seems to be that when Sphinx reads the intermediate reST file, which contains image links in the form notebooks/../_build/doctrees/nbsphinx/*.png, it apparently doesn't follow the symlink back to the source directory but it applies the .. to the symlink-free original location on the file system (which would actually make sense if this were in a real reST file). Therefore, it doesn't find the intermediate directory where the image files are stored.

This will hopefully be solved with #36, but I'm afraid this won't happen very soon.

In the meantime I guess I'll have to make some kind of work-around, any ideas how to tackle this?

@mgeier
Copy link
Member

mgeier commented May 23, 2016

Correction: The intermediate reST file contains links like this: ../_build/doctrees/nbsphinx/*.png, but Sphinx somehow prepends the directory notebooks/, which contains the source file.
I guess it's actually the operating system that resolves the .. part.

@twiecki
Copy link
Author

twiecki commented May 23, 2016

It seemed to ultimately work in #9, what is different about my usecase? Would it help if I moved the NBs out of the subdirectory? The same problem persists locally.

@mgeier
Copy link
Member

mgeier commented May 23, 2016

The problem is the symbolic link. It should work if you actually move the files to a "real" subdirectory docs/source/notebooks/. If you want, you can then make a symbolic link in the other direction, back to the original place pymc3/examples/notebooks/.

@twiecki
Copy link
Author

twiecki commented May 23, 2016

Oh nice, that works. http://pymc-devs.github.io/pymc3/notebooks/stochastic_volatility.html. Thanks.

@twiecki twiecki changed the title matplotlib plots do not show up Symbolic link seems to cause problems with paths to images May 23, 2016
@mgeier mgeier changed the title Symbolic link seems to cause problems with paths to images Symbolic link causes problems with images in output cells May 24, 2016
@mgeier
Copy link
Member

mgeier commented May 24, 2016

Good to know that the work-around helps. I changed the title to mention that the problem occurs in output cells. There shouldn't be any problems with images in Markdown cells.

@twiecki
Copy link
Author

twiecki commented Jul 15, 2016

Any solution to this? Having the NB directory live in the doc subdir is a bit unwieldy.

@mgeier
Copy link
Member

mgeier commented Jul 16, 2016

Sorry, I don't know how to solve this before #36. But I'm open to suggestions!

If you don't want to move the NB dir into the doc dir, you can do it the other way round, by moving conf.py to your main directory (and then use master_doc = 'doc/index'). Would this be less unwieldy?

@twiecki
Copy link
Author

twiecki commented Jul 16, 2016

Thanks for the suggestion. conf.py as well as Makefile, right?

@mgeier
Copy link
Member

mgeier commented Jul 16, 2016

The Makefile is optional and IMHO not necessary. But if you want to use the auto-generated Makefile as is, I guess you'll have to move it, too. But I don't think that's a good idea since people might think that's a Makefile for the whole program/library, not only for the docs.

You could of course create a custom Makefile and put it anywhere you want, or you could manually call sphinx-build every time, or create a simple shell script, or ...

The IMHO nicest solution would be to use BuildDoc in your setup.py, then you could generate the docs by simply running:

python3 setup.py build_sphinx

In this case, you wouldn't even need to move your conf.py, since you could specify its location in setup.py.

If you want to go that way and need more information, don't hesitate to ask.

@twiecki
Copy link
Author

twiecki commented Jul 18, 2016

Thanks @mgeier. I think I'm making some progress: pymc-devs/pymc#1245

The problem is that build/sphinx directory where the compiled docs get stored does not contain index.html and the other master level files in the root directory but build/sphinx/html/docs/source. Any idea on how to fix that?

@mgeier
Copy link
Member

mgeier commented Jul 19, 2016

I didn't think about this before, but I guess it makes sense that the output directory is laid out like this (mirroring the source directory).

You could try to move index.rst to the main directory, too, but at some point it will get crowded ...

To get nicer URLs for the other pages, you should probably get rid of the sources/ subdirectory.

@johannes-mueller
Copy link

johannes-mueller commented Nov 7, 2019

It works for me when I create a real directory notebooks/ in the sources/ subdirectory and in there have symlinks to the individual notebooks.

I think that's a feasible workaround.

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

No branches or pull requests

4 participants