mirror of
https://github.com/ent/ent.git
synced 2026-03-05 19:35:23 +03:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user