Skip to main content

A core library to synchronize Jupyter notebooks and Markdown documents, enabling seamless integration and dynamic content execution

Project description

nbsync

PyPI Version Python Version Build Status Coverage Status

Connect Jupyter notebooks and Markdown documents

nbsync is a core library that seamlessly bridges Jupyter notebooks and Markdown documents, enabling dynamic content synchronization and execution.

Why Use nbsync?

The Documentation Challenge

Data scientists, researchers, and technical writers face a common dilemma:

  • Development happens in notebooks - ideal for experimentation and visualization
  • Documentation lives in markdown - perfect for narrative and explanation
  • Connecting the two is painful - screenshots break, exports get outdated

Our Solution

nbsync creates a live bridge between your notebooks and markdown documents by:

  • Keeping environments separate - work in the tool best suited for each task
  • Maintaining connections - reference specific figures from notebooks
  • Automating updates - changes to notebooks reflect in documentation

Key Benefits

  • True Separation of Concerns: Develop visualizations in Jupyter notebooks and write documentation in markdown files, with each tool optimized for its purpose.

  • Intuitive Markdown Syntax: Use standard image syntax with a simple extension to reference notebook figures: ![alt text](notebook.ipynb){#figure-id}

  • Automatic Updates: When you modify your notebooks, your documentation updates automatically.

  • Clean Source Documents: Your markdown remains readable and focused on content, without code distractions or complex embedding techniques.

  • Enhanced Development Experience: Take advantage of IDE features like code completion and syntax highlighting in the appropriate environment.

Quick Start

1. Installation

pip install nbsync

2. Basic Usage

from nbsync.sync import Synchronizer
from nbstore import Store

# Initialize with a notebook store
store = Store("path/to/notebooks")
sync = Synchronizer(store)

# Process markdown with notebook references
markdown_text = """
# My Document

![Chart description](my-notebook.ipynb){#my-figure}
"""

# Convert markdown with notebook references to final output
for element in sync.convert(markdown_text):
    # Process each element (string or Cell objects)
    print(element)

3. Mark Figures in Your Notebook

In your Jupyter notebook, identify figures with a comment:

# #my-figure
import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize=(8, 4))
ax.plot([1, 2, 3, 4], [10, 20, 25, 30])

4. Reference in Markdown

Use standard Markdown image syntax with the figure identifier:

![Chart description](my-notebook.ipynb){#my-figure}

Control how results render

You can control how executed outputs render using attributes:

  • source: where to place the source relative to the result. Supported values include on/1 (above), below, only, material-block, tabbed-left, tabbed-right. See tests for details.
  • result: wrap the execution result in a fenced code block using the given language (similar to mkdocs-exec). For example:
```python exec="1" result="text"
print(2)
```

The Power of Separation

Creating documentation and developing visualizations involve different workflows and timeframes. When building visualizations in Jupyter notebooks, you need rapid cycles of execution, verification, and modification.

nbsync is designed specifically to address these separation of concerns, allowing you to:

  • Focus on code in notebooks without documentation distractions
  • Focus on narrative in markdown without code interruptions
  • Maintain powerful connections between both environments

Each environment is optimized for its purpose, while nbsync handles the integration automatically.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

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

nbsync-0.4.4.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nbsync-0.4.4-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file nbsync-0.4.4.tar.gz.

File metadata

  • Download URL: nbsync-0.4.4.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nbsync-0.4.4.tar.gz
Algorithm Hash digest
SHA256 b8f940241f300acc027476a85f97076a8a1d56e3fe10485bf37d5f8fd94d7a34
MD5 a3c7865825fa609d2eac363810fe85ca
BLAKE2b-256 2c51d07edcb8f7d9067a6a4a41390231f4905c280146256ae2b2f9d1e49565a0

See more details on using hashes here.

File details

Details for the file nbsync-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: nbsync-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nbsync-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d7ed904376d3cb56e88c8dfe3d3d6791e670a9ad32ecf44aa00240de6c2519ff
MD5 1571ab6e07fda178ab9a62dfdcea80f8
BLAKE2b-256 62deb81462363bd37b75e0b9ccaa7e23ea4f4f28a6eddabb2d5d0f6698cf6f50

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