Skip to main content

A commmand-line interface to add or update TOC to Jupyter Notebooks

Project description

<div align="center">
<img src="misc/logo.png" alt="jupytoc_logo"/>
</div>

<br/>

<div align="center">
<a href="https://badge.fury.io/py/jupytoc"><img src="https://badge.fury.io/py/jupytoc.svg" alt="PyPI version" height="18"></a>
<a href="https://requires.io/github/axelbellec/Jupytoc/requirements/?branch=master"><img src="https://requires.io/github/axelbellec/Jupytoc/requirements.svg?branch=master" alt="Requirements Status" /></a>
<a href="https://opensource.org/licenses/MIT">
<img src="http://img.shields.io/:license-mit-ff69b4.svg?style=flat-square" alt="mit"/>
</a>
<a href="https://travis-ci.org/axelbellec/jupytoc">
<img alt="Build Status" src="https://travis-ci.org/axelbellec/Jupytoc.svg?branch=master">
</a>
<a href='https://coveralls.io/github/axelbellec/Jupytoc?branch=master'><img src='https://coveralls.io/repos/github/axelbellec/Jupytoc/badge.svg?branch=master' alt='Coverage Status' /></a>
</div>

<br/>

<div align="center">
<p><b>Jupytoc</b> generates table of contents for jupyter notebook files. Links are compatible with anchors generated by GitHub.</p>
</div>

<br/>
<br/>

# `$ jupytoc`
:pushpin: A commmand-line interface to add/update/delete TOC to Jupyter Notebooks

## Usage

### Simplest usage

```sh
$ jupytoc <jupyter_notebook>
```

To add toc for all files in a directory, just launch:
```sh
$ jupytoc .
```

### CLI args/otps

```sh
$ jupytoc --help
Usage: jupytoc [OPTIONS] [NOTEBOOKS]...

Options:
-R, --recursive build TOC for all subdirectories recursively
-l, --maxlevel INTEGER limit TOC entries to headings only up to the
specified level
-t, --title TEXT custom TOC title
-s, --stdout print to stdout
-d, --delete remove TOC from notebook file
--help Show this message and exit.
```

### Adding (or update) TOC to all notebooks in a directory and sub directories

```sh
$ jupytoc .
```

### Custom TOC title

Use `--title` option to specify a custom TOC title (Markdown formatted).
e.g. :
```sh
$ jupytoc --title '**Contents**'
```

### Maximum heading level

Use `--maxlevel` option to limit TOC entries to a certain level.
By default, Jupyter Notebook headings are limited to 6 levels.

```sh
$ jupytoc --maxlevel 2
```

### Print generated TOC to stdout

Use `--stdout` flag to print to stdout.

```sh
$ jupytoc --stdout
```

### Deleting TOC

Use `--delete` option to delete a TOC.

```sh
$ jupytoc --delete <jupyter_notebook>
```

## Installation

### **1. PyPI**

```sh
$ pip install jupytoc
```

### **2. GitHub for the latest development version**

```sh
$ pip install git+https://github.com/axelbellec/jupytoc
```

Jupytoc has the following dependencies:

- [click](http://click.pocoo.org/6/): a command line library for Python
- [emoji](https://github.com/carpedm20/emoji/): emoji terminal output for Python

## Features

### Done

- [X] generate TOC a top of file
- [X] add/update an existing TOC in Markdown file
- [X] add/update TOC for all files in the current directory
- [X] handle multiple files input
- [X] limit TOC entries
- [X] add/udpate TOC to all files in a directory/sub directories
- [X] enable custom TOC title editing
- [X] print TOC to stdout
- [X] delete TOC option

### Still in development

- [ ] Test suite


## FAQ


__1. Why do my link anchors generated with `jupytoc` not work when the notebook is read on Github?__

GitHub rending concerning `.ipynb` notebooks do not let us to navigate through links.

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

jupytoc-0.1.4.tar.gz (5.7 kB view details)

Uploaded Source

File details

Details for the file jupytoc-0.1.4.tar.gz.

File metadata

  • Download URL: jupytoc-0.1.4.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for jupytoc-0.1.4.tar.gz
Algorithm Hash digest
SHA256 c1c1b3385f643c840fb3836a4b152dea7d2864164d850d6b684460c93c9f12f5
MD5 8601605c99253b1012fe54cf48f1285c
BLAKE2b-256 40cc376f8cae3eeca65f4e8aa0d270176eaa3a760c608876d29cccbf71d6103b

See more details on using hashes here.

Supported by

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