Skip to content

Add kernel_javascript support to write kernel.js during kernelspec install#378

Merged
blink1073 merged 2 commits intoCalysto:mainfrom
blink1073:finish-194
Mar 15, 2026
Merged

Add kernel_javascript support to write kernel.js during kernelspec install#378
blink1073 merged 2 commits intoCalysto:mainfrom
blink1073:finish-194

Conversation

@blink1073
Copy link
Copy Markdown
Contributor

References

Replaces and closes #194.

Description

Kernels can now set a kernel_javascript class attribute. When python -m my_kernel install runs, MetaKernel writes that string to kernel.js alongside kernel.json in 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 in KernelInstallerApp.start(); if the instance has a non-empty kernel_javascript attribute, write it to kernel.js in the temporary kernelspec directory before calling jupyter 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 set kernel_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 CodeMirror defineSimpleMode example.

Backwards-incompatible changes

None

Testing

New and existing tests in tests/test_metakernel_app.py all pass (just test tests/test_metakernel_app.py).

AI usage

  • Some or all of the content of this PR was generated by AI.
  • The human author has carefully reviewed this PR and run this code.
  • AI tools and models used: Claude Sonnet 4.6 (Claude Code)

…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.
@blink1073 blink1073 enabled auto-merge (squash) March 15, 2026 02:09
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.84%. Comparing base (f9f5e94) to head (e0eb166).
⚠️ Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@blink1073 blink1073 disabled auto-merge March 15, 2026 02:20
@blink1073 blink1073 merged commit d9eb38e into Calysto:main Mar 15, 2026
25 checks passed
@blink1073 blink1073 deleted the finish-194 branch March 15, 2026 02:23
@blink1073 blink1073 mentioned this pull request Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant