spatialaudio / nbsphinx

:ledger: Sphinx source parser for Jupyter notebooks
https://nbsphinx.readthedocs.io/
MIT License
451 stars 130 forks source link

Use nbconvert's preprocessor framework #650

Open jasongrout opened 2 years ago

jasongrout commented 2 years ago

As noted in https://github.com/spatialaudio/nbsphinx/issues/341#issuecomment-544119639, nbsphinx directly uses the nbconvert execute preprocessor before the preprocessor queue is invoked. This changes the logic to use the nbconvert preprocessor queue. It also enables the user to give a configuration for preprocessors (for example, I used this to remove cells with certain tags).

The first commit in this PR appears to work just fine. However, with the second commit applied, building the ipywidgets docs with nbsphinx ends with some errors about files (notebooks) not found in the html-collect-pages step. Unfortunately, I ran out of time to debug this, but am opening a draft PR with my current in-progress work in hopes it will be of use.

This begins to address comments from https://github.com/spatialaudio/nbsphinx/issues/285, https://github.com/spatialaudio/nbsphinx/issues/305, https://github.com/spatialaudio/nbsphinx/issues/341.

pep8speaks commented 2 years ago

Hello @jasongrout! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 877:13: E128 continuation line under-indented for visual indent Line 878:17: E128 continuation line under-indented for visual indent

Comment last updated at 2022-06-22 04:30:43 UTC
mgeier commented 2 years ago

Thanks for this PR and sorry for my late response!

It would be great if we could provide a hook for users to provide additional preprocessor settings.

Sadly, I don't have time to look into this either, but maybe someone else does?

I was wondering if the RegexRemovePreprocessor should be forced, but I guess this isn't necessary anymore since https://github.com/jupyter/nbconvert/pull/784 has been merged.

However, I think we should force HighlightMagicsPreprocessor, because otherwise people might inadvertently disable the highlighting of "magic" cells.