schema: add Comment annotation (#3164)

* Add schema.CommentAnnotation (resolves #3155)

Adds new mechanism for customizing a model's godoc comment in code (via an Annotation).

* feedback
This commit is contained in:
Andy Day
2022-12-10 13:30:45 -08:00
committed by GitHub
parent dcc16c5763
commit 63c123f36c
4 changed files with 40 additions and 2 deletions

View File

@@ -22,3 +22,22 @@ type Annotation interface {
type Merger interface {
Merge(Annotation) Annotation
}
// CommentAnnotation is a builtin schema annotation for
// configuring the schema's Godoc comment.
type CommentAnnotation struct {
Text string // Comment text.
}
// Name implements the Annotation interface.
func (c *CommentAnnotation) Name() string {
return "Comment"
}
// Comment is a builtin schema annotation for
// configuring the schema's Godoc comment.
func Comment(text string) *CommentAnnotation {
return &CommentAnnotation{Text: text}
}
var _ Annotation = (*CommentAnnotation)(nil)