-
Notifications
You must be signed in to change notification settings - Fork 568
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
Use nbsphinx instead of converting .ipynb -> .rst #212
Conversation
Cool ! |
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [ |
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 take it nbsphinx executes the notebooks as part of the build, then?
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.
Yes, if there are no outputs, it does.
If there is at least one output, the notebook is not executed (see http://nbsphinx.readthedocs.org/en/latest/pre-executed.html).
I think this looks like a good idea. |
I tested this locally, and it seems to work rather well. There seem to be merge conflicts, but I'd be happy to merge this once it's mergeable. Any further work to explore? |
I did a rebase, now it should be mergeable. Note that the CSS is incomplete and it might not look nice on narrow browser windows and on old browsers, see spatialaudio/nbsphinx#11. |
@mgeier Thank you. This is really cool. I only tried on Chrome but it looks pretty good as is on a narrow window. I did notice a few things when I tested building the nbconvert documentation locally in a virtualenv with jupyter installed, the dev version of nbconvert with your PR, and the nbconvert/docs/requirements.txt:
At minimum, this will be need to be documented. I'm a little concerned about what information might be displayed on an error or warning. It's not a big deal for an individual user but could be an issue when used for documentation or folks running batches of notebooks without close review of the output. If potentially sensitive or secure information were displayed within the error/warning messages, that would be a problem. Not sure of the likelihood of this. Thoughts from all? Overall, this is a big improvement over the current way we have been using nbconvert in documentation. Thanks ☀️ |
A different solution to the Both The further errors and warnings @willingc is describing would also appear when executing the notebooks manually beforehand. Exceptions will cause the build process to fail (unless they are ignored), but warnings on
The Bash error at the bottom is legitimate because the command isn't valid as-is. I don't know what caused the deprecation warning, i'm not getting that on my local installation. Finally, I have no clue if any sensitive or secure information might be displayed in the output of Sphinx, but I think if anything, this is likely to be less of a problem if the notebooks are stored in the repository without output cells. The build process on readthedocs.org has only access to the files of the public repository, so I think it cannot produce anything more private/sensitive as is already available in the (public) repository. |
@mgeier My apologies, wrong notebook on the exclude. For a one off example, it may be okay to change the requests import but that's inefficient as a general solution. I don't want to hold up the PR since I would like to use this for other Jupyter docs. At minimum, this needs to be documented which I am happy to do. The use case that I am most concerned about is someone who has been using nbconvert in their documentation, switches to nbsphinx expecting that the output would not include warnings, and then is surprised that the warnings are displayed in their production docs on RTD. I'm +1 on merging this PR yet I would like f950abe to be removed and the example notebook left as is. I would rather add a section to the bottom of the docs/requirements.txt to include required packages in documentation notebooks (i.e. add requests to the end of the list). |
I just thought it's strange to add an external dependency just to download a single file, which the standard library can perfectly do on its own. But anyway, I don't really care that much. Shall I remove f950abe and instead add I still don't understand your concerns about the warnings. |
It looks like the bash cell is not supposed to be run as is. Maybe it should be a code block in a markdown cell rather than a code cell. |
I mean the one with |
@takluyver Good point. @mgeier I'm going to merge this PR as is. I'll fix up the notebooks and requirements.txt so that you can get back to working on more good stuff for nbsphinx. Thanks for creating nbsphinx. I really like it 😄 🌻 🍰 |
Use nbsphinx instead of converting .ipynb -> .rst
Great, thanks a lot! I wanted to look at the glorious result on readthedocs, but there was a build error: This exception was raised while executing
Isn't that a dependency of Is the option "Install your project inside a virtualenv using But even without that, Hmm, yet another possibility would be that the notebook wants to run |
I think we just need to add mistune to docs/requirements.txt. I've just done that, let's see if it works. |
@takluyver If it doesn't work (which I hope it does), it may be the recent change to jupyter_client. I noticed on jupyter/notebook that the doc build was failing for having setuptools 18.2 vs 18.5. |
Now it works, thanks! I still don't understand why it's necessary to add this to the |
@mgeier Cool. I agree that its weird that RTD is needing this. |
I think it's because RTD invokes |
@takluyver Ugh! Thanks for the explanation. setuptools == utter putrid mess Well said. |
Ah, that explains it! But if you don't mind my asking, why are you even bothering to pass |
When setup.py is run by pip, or when it runs a command like bdist_whl, it does use setuptools, so |
Thanks a lot for the explanation! OK, first I thought: readthedocs uses But, according to the build log, So I guess the problem only occured because the If I'm not mistaken, I think apart from caching, those other dependencies are not strictly necessary anymore for readthedocs since But if anyone else installs The reason why I myself didn't have this problem initially, is because I used Sorry for all the confusion, but I just wanted to see if I can understand this stuff ... Please allow me one final question: How are you installing the development version of |
The readme outlines how to install the dev version locally. "-e" option on pip is the key.
|
|
So pretty much like you. Just under the hood of pip. |
No problem :-). I symlink packages I'm working on into I actually made my own packaging tool, flit, which works like this for development installs. |
Thanks a lot for the explanations, that's good to know! |
Are you going for a 'most packages on PyPI' record? Next step, create a script so you can do it all with |
This is a proof-of-concept for using the nbsphinx extension to use notebooks as Sphinx sources instead of manually converting them to
.rst
files beforehand.It still has a few rough edges regarding the CSS, but in general I think it works quite well.