Skip to content

Comments

fix(napi-derive): escape * in comments#3109

Merged
Brooooooklyn merged 1 commit intomainfrom
01-27-fix_napi-derive_escape_in_comments
Jan 27, 2026
Merged

fix(napi-derive): escape * in comments#3109
Brooooooklyn merged 1 commit intomainfrom
01-27-fix_napi-derive_escape_in_comments

Conversation

@Brooooooklyn
Copy link
Member

@Brooooooklyn Brooooooklyn commented Jan 27, 2026

Note

Ensures generated JSDoc never closes comment blocks prematurely when */ appears in source docs.

  • Update JSDoc formatter in typegen.rs to escape */ as *\/ for both single-line and multi-line outputs
  • Refresh examples/napi comments and snapshots to include a case like "*/json", verifying correct escaping in generated index.d.cts

Written by Cursor Bugbot for commit cb2fcc9. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

Bug Fixes

  • Fixed improper handling of special character sequences in generated documentation comments, ensuring comment blocks are no longer prematurely terminated by embedded characters.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings January 27, 2026 04:56
@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

The changes introduce a helper function to escape the */ sequence in JSDoc comments to prevent premature comment termination. The escaping is applied to both single-line and multi-line comment blocks during type generation, with test cases added to verify the behavior.

Changes

Cohort / File(s) Summary
Core JSDoc Escaping Logic
crates/backend/src/typegen.rs
Introduces escape_comment_close helper function to escape */ sequences. Applied to single-line JSDoc entries and all lines in multi-line comment blocks during formatting.
Test & Example Updates
examples/napi/__tests__/__snapshots__/values.spec.ts.md, examples/napi/index.d.cts, examples/napi/src/class.rs
Updated test snapshot, generated TypeScript declarations, and Rust documentation with test case demonstrating proper escaping of */ in comments.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A comment close no more breaks free,
With asterisk and slash we see,
Escape the */ with careful care,
Your JSDoc blocks now safe from snare!
The rabbit hops with joy today! 🐇

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(napi-derive): escape * in comments' accurately describes the main change: escaping the */ sequence in JSDoc comments to prevent premature comment termination.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • ready-to-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a bug where */ sequences in Rust doc comments would prematurely terminate JSDoc comment blocks in the generated TypeScript declaration files. The fix adds an escape function that converts */ to *\/ in all JSDoc output.

Changes:

  • Added escape_comment_close function to properly escape */ sequences in JSDoc comments
  • Updated example and test files to demonstrate the fix with a test case containing "*/json" in a comment

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/backend/src/typegen.rs Implements the escape_comment_close function and applies it to all JSDoc comment output (both single-line and multi-line formats)
examples/napi/src/class.rs Adds a test comment containing "*/json" to verify the fix
examples/napi/index.d.cts Shows the generated TypeScript with properly escaped "*\/json" comment
examples/napi/tests/snapshots/values.spec.ts.md Updates snapshot to reflect the properly escaped comment
examples/napi/tests/snapshots/values.spec.ts.snap Binary snapshot file update

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Brooooooklyn Brooooooklyn merged commit 8efc798 into main Jan 27, 2026
81 of 82 checks passed
@Brooooooklyn Brooooooklyn deleted the 01-27-fix_napi-derive_escape_in_comments branch January 27, 2026 05:14
@github-actions github-actions bot mentioned this pull request Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for // style comments

1 participant