Skip to main content

A Jupyter notebook extension to hide code and prompts.

Project description

Hide_code

https://img.shields.io/github/license/mashape/apistatus.svg

Release build

https://travis-ci.org/kirbs-/hide_code.svg?branch=master

Development build

https://travis-ci.org/kirbs-/hide_code.svg?branch=dev)

Introduction

hide_code is an extension for Jupyter/IPython notebooks to selectively hide code and prompts. Make a notebook a code free document for exporting or presenting with a single click by pressing

https://raw.githubusercontent.com/kirbs-/hide_code/dev/images/button.png

Normal

https://raw.githubusercontent.com/kirbs-/hide_code/dev/images/1.1.png

Hide code enabled

https://raw.githubusercontent.com/kirbs-/hide_code/dev/images/1.2.png

Or customize each cell by selecting “Hide code” from the Cell Toolbar dropdown. Then use “Hide Code” and “Hide Prompts” checkboxes to hide the specific cell’s code or cell’s input/output prompts.

https://raw.githubusercontent.com/kirbs-/hide_code/dev/images/2.png

Normal

https://raw.githubusercontent.com/kirbs-/hide_code/dev/images/3.1.png

Hide code enabled

https://raw.githubusercontent.com/kirbs-/hide_code/dev/images/3.2.png

Exporting

Exporting respects hide code/prmpt cell selections only. Output is saved in Jupyter’s current working directory with the notebook’s file name + ‘.html’ or ‘.pdf’.**Exporting to PDF via notebook requires** wkhtmltopdf.

This feature continues to evolve. Items on the road map incude:

  • saving to a different file loaction.

  • saving as a different file name.

  • support for custom CSS.

  • single click exporting with all code and prompts hidden (similar to how the toolbar button).

Via notebook

To export via HTML or PDF simply click on the respective button.

https://raw.githubusercontent.com/kirbs-/hide_code/dev/images/4.1.png

Via nbconvert command line

To export via nbconvert command line, nbconvert 4.2 or later is required. Hide_code adds two export options to nbconvert, hide_code_html and hide_code_pdf.

Note: PDF exporting via command line uses nbconvert’s built in PDF exporter.

jupyter nbconvert –to hide_code_html notebook_to_convert.ipynb

jupyter nbconvert –to hide_code_pdf notebook_to_convert.ipynb

Installation

Via pip

pip install hide_code

Via setuptools

  1. Download and unzip this repository.

  2. Change to unzipped directory.

  3. Execute python setup.py install

Installation Troubleshooting

If installation complains the directory doesn’t exist, you’re Jupyter/IPython installation probably isn’t in one of the usual places. Locate Jupyter’s configuration directory, then use code below to install in a non-standard directory.

` import hide_code.hide_code as hc dir = “<full path to Jupyter config directory>” hc.install(dir) `

Requirements

  • Jupyter notebook 4.x+

  • Jupyter nbconvert 4.2+ if using nbconvert command line exporting

  • pdfkit & wkhtmltopdf

  • Python 2.7 or 3.3+

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hide_code-0.2.1.tar.gz (10.7 kB view details)

Uploaded Source

File details

Details for the file hide_code-0.2.1.tar.gz.

File metadata

  • Download URL: hide_code-0.2.1.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hide_code-0.2.1.tar.gz
Algorithm Hash digest
SHA256 47464a5d9d54a1662702c02ce989c71e53286b587fe54189639f0efd2c929eeb
MD5 4b43f8b9a31020ff05daae7892e19aa7
BLAKE2b-256 ac5eefbadfc379c57473a127a6b47a92f6ee2adba81373011bdb3a90c2d2a6d4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page