Notebook Documentation Generator for VS Code
A Visual Studio Code extension that generates comprehensive documentation from Jupyter notebooks using AI-powered analysis. This extension integrates with the Python-based notebook documentation generator to create both Markdown and PDF documentation from your notebooks.
Features
- Active Notebook Documentation: Generate documentation for the currently open notebook
- Right-Click Context Menu: Generate documentation for any
.ipynb file in the explorer
- Folder-Wide Generation: Process all notebooks in a selected folder
- Progress Notifications: Real-time feedback on documentation generation progress
- Output Panel Logging: Detailed logs for debugging and monitoring
- Cross-Platform Support: Works on Windows, macOS, and Linux
- Automatic Output Folder: Creates and opens the output directory with generated files
Requirements
System Dependencies
The extension requires Python and several system-level dependencies for PDF generation:
Windows
- Python 3.7+ with pip
- GTK3 for WeasyPrint: Download from GTK3 Windows
- Visual C++ Build Tools (if not already installed)
macOS
Linux (Ubuntu/Debian)
Python Dependencies
The extension will automatically check for and prompt installation of required Python packages:
openai
nbconvert
nbformat
markdown
weasyprint
pypandoc
Installation
1. Install the Extension
- Open VS Code
- Press
Ctrl+P (or Cmd+P on macOS)
- Type
ext install notebook-documentation-generator (or install from VSIX if provided)
- Click Install
2. Install Python Dependencies
The extension will automatically detect missing Python packages and prompt you to install them. Alternatively, you can install them manually:
pip install openai nbconvert nbformat markdown weasyprint pypandoc
Set your OpenAI API key in one of these ways:
Environment Variable (Recommended):
# Windows
set OPENAI_API_KEY=your-api-key-here
# macOS/Linux
export OPENAI_API_KEY=your-api-key-here
VS Code Settings:
- Open VS Code Settings (
Ctrl+,)
- Search for
Notebook Doc Assistant
- Enter your API key in the settings
Usage
Generate Documentation for Active Notebook
- Open a Jupyter notebook (
.ipynb file) in VS Code
- Open Command Palette (
Ctrl+Shift+P)
- Type and select:
Generate Documentation for Notebook
- Wait for the process to complete
- The output folder will automatically open with your generated documentation
Generate Documentation for Specific Notebook
- Right-click on any
.ipynb file in the VS Code Explorer
- Select
Generate Notebook Documentation
- Wait for the process to complete
- The output folder will open with your generated documentation
Generate Documentation for All Notebooks in Folder
- Right-click on any folder in the VS Code Explorer
- Select
Generate Documentation for Folder
- The extension will process all
.ipynb files in the folder
- Individual documentation files will be created for each notebook
Commands
The extension provides the following commands in the Command Palette:
Notebook Documentation Generator: Generate Documentation for Notebook - Active notebook
Notebook Documentation Generator: Generate Documentation for Folder - Selected folder
Configuration
The extension supports the following VS Code settings:
notebookDocGenerator.openaiApiKey - Your OpenAI API key (alternative to environment variable)
notebookDocGenerator.model - AI model to use (default: gpt-4)
notebookDocGenerator.language - Documentation language (default: english)
notebookDocGenerator.generatePdf - Generate PDF in addition to Markdown (default: true)
notebookDocGenerator.pythonPath - Custom Python executable path (auto-detected by default)
notebookDocGenerator.apiBaseUrl - Custom API base URL for local models
Output
Generated documentation includes:
- Markdown files (
.md) - Human-readable documentation
- PDF files (
.pdf) - Formatted documentation for sharing
- Output location:
output/ folder in your workspace (configurable)
Each notebook generates:
{notebook_name}.md - Markdown documentation
{notebook_name}.pdf - PDF documentation
Troubleshooting
Common Issues
"Python not found" Error
- Ensure Python 3.7+ is installed and in your system PATH
- Check Python installation:
python --version or python3 --version
- Set custom Python path in VS Code settings if needed
"Module not found" Error
- Install missing Python packages:
pip install -r requirements.txt
- The extension will prompt to install missing dependencies automatically
PDF Generation Fails
- Ensure system dependencies are installed (see Requirements section)
- Check WeasyPrint installation:
python -c "import weasyprint"
- On Windows, ensure GTK3 is properly installed
OpenAI API Key Issues
- Verify your API key is valid and has sufficient credits
- Check environment variable is set correctly:
echo $OPENAI_API_KEY
- Try setting the API key in VS Code settings instead
Extension Not Working
- Check VS Code Output panel for detailed logs
- Verify all dependencies are installed
- Restart VS Code after installing dependencies
- Check Python path in extension settings
Getting Help
- Check Output Panel: View detailed logs in VS Code Output panel
- Check Requirements: Ensure all system and Python dependencies are installed
- Restart VS Code: Sometimes needed after installing dependencies
- Manual Testing: Try running the Python CLI directly:
python -m core path/to/notebook.ipynb output/
Development
Building the Extension
cd vscode-extension
npm install
npm run compile
Packaging the Extension
npm install -g vsce
vsce package
Testing
- Open the extension folder in VS Code
- Press
F5 to launch Extension Development Host
- Test the extension functionality
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
License
This extension is part of the notebook documentation generator project. See the main project LICENSE file for details.
Support
For issues and feature requests, please use the GitHub issue tracker. Include:
- VS Code version
- Extension version
- Operating system
- Error messages from Output panel
- Steps to reproduce the issue