Skip to content

Extend support for doc comments#206

Merged
jupblb merged 6 commits intomainfrom
michal/more-docs
Apr 15, 2026
Merged

Extend support for doc comments#206
jupblb merged 6 commits intomainfrom
michal/more-docs

Conversation

@jupblb
Copy link
Copy Markdown
Member

@jupblb jupblb commented Apr 15, 2026

No description provided.

jupblb added 6 commits April 15, 2026 12:14
Add test input files and baseline snapshot output covering all four
categories of missing documentation from issue #108:

- Constants/variables in grouped declarations (get block doc instead of per-item doc)
- Struct field doc comments (lost entirely due to nil parent)
- Interface method doc comments (lost due to self-referencing parent)
- Types in grouped type declarations (get block doc instead of per-type doc)
Pass the *ast.ValueSpec as parent instead of *ast.GenDecl when registering
const/var names. This makes extractHoverText consult ValueSpec.Doc (the
per-item doc comment) instead of GenDecl.Doc (the block-level doc).

Items without their own doc comment now correctly get no documentation
rather than inheriting the unrelated block-level comment.

Fixes the const/var portion of #108.
Pass the *ast.Field as parent instead of nil when registering named
struct field symbols in both visitor_type.go and visitor_var.go.
This allows extractHoverText to reach the Field.Doc and Field.Comment
nodes that carry doc and inline comments.

Fixes the struct field portion of #108.
Pass the *ast.Field as parent instead of the method's *ast.Ident when
registering interface method symbols. Previously the Ident was passed
as both parent and node, causing a self-referencing delegation in
extractHoverText that always returned empty string.

Fixes the interface method portion of #108.
When an *ast.Ident delegates to a *ast.GenDecl parent in extractHoverText,
first check if the ident belongs to a TypeSpec within that GenDecl and
route through the TypeSpec case instead. This lets TypeSpec.Doc (the
per-type doc comment) take priority, with fallback to GenDecl.Doc (the
block-level doc) when no per-type doc exists.

Fixes the grouped type portion of #108.
When a symbol lives inside a grouped declaration (const/var/type block)
that has its own doc comment, append the block-level doc as a second
entry in Documentation. SCIP's Documentation is a repeated string field,
and Sourcegraph's hover tooltip renders all entries.

This gives richer hover info: the per-item doc first, then the group
context. Items whose only doc is the block-level fallback get it once
without duplication.
@jupblb jupblb force-pushed the michal/more-docs branch from 359652a to 31cb8da Compare April 15, 2026 10:32
@jupblb jupblb marked this pull request as ready for review April 15, 2026 10:41
@jupblb jupblb merged commit 677b8de into main Apr 15, 2026
5 checks passed
@jupblb jupblb deleted the michal/more-docs branch April 15, 2026 10:41
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.

1 participant