├── requirements.txt ├── .gitignore ├── docs └── static │ └── nbreport.gif ├── postBuild ├── jupyter-config ├── nbconfig │ └── notebook.d │ │ └── my_fancy_module.json │ │ └── nbreport.json └── jupyter_notebook_config.d │ └── nbreport.json ├── nbreport ├── static │ ├── extra.css │ └── report.tpl └── __init__.py ├── setup.py └── README.md /requirements.txt: -------------------------------------------------------------------------------- 1 | nbclean 2 | nbformat -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .ipynb_checkpoints 2 | *.egg-info/ 3 | __pycache__/ 4 | example/an_example_notebook.html -------------------------------------------------------------------------------- /docs/static/nbreport.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choldgraf/nbreport/HEAD/docs/static/nbreport.gif -------------------------------------------------------------------------------- /postBuild: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | jupyter bundlerextension enable --py nbreport --sys-prefix 4 | 5 | 6 | -------------------------------------------------------------------------------- /jupyter-config/nbconfig/notebook.d/my_fancy_module.json/nbreport.json: -------------------------------------------------------------------------------- 1 | { 2 | "load_extensions": { 3 | "nbreport/index": true 4 | } 5 | } -------------------------------------------------------------------------------- /jupyter-config/jupyter_notebook_config.d/nbreport.json: -------------------------------------------------------------------------------- 1 | { 2 | "NotebookApp": { 3 | "nbserver_extensions": { 4 | "nbreport": true 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /nbreport/static/extra.css: -------------------------------------------------------------------------------- 1 | /* Add an extra style for a figure caption */ 2 | figure figcaption { 3 | text-align: center !important; 4 | font-style: italic; 5 | padding-bottom: 20px; 6 | } -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | """ 2 | nbreport 3 | """ 4 | 5 | import codecs 6 | import os 7 | from setuptools import setup, find_packages 8 | import nbreport 9 | 10 | install_requires = [] 11 | 12 | setup( 13 | name="nbreport", 14 | description="Generate quick reports", 15 | long_description='', 16 | version=nbreport.__version__, 17 | packages=find_packages(), 18 | package_data={'sphinx_gallery': ['static/report.tpl']}, 19 | url="https://github.com/choldgraf/nbreport", 20 | author="Chris Holdgraf", 21 | author_email='choldgraf@berkeley.edu', 22 | install_requires=install_requires, 23 | license='3-clause BSD', 24 | classifiers=['Intended Audience :: Developers', 25 | 'Development Status :: 3 - Alpha', 26 | 'Framework :: Sphinx :: Extension', 27 | 'Programming Language :: Python', 28 | ], 29 | entry_points={ 30 | 'console_scripts': [ 31 | 'nbreport = nbreport:main', 32 | ]}, 33 | include_package_data=True, 34 | data_files=[ 35 | ("nbreport/static/", ["nbreport/static/report.tpl", 'nbreport/static/extra.css']), 36 | ], 37 | zip_safe=False 38 | ) 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nbreport 2 | 3 | [](https://mybinder.org/v2/gh/choldgraf/nbreport/master?filepath=example%2F) 4 | 5 | Quick generate HTML reports from your Jupyter Notebooks. 6 | 7 | This is a lightweight Jupyter plugin that gives you the option to download 8 | a report from the Jupyter Notebook interface. Upon installing, you get a 9 | new button in the `Download as` section that, when clicked, does the following 10 | things: 11 | 12 | 1. Removes all empty cells 13 | 2. Removes any cells with `hide_cell` in the tags 14 | 3. Removes the code of any cells with `hide_code` in the tags 15 | 4. Clears the `stderr` output 16 | 5. Clears the input / output numbers 17 | 6. Adds author / title information to the top of the page 18 | 6. Outputs the notebook as a single HTML file that can be 19 | opened in the browser. 20 | 21 |  22 | 23 | `nbreport` uses another lightweight tool called [nbclean](https://github.com/choldgraf/nbclean) 24 | in order to accomplish the above, along with a simple template designed 25 | for [nbconvert](https://github.com/jupyter/nbconvert). 26 | 27 | ## Installation 28 | 29 | To install `nbreport`, first clone this repository to your computer, then run 30 | 31 | ``` 32 | pip install -e nbreport/ 33 | ``` 34 | 35 | Finally, activate `nbreport` on your Jupyter environment with the following command: 36 | 37 | ``` 38 | jupyter bundlerextension enable --py nbreport --sys-prefix 39 | ``` 40 | 41 | ## Usage 42 | 43 | There are two primary ways to use `nbreport`: 44 | 45 | * **As a command-line tool**. You can invoke `nbreport` from the command line with the 46 | following command: 47 | 48 | ``` 49 | nbreport path/to/notebook.ipynb 50 | ``` 51 | 52 | It will output the HTML file in the same directory as the notebook you used as input. 53 | 54 | * **From the Jupyter Notebook interface**. From a live Notebook, you can convert the 55 | current notebook to an HTML report by following clicking on `File --> Download As --> NBReport`. 56 | The HTML will be created in the same folder as the notebook you've opened. 57 | 58 | ## Command-line options 59 | 60 | You can expand the functionality of `nbreport` with a few extra command-line options. For 61 | example, the `--css` parameter allows you to include arbitrary extra CSS files with your built 62 | HTML, allowing you to style it however you like. -------------------------------------------------------------------------------- /nbreport/static/report.tpl: -------------------------------------------------------------------------------- 1 | {%- extends 'basic.tpl' -%} 2 | {% from 'mathjax.tpl' import mathjax %} 3 | 4 | 5 | {%- block header -%} 6 | 7 | 8 |
9 | {%- block html_head -%} 10 | 11 | {% set nb_title = nb.metadata.get('title', '') or resources['metadata']['name'] %} 12 |