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

Fix CI By Adding PIP to conda envt for docs build #1570

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ dependencies:
- tornado
- entrypoints
- ipykernel
- pip
- pip:
- nbsphinx>=0.7.1
2 changes: 1 addition & 1 deletion docs/source/nbconvert_library.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"source": [
"from urllib.request import urlopen\n",
"\n",
"url = 'http://jakevdp.github.com/downloads/notebooks/XKCD_plots.ipynb'\n",
"url = 'https://jakevdp.github.io/downloads/notebooks/XKCD_plots.ipynb'\n",
"response = urlopen(url).read().decode()\n",
"response[0:60] + ' ...'"
]
Expand Down
25 changes: 20 additions & 5 deletions docs/source/removing_cells.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Removing pieces of cells using cell tags
The most straightforward way to control which pieces of cells are
removed is to use **cell tags**. These are single-string snippets of
metadata that are stored in each cells "tag" field. The
`TagRemovePreprocessor` can be used
`TagRemovePreprocessor` can be used
to remove inputs, outputs, or entire cells.

For example, here is a configuration that uses a different tag for
Expand All @@ -27,17 +27,33 @@ we demonstrate using the nbconvert Python API.
from traitlets.config import Config
import nbformat as nbf
from nbconvert.exporters import HTMLExporter
from nbconvert.preprocessors import TagRemovePreprocessor

# Setup config
c = Config()

# Configure our tag removal
# Configure tag removal - be sure to tag your cells to remove using the
# words remove_cell to remove cells. You can also modify the code to use
# a different tag word
c.TagRemovePreprocessor.remove_cell_tags = ("remove_cell",)
c.TagRemovePreprocessor.remove_all_outputs_tags = ('remove_output',)
c.TagRemovePreprocessor.remove_input_tags = ('remove_input',)
c.TagRemovePreprocessor.enabled = True

# Configure and run out exporter
c.HTMLExporter.preprocessors = ["TagRemovePreprocessor"]
HTMLExporter(config=c).from_filename("path/to/mynotebook.ipynb")
c.HTMLExporter.preprocessors = ["nbconvert.preprocessors.TagRemovePreprocessor"]

exporter = HTMLExporter(config=c)
exporter.register_preprocessor(TagRemovePreprocessor(config=c),True)

# Configure and run our exporter - returns a tuple - first element with html,
# second with notebook metadata
output = HTMLExporter(config=c).from_filename("your-notebook-file-path.ipynb")

# Write to output html file
with open("your-output-file-name.html", "w") as f:
f.write(output[0])


Removing cells using Regular Expressions on cell content
--------------------------------------------------------
Expand All @@ -63,4 +79,3 @@ an arbitrary number of whitespace characters followed by the end of the string.
See https://regex101.com/ for an interactive guide to regular expressions
(make sure to select the python flavor). See https://docs.python.org/library/re.html
for the official regular expression documentation in python.