ehmatthes / intro_programming

A set of IPython notebooks and learning resources for an Introduction to Programming class, focusing on Python.
MIT License
396 stars 198 forks source link

Implement an "invisible" cell tag, or metadata attribute #142

Open ehmatthes opened 7 years ago

ehmatthes commented 7 years ago

There are some cells that are required for the .ipynb file to work in development, but shouldn't be shown to the end user. For example, there are some cells that need to have a resources/ directory added to the path variable for imports to work:

# This needs a "hidden" attribute in cell metadata.
import os, sys
cwd = os.getcwd()
resources_path = os.path.join(cwd, 'resources')
if resources_path not in sys.path:
    sys.path.append(resources_path)

This kind of cell needs either an invisible tag or cell metadata attribute, so it can be removed when the notebook is converted to html. This is distinct from hidden, which the user can toggle. For example, cell output can be toggled by the user.

ehmatthes commented 7 years ago

From a comment:

#   These cells can be ignored in the template.
#   {% if cell.tags contains invisible %}
#     {# don't include cell #}
#   {% else %}
#     {{ super() }}