Skip to content
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

How to skip some cells? #285

Closed
wookayin opened this issue Feb 14, 2019 · 5 comments
Closed

How to skip some cells? #285

wookayin opened this issue Feb 14, 2019 · 5 comments

Comments

@wookayin
Copy link

wookayin commented Feb 14, 2019

This is really a great plugin for sphinx!

I am curious how we can skip some cells from ipython notebooks that we mark using some comments, directives, or cell metadata to be excluded in converting. This would be super useful in writing documentations when we want to exclude some preambles or dirty data preparation codes from the rendered sphinx docs.

I don't think ipython nbconvert does have this feature :)

@mgeier
Copy link
Member

mgeier commented Feb 18, 2019

Thanks!

Is https://nbsphinx.readthedocs.io/en/0.4.2/hidden-cells.html what you need?

when we want to exclude some preambles or dirty data preparation codes

Well it would probably be better to clean up the preparation code, wouldn't it?

And did you consider moving the (clean) preparation code to a separate .py file and then using import to work with it in your notebook?

I don't think ipython nbconvert does have this feature :)

In fact, there are multiple ways to do this in nbconvert:

By regex with https://nbconvert.readthedocs.io/en/latest/api/preprocessors.html#nbconvert.preprocessors.RegexRemovePreprocessor

By tags with TagRemovePreprocessor.remove_cell_tags and TagRemovePreprocessor.remove_input_tags (see https://nbconvert.readthedocs.io/en/latest/config_options.html)

@wookayin
Copy link
Author

This works so great, sorry for missing that!

@ratnanil
Copy link

ratnanil commented Oct 17, 2019

I'd be very interested to use nbconvert.preprocessors.RegexRemovePreprocessor. Can this funcionality be used within nbsphinx? I cant find anything in the docs..

@ratnanil
Copy link

ratnanil commented Oct 18, 2019

It seems that nbconvert.preprocessors.RegexRemovePreprocessor is disabled (see below, and also #305 (comment)). Does this mean that I cannot use RegexRemovePreprocessor?

nbsphinx/src/nbsphinx.py

Lines 722 to 726 in 880bf3a

config=traitlets.config.Config({
'HighlightMagicsPreprocessor': {'enabled': True},
# Work around https://github.com/jupyter/nbconvert/issues/720:
'RegexRemovePreprocessor': {'enabled': False},
}),

@mgeier
Copy link
Member

mgeier commented Oct 19, 2019

@ratnanil See my answer at #341 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants