DOC/DEV: add docs for enabling interactive examples#20843
DOC/DEV: add docs for enabling interactive examples#20843rgommers merged 13 commits intoscipy:mainfrom
Conversation
|
Thanks, this is very helpful! I gave it a spin for the 1.13.1 docs - it's live on https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.vq.vq.html now:
To enable: Putting the pattern back immediately disables things again. One thing I noticed is that the vertical height is too small. Changing it in |
|
@agriyakhetarpal you'll be interested in this I'm sure (and may know the answer for the |
Thanks for tagging me, @rgommers! The last paragraph in the Global Configuration section under the |
|
https://jupyterlite-sphinx.readthedocs.io/en/latest/directives/try_examples.html#global-min-height suggests we need
That's exactly what we don't want I think. The minimum height should be okay by default, it's much too small now. It works fine in the PyWavelets API reference docs. |
|
Ah, yes. Sorry about that. |
|
I just added these specific commands @rgommers gave above to $ ssh your-username@docs.scipy.org
$ cd /srv/docs_scipy_org/doc/scipy-1.13.1
$ vim try_examples.json # edit the ignore list to remove: ".*" |
melissawm
left a comment
There was a problem hiding this comment.
Thanks @steppi - this is looking good!
I have a few questions (and I'm not sure if they're in scope for users, but as a maintainer I think they are):
- How is the kernel created and connected to our docs?
- Where are the ipynb files generated by the docs build?
- What is the path for a generated ipynb for a particular example/page? (this can be important also in the full page case like in #20303
|
Thanks Melissa!
I'm not aware of the underlying details but I know: We have the Line 12 in 4759208 which get installed here Line 78 in 4759208 There's some metadata in the generated notebooks that tells the system to look for a Python kernel. nb["metadata"] = {
"kernelspec": {
"display_name": "Python",
"language": "python",
"name": "python",
},
"language_info": {
"name": "python",
},
}
The path to these notebooks is
This might need some work for the sake of ergonomics. Each notebook's name is based on a and find the <button class="try_examples_button"
onclick="window.tryExamplesShowIframe('732d240c-3ec6-4d9f-8c2b-8318deab1a79','284465d0-7adb-432b-995a-c1e126ab17b9','795d8fdc-a0ba-4c79-97ab-90de384b72b5','../../lite/tree/../notebooks/?path=7b2233aa_1a1d_40fe_9a23_4846c195450f.ipynb','None')">
Try it in your browser!
</button>The name of the |
|
So, does that mean we are using a vanilla kernel? I thought there was a step to build and select a specific kernel with a specific scipy version? Is that outdated info? |
Having a specific SciPy version is in the works, but isn’t ready yet. In the jupyterlite-sphinx docs I was just trying to point out that the problem exists. It’s much easier to solve for other projects though. SciPy is tough because of all of the Fortran. |
rgommers
left a comment
There was a problem hiding this comment.
Looks good to me for now. We've enabled interactive examples four days ago, and nothing went wrong yet. So let's call this good for now.
|
Nice to see this has been merged and all examples are enabled by default! Not crucial but I was a bit confused originally because I was looking at the dev website and interactive examples are not enabled on the dev website for example https://scipy.github.io/devdocs/reference/generated/scipy.cluster.vq.vq.html#c58617e0-b72b-447b-b0cf-19e78ade50b3. I guess the reason is that you want it disabled by default and then enabled explicitly by sshing to the doc server and editing |
Long term, no. But I think for now it's more confusing then helpful to default to adding the buttons, since any local changes to |
|
Ah yeah good point indeed, I didn't think of this. By the way there is likely a way to extend https://github.com/lesteve/scipy-tests-pyodide to run the Scipy doctests inside Pyodide and get an idea of what works and what doesn't, I need to look at it. Minor side-comment: what you call examples (code examples in |
|
Re examples: yes indeed. We have longer-form content too in the User Guide, and that is still in the process (actually near the beginning of the process) to be migrated to executable content: https://scipy.github.io/devdocs/tutorial/index.html#executable-tutorials. Long-form
That looks like quite magical hackery to make things work. Would the need for this be removed though by simply building a separately installable |
Not sure which part you are talking about, but it certainly is a bit 😅. A few things to note:
|



This PR adds information to the releasing section of the core developer guide and the "Rendering documentation locally with Sphinx" section of the contributor guide describing how to enable interactive documentation with jupyterlite-sphinx.
The information I've added to the releasing section is terse, giving only a mechanical description of what steps to take. This seems in line to me with how
releasing.rst.incis structured. I've added these steps to the "Wrapping Up" subsection.The information I've given in the contributor guide has more detail, giving some explanation of what is going on, and showing what
try_examples.jsonlooks like in a clean doc build. I think that some contributors may be curious about these things.Additional information
Pyodide 0.26 was released recently, which updated the SciPy version to 1.12. My understanding is that the jump from 1.11 to 1.12 was rather large, and examples running with 1.12 should work well enough for the latest version of SciPy (now 1.13, soon to be 1.14). I think now is a good time for us to turn on the interactive examples. I suppose this should go through discourse.
cc @rgommers, @melissawm