cmd/viewer: add field comments to generated view methods
Extract field comments from AST and include them in generated view methods. Comments are preserved from the original struct fields to provide documentation for the view accessors. Fixes #16958 Signed-off-by: Maisem Ali <3953239+maisem@users.noreply.github.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
80f5a00e76
commit
882b05fff9
@@ -53,6 +53,7 @@ func TestViewerImports(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var fieldComments map[fieldNameKey]string // don't need it for this test.
|
||||
|
||||
var output bytes.Buffer
|
||||
tracker := codegen.NewImportTracker(pkg)
|
||||
@@ -65,7 +66,7 @@ func TestViewerImports(t *testing.T) {
|
||||
if !ok {
|
||||
t.Fatalf("%q is not a named type", tt.typeNames[i])
|
||||
}
|
||||
genView(&output, tracker, namedType, pkg)
|
||||
genView(&output, tracker, namedType, fieldComments)
|
||||
}
|
||||
|
||||
for _, pkg := range tt.wantImports {
|
||||
|
||||
Reference in New Issue
Block a user