Multiple Kernel Support¶
MkDocs-Jupyter supports notebooks written in multiple programming languages through different Jupyter kernels. This allows you to create documentation that includes examples in Python, R, Julia, Ruby, and many other languages.
Supported Kernels¶
While Python is the default kernel, you can use any kernel that's installed in your Jupyter environment:
- Python 3 - Default kernel for data science and general programming
- R (IRkernel) - Statistical computing and data analysis
- Julia (IJulia) - High-performance scientific computing
- Ruby (IRuby) - Web development and scripting
- JavaScript (IJavascript) - Frontend development examples
- Bash - System administration and DevOps
- SQL - Database queries and examples
- And many more...
Configuration¶
The MkDocs configuration already supports multiple kernels:
plugins:
- mkdocs-jupyter:
kernel_name: python3 # Default kernel
execute: true # Execute all notebooks
allow_errors: true # Continue even if execution fails
Individual notebooks can specify their own kernel in the notebook metadata.
Installing Additional Kernels¶
R Kernel (IRkernel)¶
Julia Kernel (IJulia)¶
Ruby Kernel (IRuby)¶
JavaScript Kernel¶
Creating Multi-Language Documentation¶
You can create comprehensive documentation that shows the same concept in multiple languages:
- Algorithm Implementation - Show the same algorithm in Python, Julia, and C++
- Data Analysis - Compare approaches in Python, R, and Julia
- Web API Clients - Examples in Python, Ruby, JavaScript, and Go
- System Scripts - Bash, Python, and PowerShell examples
Example Notebooks¶
We've created example notebooks for different kernels:
- Python Kernel Example - Data science with Python
- R Kernel Example - Statistical analysis with R
- Julia Kernel Example - Scientific computing with Julia
- Ruby Kernel Example - Scripting with Ruby
Kernel-Specific Features¶
Python¶
- Rich ecosystem of data science libraries
- Excellent visualization tools
- Machine learning frameworks
- Web development capabilities
R¶
- Statistical analysis functions
- Advanced plotting capabilities
- Bioinformatics packages
- Time series analysis
Julia¶
- High-performance computing
- Mathematical optimization
- Parallel processing
- Scientific simulations
Ruby¶
- Web development (Rails)
- Scripting and automation
- Metaprogramming
- DSL creation
Best Practices¶
1. Specify Kernel Explicitly¶
Always specify the kernel in your notebook metadata:
2. Handle Missing Kernels Gracefully¶
Use allow_errors: true
in your MkDocs configuration to prevent build failures if a kernel isn't available:
3. Document Requirements¶
For each notebook, document the kernel installation requirements:
## Requirements
This notebook requires the R kernel. Install it with:
\`\`\`bash
R -e "install.packages('IRkernel'); IRkernel::installspec()"
\`\`\`
4. Use Language-Specific Features¶
Take advantage of each language's strengths:
- Python: Use type hints and docstrings
- R: Leverage vectorized operations
- Julia: Utilize multiple dispatch
- Ruby: Employ blocks and metaprogramming
Troubleshooting¶
Kernel Not Found¶
If a notebook fails with "kernel not found":
- Check available kernels:
jupyter kernelspec list
- Install the missing kernel
- Restart the MkDocs build
Execution Errors¶
For notebooks that may fail in CI/CD:
- Add to
execute_ignore
list - Set
allow_errors: true
- Pre-execute notebooks and commit outputs
Performance Issues¶
For slow-executing notebooks:
- Consider pre-executing and saving outputs
- Use
execute: false
for specific notebooks - Implement caching mechanisms
Advanced Usage¶
Multi-Kernel Workflows¶
Create notebooks that demonstrate interoperability:
- Data preparation in Python
- Statistical analysis in R
- Performance optimization in Julia
- Web API in Ruby
Kernel Comparison¶
Create side-by-side comparisons:
# R
fibonacci <- function(n) {
a <- 0
b <- 1
for (i in 1:n) {
temp <- b
b <- a + b
a <- temp
}
return(a)
}
Conclusion¶
Multiple kernel support in MkDocs-Jupyter enables you to create rich, multi-language documentation that serves diverse audiences and use cases. Whether you're documenting a polyglot project, comparing language features, or teaching programming concepts, multiple kernels provide the flexibility you need.