script-to-ipynb

Convert Python scripts into runnable Jupyter notebooks with markdown cells.

Updated Mar 1, 2023
One-click install
npx skills add https://github.com/luk036/sphere-n --skill script-to-ipynb
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: script-to-ipynb
Source: https://github.com/luk036/sphere-n/tree/main/.opencode/skills/script-to-ipynb
Command: npx skills add https://github.com/luk036/sphere-n --skill script-to-ipynb

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Converts Python scripts into fully interactive Jupyter notebooks by automatically converting code into executable cells, extracting docstrings and comments into markdown, and preserving the original structure for easy exploration and documentation.

Core Features & Use Cases

  • Cell Detection: Identifies imports, functions, classes, and main execution order to structure the notebook.
  • Docstring & Comment Conversion: Converts module and function docstrings to markdown cells for readability.
  • Executable Code Cells: Preserves code blocks as runnable cells in the notebook.
  • Output JSON: Generates properly formatted .ipynb files ready to run.

Quick Start

Provide the path to a Python script and an optional notebook title to generate a .ipynb file.

Frequently Asked Questions about script-to-ipynb

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert a Python script to a Jupyter notebook?

To convert a Python script to a Jupyter notebook, this tool parses your file and transforms functions, classes, imports, and docstrings into executable code cells and markdown. It automatically generates a properly formatted .ipynb file ready for interactive exploration.

Can I turn Python docstrings into markdown cells in an ipynb file?

Yes, you can turn Python docstrings into markdown cells. The conversion process extracts module and function docstrings from your script and converts them into readable markdown cells within the generated Jupyter notebook, preserving the original documentation structure.

What is the best way to document analysis workflows using Jupyter notebooks?

The best way to document analysis workflows is transforming your Python scripts into interactive notebooks. This approach converts existing code blocks into runnable cells and comments into markdown, allowing you to share and explore executable documentation seamlessly.

Does converting Python scripts to notebooks preserve the original code execution order?

Yes, converting Python scripts to notebooks preserves the original code execution order. The tool detects imports, functions, and main execution blocks to structure the notebook accurately, ensuring the runnable code cells maintain the script's logical flow.

What are the limitations of converting complex Python files to interactive notebooks?

A limitation of converting complex Python files to interactive notebooks is that the parser relies on identifying standard code structures. Scripts with highly unconventional formatting or dynamic execution paths may not translate perfectly into cleanly separated markdown and code cells.

Do I need any extra dependencies to generate a valid .ipynb file from my code?

No, you do not need extra dependencies to generate a valid .ipynb file from your code. The tool operates independently to output properly formatted Jupyter notebook files, requiring only the path to your Python script and an optional notebook title.