 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Directive ¶
type Directive struct {
	AST *ast.CommentGroup // the comment group containing the directive
	Name    string  // "foo" in "encore:foo"
	Options []Field // options that are enabled ("public" and "raw" in "encore:api public raw path=/foo")
	Fields  []Field // key-value pairs ({"path": "/foo"} in "encore:api public raw path=/foo")
	Tags    []Field // tag names ("tag:foo" in "encore:api public tag:foo")
	// contains filtered or unexported fields
}
    Directive represents a parsed "encore:" directive.
func Parse ¶
Parse parses the encore:foo directives in cg. It returns the parsed directives, if any, and the remaining doc text after stripping the directive lines.
func (Directive) Get ¶
Get returns the value of the given field, if any. If the field doesn't exist it reports "".
func (Directive) GetList ¶
GetList returns the value of the given field, split by commas. If the field doesn't exist it reports nil.
type Field ¶
func (Field) Equal ¶
Equal reports whether two fields are equal. It's implemented for testing purposes.
type ValidateSpec ¶
type ValidateSpec struct {
	// AllowedFields and AllowedOptions are the allowed fields and options.
	// Expected values must be found in the corresponding list.
	AllowedOptions []string
	AllowedFields  []string
	// ValidateOption, if non-nil, is called for each option in the directive.
	ValidateOption func(*perr.List, Field) (ok bool)
	// ValidateField, if non-nil, is called for each field in the directive.
	ValidateField func(*perr.List, Field) (ok bool)
	// ValidateTag, if non-nil, is called for each tag in the directive.
	// It is called with the whole tag, including the "tag:" prefix.
	ValidateTag func(*perr.List, Field) (ok bool)
}
     Click to show internal directories. 
   Click to hide internal directories.