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
Sphinx bokeh_plot extension should work outside project docs #5955
Comments
AFAIK the docs will have to be served by a real HTTP server. That is why we have a simple Flask |
Sorry, I didn't elaborate on my use case. I'm actually trying to build custom docs, not the bokeh ones. I realize this sphinx extension was designed primarily for building the bokeh docs, but with this small change it's also incredibly useful for building custom static docs. From what I can tell from I can submit a PR if this sounds good. |
Right I understood that. I was suggesting that you do serve them, even locally, which is as simple as |
Also are you testing the directive in a top level page? (I think you must be?) On a lark I tried building the docs with To make |
I was originally thinking of sharing my custom documentation (with non-python users) by simply sharing the static html files, as that way I could avoid the need to maintain a server. However, after a bit of consideration and discussion with the users, we've decided that the cost of maintaining a documentation server is worth the benefits it provides. I had thought the original use case would be more common, but maybe not.
Yeah, good catch, it totally breaks subdirectories.
What would the other advantages be? It sounds like it would involve a lot of complexity. |
Well being able to use relative links is in general a good thing. In addition to letting things work with static (non-served) resources, which I think would indeed be more user-friendly, it would let me simplify some currently gorpy things in our nginx config for the main docs site. I won't fault anyone else for not being motivated by that last, though. :)
It's mostly just bookkeeping, so that the directive can be a good citizen and cleanup properly after itself, or update properly when source files are out of date. I'd describe it as more tedious than complex, but still some work either way. Or maybe I am overthinking, maybe there is some small set of changes here: https://github.com/bokeh/bokeh/blob/master/bokeh/sphinxext/bokeh_plot.py#L268-L286 and wherever |
I have a a bit of a hacky solution to make it work for my specific use case. Unfortunately I don't have a ton of time to find an elegant method worthy of a PR. What I ended up doing was:
I am building my docs on Linux right now but it has been working with gh-pages with these changes. I can post more details on gist if it is any use to anyone. |
@hallyourbase please do post, I definitely want to fix this up in the library itself, but it's one task of many |
@bryevdv Here are the changes I had made. Like I said, not an elegant solution so I am hesitant to create a PR. Changes are in |
@bryevdv Any updates on this? Do you want me to make a PR as described above? |
@hallyourbase If you submit a PR that will make it much easier to compare the changes, so I'd say yes, though it may be starting point for more discussion or changes |
@bryevdv Roger that, thanks. Submitted a first cut at it. Not the most elegant solution but I wanted to get the conversation going. |
OK the other PR has been merged and offers a possible immediate way forward, but leaving this issue open to try and tackle the broader task of making all file locations more flexible later (i.e. please be aware the method in the PR may change in the future) |
This would be incredibly helpful since the extension doesn't seem to embed usable plots on ReadTheDocs and I hate the idea of using screenshots in my docs |
@Benjamin-Lee are you interested in working on it? It's not likely that I will be able to prioritize this anytime soon over other tasks, but I suspect it would be approachable to any non-beginner python dev, and I'd be happy to help provide guidance. |
Sure -- I've been able to get working plots in my Sphinx docs by embedding manually outputted HTML so I can take a stab at it when I get a chance. I'll need to into the details of how the extension works first. |
@Benjamin-Lee Great, sure, most of the relevant code is in this file: https://github.com/bokeh/bokeh/blob/master/bokeh/sphinxext/bokeh_plot.py Things are a little complicated by the fact that there are three ways to include a plot:
You can see these branches commented in the So what is the task? Mostly bookkeeping. Those two function I think the first part of that is just calling |
When using the sphinxext.bokeh_plot directive with the example from the docs, the sphinx build executes successfully (after following #5951). The js script is generated and copied into
SPHINX_DOCS_ROOT_PATH/build/html/scripts/bokeh-plot-index-inline-5.js
.However when the file
SPHINX_DOCS_ROOT_PATH/build/html/index.html
is opened locally in chrome, the plot doesn't render (although the code-block does), and the console gets the following error:Failed to load resource: net::ERR_FILE_NOT_FOUND
with a link tofile:///scripts/bokeh-plot-index-inline-5.js
.When I edited line 122 of
PYTHON_LIB_PATH/bokeh/sphinxext/bokeh_plot.py
fromscript_path = join("/scripts", js_name)
toscript_path = join("scripts", js_name)
, the plot appeared. I don't know a lot about web development, so I don't know if removing the/
would break documentation hosted on a server.Version Info:
Python version : 3.6.0 | packaged by conda-forge | (default, Jan 14 2017, 03:13:00)
IPython version : 5.1.0
Bokeh version : 0.12.4
BokehJS static path : /Users/Atom/.anaconda/envs/py3/lib/python3.6/site-packages/bokeh/server/static
node.js version : v6.3.1
npm version : 3.10.3
jupyter --version : 4.2.1
jupyter notebook --version : 4.3.1
os version : macOS 10.12.3
browser verision: Google Chrome Version 56.0.2924.87 (64-bit)
sphinx version: 1.5.3
This is a really awesome sphinx extension!
The text was updated successfully, but these errors were encountered: