question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enable Jupyter Sphinx Extension in docs?

See original GitHub issue

While writing documentation, I noticed the extended use of the IPython Sphinx Directive.

I bet most pvlib users like to play with pvlib in interactive environments. However, I think Jupyter Notebooks are getting more common/widespread when compared to IPython consoles. I wondered if it would be acceptable to allow code in the documentation to look more like notebooks instead of consoles.

There is this extension called Jupyter Sphinx, under the umbrella of the Jupyter organization.

I think it could have a couple of advantages:

  • Simpler code (i.e.: no need to @savefig)
  • Removal of In [xx]:, which makes it harder to read, copy and paste
  • Easier to read, since blank lines are honored in the code
  • More similarities to a Jupyter notebook (so maybe more user-friendly for readers)
  • Allows to hide input/output
  • Allows to download as a Notebook or Python script
  • Allows to emphasize lines in a cell (very useful when wanting to highlight something in the documentation)
  • The style can be tweaked to, for example, remove the box shadows (to avoid changing too much the current looks of the docs)
  • Allows for interactive plots with Plotly, and Pandas has a Plotly backend, so it would be very easy to have interactive plots in the documentation without adding clutter nor assuming readers need to know about Plotly/Matplotlib

A couple of (maybe) disadvantages:

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Pequecommented, Jan 22, 2022

@wholmgren It’s true that the directive had 3 commits in the last 2 years, and the documentation still states:

The IPython Sphinx Directive is in ‘beta’ and currently under active development. Improvements to the code or documentation are welcome!

jupyter-sphinx seems to be a bit more active and there does not seem to be a “beta” statement in the docs.

PS: Cross-referencing https://github.com/jupyter/jupyter-sphinx/issues/36.

1reaction
kanderso-nrelcommented, Jan 16, 2022

Thanks for the thorough summary @Peque! Just to have something to look at, here’s the result of naively replacing ipython w/ jupyter-execute:

Of course blocks of code with multiple outputs only show the last output now, so a little restructuring would be needed. Also, it seems like ?? doesn’t work?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use Jupyter notebooks in Sphinx - Read the Docs
There are a few extensions that allow integrating Jupyter and Sphinx, and this document will explain how to achieve some of the most...
Read more >
Sphinx extension for rendering of Jupyter interactive widgets.
jupyter -sphinx enables running code embedded in Sphinx documentation and embedding output of that code into the resulting document. It has support for...
Read more >
How Jupyter Book and Sphinx relate to one another
Sphinx primarily uses a markup language called reStructuredText to write documents. This is similar to markdown, though is less-popular and more flexible. In ......
Read more >
Integrating output in documentation with jupyter-sphinx
We have just made an addition to this list, a freshly rewritten jupyter-sphinx extension, that was previously specialized to render Jupyter ...
Read more >
jupyter-sphinx - PyPI
Jupyter Sphinx Extensions ... jupyter-sphinx enables running code embedded in Sphinx documentation and embedding output of that code into the resulting document.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found