Add kernel_javascript support to write kernel.js during kernelspec install#378
Merged
blink1073 merged 2 commits intoCalysto:mainfrom Mar 15, 2026
Merged
Add kernel_javascript support to write kernel.js during kernelspec install#378blink1073 merged 2 commits intoCalysto:mainfrom
blink1073 merged 2 commits intoCalysto:mainfrom
Conversation
…stall Kernels can now set a `kernel_javascript` class attribute to have a kernel.js file written to the kernelspec directory at install time, enabling CodeMirror syntax highlighting and other notebook-editor customisations without requiring a separate packaging step.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #378 +/- ##
==========================================
+ Coverage 90.08% 90.84% +0.75%
==========================================
Files 51 51
Lines 2944 2948 +4
Branches 411 412 +1
==========================================
+ Hits 2652 2678 +26
+ Misses 214 190 -24
- Partials 78 80 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
References
Replaces and closes #194.
Description
Kernels can now set a
kernel_javascriptclass attribute. Whenpython -m my_kernel installruns, MetaKernel writes that string tokernel.jsalongsidekernel.jsonin the kernelspec directory, enabling CodeMirror syntax highlighting and other notebook-editor customisations without a separate packaging step.Changes
metakernel/_metakernel.py: instantiate the kernel class once inKernelInstallerApp.start(); if the instance has a non-emptykernel_javascriptattribute, write it tokernel.jsin the temporary kernelspec directory before callingjupyter kernelspec install.tests/test_metakernel_app.py: four new tests covering the happy path (file written, correct content), whitespace-only string (skipped), and absent attribute (skipped). Fixed three existing tests to setkernel_javascript = ""on their mock instances so the new branch does not interfere.docs/new_kernel.md: added a "Syntax highlighting (kernel.js)" section documenting the new attribute with a CodeMirrordefineSimpleModeexample.Backwards-incompatible changes
None
Testing
New and existing tests in
tests/test_metakernel_app.pyall pass (just test tests/test_metakernel_app.py).AI usage