Repository navigation
Conversation
Why:
Since #9144, "create interface" reindents copied declarations to their
nesting depth and keeps only lines inside string and template literals
verbatim. A multi-line doc comment is the string payload of @res.doc,
so shifting its lines changed the documentation: a fenced code block
became an indented one and relative indentation collapsed.
`literal_lines` now also marks the lines inside comments, doc comments and
regular block comments alike, so they are copied verbatim.
Format modified (created interface of a doc comment in a nested module):
Example:
module A = {
module B = {
/** Example:
```rescript
let v: t = 1
```
*/
type t = int
}
}
Before (rescript):
module A: {
module B: {
/** Example:
```rescript
let v: t = 1
```
*/
type t = int
}
}
After (rescript):
module A: {
module B: {
/** Example:
```rescript
let v: t = 1
```
*/
type t = int
}
}
Review: What about a comment whose last line continues with code, such as
`*/ field: int`? The whole line keeps its source indentation, as a line
ending a multi-line string literal already does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gGhHjzBTXqSo8Dckpb
Signed-off-by: Christoph Knittel <ck@cca.io>
0e1f4fc to
51278ec
Compare
ChangelogNo changelog entry. Semantic Diff1 commit · Full page Keep the lines inside comments verbatim in created interfaces51278ec · cknitt + Claude · Nov 03, 2026, 18:32 UTC
Format modified (created interface of a doc comment in a nested module) module A = {
module B = {
/** Example:
```rescript
let v: t = 1
```
*/
type t = int
}
}
module A: {
module B: {
/** Example:
- ```rescript
- let v: t = 1
- ```
- */
+```rescript
+let v: t = 1
+```
+*/
type t = int
}
}Review
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9202 +/- ##
=======================================
Coverage 81.73% 81.73%
=======================================
Files 458 458
Lines 65292 65292
=======================================
Hits 53364 53364
Misses 11928 11928
🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9202 |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Part of #9181 (first item). This fixes an unreleased regression from #9144, so it adds no changelog fragment; #9144's fragment covers the release note.
Since #9144, the editor's "create interface" command reindents the declarations it copies from the source to their nesting depth in the interface. It keeps the lines inside string and template literals verbatim, because reindenting them would change their value, but not the lines inside comments. A multi-line doc comment is the string payload of
@res.doc, so its continuation lines were shifted too: in a nested module, a fenced code block in a doc comment became an indented code block forrescript-tools doc, and relative indentation inside the comment collapsed.literal_linesinanalysis/src/create_interface.mlnow marks the lines inside comment tokens the same way as the lines inside literals, so the lines after the first line of a doc comment or block comment are copied verbatim. The scanner already returns comments as tokens, so quotes and backticks inside comments, nested block comments and/*inside//line comments are handled without further changes. As with a multi-line string, a line that ends a comment and continues with code keeps its source indentation.Tests
tests/analysis_tests/tests/src/CreateInterfaceComments.res: doc comments on types at the top level and two modules deep, on record fields and on an external, a starred doc comment, regular and nested block comments containing quotes and backticks, a//comment containing/*, and a module whose source is indented deeper than its place in the interface (lines outside comments are still reindented). Without the fix the comment lines in the nested modules are shifted.🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gGhHjzBTXqSo8Dckpb