Repository navigation
fix(go): a constant in a const ( … ) group keeps its own doc comment - #2680
Merged
Merged
Conversation
Both extractors read every member's docstring from the comment above `const (`, which documents the group. A constant documented inside the group, like gin's ErrorTypeBind under "ErrorTypeBind is used when Context.Bind() fails.", stored no docstring, or the group's comment instead of its own. A member's own doc comment, read with Go's doc comment rules, is now its docstring. A member without one keeps the group's comment, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 19, 2026
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.
Follow-up to #2678 and #2679. A constant declared inside a
const ( … )group lost the doc comment written above it:gin's
ErrorTypeBindhad no docstring. Both extractors read every member's docstring from the comment aboveconst (, the group's, and never from the member's own comment. That is the comment go doc prints beside the member, and the one gopls shows on hover.Change
extractVariablein TS,extract_variablein the kernel), eachconst_spec's docstring is now its own doc comment, read with the Go rules from fix(go): a type declared on its own keeps its doc comment #2438/fix(go): a comment a blank line separates from a declaration is not its doc #2678/fix(go): a comment directive like //go:embed is not part of a declaration's doc #2679 (trailing comments, blank lines and directives).type ( … )group's comment off its members; that stays as it is.const X = 1has no comment inside its declaration, so it reads the declaration's doc as before.Verification
__tests__/go-grouped-const-docs.test.ts, kernel and wasm, each on LF and CRLF:const/var.torture.goparity fixture gains a const group with one documented member;kernel-tsjs-paritypasses 99/99. The Go doc tests from fix(go): a type declared on its own keeps its doc comment #2438, fix(go): a comment a blank line separates from a declaration is not its doc #2678 and fix(go): a comment directive like //go:embed is not part of a declaration's doc #2679 pass unchanged.CODEGRAPH_KERNEL_EXPECT=1(--maxWorkers=4 --minWorkers=1): 7,513 passed, 0 failed, 80 skipped (7,593 tests, 0 failed files).A/B on real repos
main f43432c vs this branch; etcd 6782f522, prometheus 0b57789d, gin 0f09c3a9.
Nodes, edges, unresolved refs and files are byte-identical on all three repos, on both the kernel and wasm paths. Only docstrings change, and the two paths change the same ones:
FloatChunkEncodingXOR("selects standard XOR encoding for float chunks"); prometheuslintErrExitCode; etcd's deprecatedauthpb.READ/WRITEaliases; and the generatedconst _ = protoimpl.EnforceVersion(…)guards ("Verify that this generated code is sufficiently up-to-date").kernel-parity.mjs --lang go): 0 diffs on all three repos. etcd 1065/1105, the same 40 erroring files deferred as on main; prometheus 746/746; gin 99/99.Notes
var ( … )block are not indexed at all. tree-sitter-go wraps a var group's specs in avar_spec_listnode, which neither extractor reads, so etcd, prometheus and gin index no grouped variable. That PR gives them their own docs the same way.🤖 Generated with Claude Code