holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.79k stars 518 forks source link

Using panel with Sphinx documentation #357

Open banesullivan opened 5 years ago

banesullivan commented 5 years ago

Is it possible to use panel with Sphinx documentation to create a panel that can be saved and rendered in the documentation of a project for examples?

For example, I'd love to use the new VTK capabilities of panel to have live-ish demos on the vtki documentation: http://docs.vtki.org

Perhaps it would be possible to run the code on the documentation page and save the output panel in the HTML documentation much like how this currently works for Jupyter notebooks?

jbednar commented 5 years ago

All of our current documentation at panel.pyviz.org is based on panels that are rendered into documentation using Sphinx, so in that sense, yes it's possible. :-) But it sounds like you want the deployed version of the dashboard, created without a notebook, rendered into HTML? I don't think we have a workflow for that already. A good starting point would maybe be for bokeh html file.py (or preferably the as-yet-not-implemented panel html file.py) to work, but I just get ERROR: OutputDocumentFor expects a sequence of Models if I try that with a Panel dashboard that does work with panel serve file.py or bokeh serve file.py.

philippjfr commented 5 years ago

I do think @banesullivan just wants static export. In Panel itself we just build notebooks into docs but it shouldn't be too difficult to make a small sphinx directive that renders and embeds a panel.

banesullivan commented 5 years ago

Yes! I’d love some sort of Sphinx directive that would render and embed a panel! Is this something that might be easy for you all to implement?

Basically, I just want to have some example code that creates a panel in my rst Sphinx documentation and then have a directive that will run that code and embed the output when creating the HTML pages

banesullivan commented 5 years ago

I see that you all are using nbsite.gallery and that the panels are fully embedded in the docs... would it be possible to make a scraper for sphinx_gallery.gen_gallery to do the same thing?

https://github.com/pyviz/panel/blob/4ab07496fbe549c69d45683217d33783e839f077/doc/conf.py#L21

philippjfr commented 5 years ago

Also worth looking at https://blog.jupyter.org/integrating-output-in-documentation-with-jupyter-sphinx-ecf569ddab85

MarcSkovMadsen commented 1 year ago

pkrull is also asking how he can use Panel with Sphinx here https://discourse.holoviz.org/t/how-to-use-sphinx-gallery-with-panel/6035

MarcSkovMadsen commented 1 year ago

For sphinx-gallery there is now a feature request and proof of concept in https://github.com/holoviz/panel/issues/5519.