Skip to content

Conversation

jxnl
Copy link
Contributor

@jxnl jxnl commented May 28, 2025

Summary

  • Added a notebook watcher script that monitors Jupyter notebooks and automatically converts them to markdown format
  • Helps with version control and documentation by maintaining markdown versions of notebooks

Changes

  • New watch_notebooks.py script: Monitors .ipynb files and converts on save
  • Updated convert.py: Added file command for single file conversion
  • Added dependencies: typer, watchdog, rich, nbformat for the watcher functionality
  • Updated README: Added documentation for the notebook watcher tool

Features

  • Automatically converts all existing notebooks on startup
  • Watches for changes and converts modified notebooks in real-time
  • Saves markdown files to md/ directory by default (configurable)
  • Beautiful console output with progress indicators using Rich
  • CLI interface with help and options using Typer

Usage

# Watch current directory
./watch_notebooks.py

# Watch specific directory
./watch_notebooks.py /path/to/notebooks

# Custom output directory  
./watch_notebooks.py -o /custom/output

🤖 Generated with Claude Code


Important

Adds a notebook watcher script to automatically convert Jupyter notebooks to markdown for improved version control and documentation.

  • New Features:
    • Adds watch_notebooks.py to monitor .ipynb files and convert them to markdown on save.
    • Automatically converts all existing notebooks on startup and watches for real-time changes.
    • Saves markdown files to md/ directory by default, configurable via CLI.
  • Updates to convert.py:
    • Adds file command to convert a single notebook to markdown.
  • Dependencies:
    • Adds typer, watchdog, rich, nbformat to pyproject.toml for watcher functionality.
  • Documentation:
    • Updates README.md with usage instructions for the notebook watcher tool.

This description was created by Ellipsis for d5c69aa. You can customize this summary. It will automatically update as commits are pushed.

- Add watch_notebooks.py script that monitors .ipynb files
- Automatically converts notebooks to markdown on save
- Outputs markdown files to md/ directory by default
- Uses typer for CLI interface and rich for pretty output
- Update convert.py to support single file conversion via CLI
- Add dependencies: typer, watchdog, rich, nbformat
- Update README with notebook watcher documentation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
text=True
)
if result.returncode == 0:
console.print(f"[green]✓[/green] Converted [blue]{notebook_path.name}[/blue] → [green]{output_path.relative_to(notebook_path.parent)}[/green]")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using relative_to(notebook_path.parent) may raise a ValueError if the output directory is not a subdirectory of the notebook's directory; consider displaying the output path more safely.

Suggested change
console.print(f"[green]✓[/green] Converted [blue]{notebook_path.name}[/blue] → [green]{output_path.relative_to(notebook_path.parent)}[/green]")
console.print(f"[green]✓[/green] Converted [blue]{notebook_path.name}[/blue] → [green]{output_path}[/green]")

if show_status:
with console.status(f"[cyan]Converting {notebook_path.name}...[/cyan]"):
try:
result = subprocess.run(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The subprocess call block is duplicated; consider refactoring to a helper function to DRY up the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant