mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-21 00:38:18 +08:00
fix(go): a constant in a const ( … ) group keeps its own doc comment (#2680)
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>
This commit is contained in:
@@ -697,11 +697,15 @@ impl<'t> Walker<'t> {
|
||||
None
|
||||
};
|
||||
let signature = value_node.map(|v| util::init_signature(self.text(v)));
|
||||
// A member of a `const ( … )` group has its own doc
|
||||
// comment beside it in the parentheses; one without keeps
|
||||
// the group's.
|
||||
let doc = self.docstring_of(spec).or_else(|| docstring.clone());
|
||||
var_row = self.create_node(
|
||||
if is_const_decl { "constant" } else { "variable" },
|
||||
&name,
|
||||
spec,
|
||||
Extra { docstring: docstring.clone(), signature, ..Extra::default() },
|
||||
Extra { docstring: doc, signature, ..Extra::default() },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user