Jupyter Notebook → reStructuredText Cells
Project description
A Python utility for converting Jupyter notebooks into reStructuredText cells and splitting them into smaller snippets.
What is JupyterCell?
JupyterCell is an open-source tool designed to simplify the process of embedding Jupyter Notebook cells into Sphinx websites. With JupyterCell, you can convert your entire notebook into reStructuredText (rST) and automatically split the converted content into smaller, manageable snippets-each containing code cells and their outputs.
This project is built for educators, researchers, and developers who need a more flexible way to include specific code snippets from notebooks in their documentation projects. JupyterCell handles the tedious work of converting and splitting, so you can focus on creating insightful content for your audience.
Getting Started
Prerequisites
Python 3.11+
Jupyter Notebook or Jupyter Lab
Sphinx (for rST-based documentation)
Optional: virtual environment (recommended)
To get started with JupyterCell, you’ll need to have Python and the required dependencies installed. Here’s how you can set things up:
Installation
python3 -m venv env
source env/bin/activate # On Windows, use `env\Scripts\activate`
Now, install the package directly from PyPI:
pip install jupyter-cell
Usage
You can use JupyterCell from the command line with the following syntax:
jupyter-cell --notebook path/to/notebook.ipynb [--prefix <prefix>] [--keep]
–notebook (-n) [Required]: The path to the Jupyter notebook you want to convert.
–prefix [Optional]: Prefix for the generated snippet files (Default: cell-).
–keep [Optional]: Whether to keep the full RST file after splitting into snippets (Default: False).
Example
Suppose you have a Jupyter Notebook called some_notebook.ipynb in your current directory. To convert and split it into smaller rST snippets, run the following command:
jupyter-cell --notebook some_notebook.ipynb --prefix snippet- --keep
This will produce:
A full some_notebook.rst file.
Several smaller files, each named snippet-1.rst, snippet-2.rst, etc., containing individual cells or cell/output pairs.
The –keep flag ensures that the original some_notebook.rst is preserved.
Contributions
Contributions and/or suggestions are welcome! If you find a bug, have a feature request, or want to contribute improvements, please open an issue or submit a pull request on GitHub.
License
JupyterCell is licensed under the MIT License. See the LICENSE file for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file jupyter_cell-2024.9.15.tar.gz
.
File metadata
- Download URL: jupyter_cell-2024.9.15.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90523f689c4b53a5c17de50637d4e8339f4c2af50a61efdc2ec8238aeaac1616 |
|
MD5 | 38892c3d098ba9eeb3cee91911bb8fcf |
|
BLAKE2b-256 | a28d5d18d6055ed06d500ddc6a4da37e72d436bb90de3afebbfca6c0b6267bdd |
File details
Details for the file jupyter_cell-2024.9.15-py3-none-any.whl
.
File metadata
- Download URL: jupyter_cell-2024.9.15-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3975a5ed9cc54f461715c840eb5d91bc10903059b6b2d7e247ebb078c7c6fa09 |
|
MD5 | 8c0f5dfdd24a1e53f0454c23bec2651c |
|
BLAKE2b-256 | d0d6f01186c82d3e6f9aa872fee404b814499b7470dab107be4f4f69e90f1968 |