Documentation ¶
Index ¶
Constants ¶
const (
DefaultAPIVersion = "0.0.1"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index interface { List() (SpecificationSchemas, error) SearchNames(query string, opts SearchOptions) (SpecificationSchemas, error) }
Index represents a queryable index of prototype specifications.
func NewIndex ¶
func NewIndex(prototypes []*SpecificationSchema) Index
NewIndex constructs an index of prototype specifications from a list.
type ParamSchema ¶
type ParamSchema struct { Name string `json:"name"` Alias *string `json:"alias"` // Optional. Description string `json:"description"` Default *string `json:"default"` // `nil` only if the parameter is optional. Type ParamType `json:"type"` }
ParamSchema is the JSON-serializable representation of a parameter provided to a prototype.
func OptionalParam ¶
func OptionalParam(name, alias, description, defaultVal string, t ParamType) *ParamSchema
OptionalParam constructs an optional parameter, i.e., a parameter that is meant to be optionally provided to some prototype, somewhere.
func RequiredParam ¶
func RequiredParam(name, alias, description string, t ParamType) *ParamSchema
RequiredParam constructs a required parameter, i.e., a parameter that is meant to be required by some prototype, somewhere.
type ParamSchemas ¶
type ParamSchemas []*ParamSchema
ParamSchemas is a slice of `ParamSchema`
func (ParamSchemas) PrettyString ¶
func (ps ParamSchemas) PrettyString(prefix string) string
PrettyString creates a prettified string representing a collection of parameters.
type ParamType ¶
type ParamType string
ParamType represents a type constraint for a prototype parameter (e.g., it must be a number).
const ( // Number represents a prototype parameter that must be a number. Number ParamType = "number" // String represents a prototype parameter that must be a string. String ParamType = "string" // NumberOrString represents a prototype parameter that must be either a // number or a string. NumberOrString ParamType = "numberOrString" // Object represents a prototype parameter that must be an object. Object ParamType = "object" // Array represents a prototype parameter that must be a array. Array ParamType = "array" )
type SearchOptions ¶
type SearchOptions int
SearchOptions represents the type of prototype search to execute on an `Index`.
const ( // Prefix represents a search over prototype name prefixes. Prefix SearchOptions = iota // Suffix represents a search over prototype name suffices. Suffix // Substring represents a search over substrings of prototype names. Substring )
type SnippetSchema ¶
type SnippetSchema struct { Prefix string `json:"prefix"` // Description describes what the prototype does. Description string `json:"description"` // ShortDescription briefly describes what the prototype does. ShortDescription string `json:"shortDescription"` // Various body types of the prototype. Follows the TextMate snippets syntax, // with several features disallowed. At least one of these is required to be // filled out. JSONBody []string `json:"jsonBody"` YAMLBody []string `json:"yamlBody"` JsonnetBody []string `json:"jsonnetBody"` }
SnippetSchema is the JSON-serializable representation of the TextMate snippet specification, as implemented by the Language Server Protocol.
func (*SnippetSchema) AvailableTemplates ¶
func (schema *SnippetSchema) AvailableTemplates() (ts []TemplateType)
AvailableTemplates returns the list of available `TemplateType`s this prototype implements.
func (*SnippetSchema) Body ¶
func (schema *SnippetSchema) Body(t TemplateType) (template []string, err error)
Body attempts to retrieve the template body associated with some type `t`.
type SpecificationSchema ¶
type SpecificationSchema struct { APIVersion string `json:"apiVersion"` Kind string `json:"kind"` // Unique identifier of the mixin library. The most reliable way to make a // name unique is to embed a domain you own into the name, as is commonly done // in the Java community. Name string `json:"name"` Params ParamSchemas `json:"params"` Template SnippetSchema `json:"template"` }
SpecificationSchema is the JSON-serializable representation of a prototype specification.
func FromJsonnet ¶
func FromJsonnet(data string) (*SpecificationSchema, error)
func Unmarshal ¶
func Unmarshal(bytes []byte) (*SpecificationSchema, error)
Unmarshal takes the bytes of a JSON-encoded prototype specification, and deserializes them to a `SpecificationSchema`.
func (*SpecificationSchema) OptionalParams ¶
func (s *SpecificationSchema) OptionalParams() ParamSchemas
OptionalParams retrieves all parameters that can optionally be provided to a prototype.
func (*SpecificationSchema) RequiredParams ¶
func (s *SpecificationSchema) RequiredParams() ParamSchemas
RequiredParams retrieves all parameters that are required by a prototype.
type SpecificationSchemas ¶
type SpecificationSchemas []*SpecificationSchema
SpecificationSchemas is a slice of pointer to `SpecificationSchema`.
func (SpecificationSchemas) String ¶
func (ss SpecificationSchemas) String() string
type TemplateType ¶
type TemplateType string
TemplateType represents the possible type of a prototype.
const ( // YAML represents a prototype written in YAML. YAML TemplateType = "yaml" // JSON represents a prototype written in JSON. JSON TemplateType = "json" // Jsonnet represents a prototype written in Jsonnet. Jsonnet TemplateType = "jsonnet" )
func ParseTemplateType ¶
func ParseTemplateType(t string) (TemplateType, error)
ParseTemplateType attempts to parse a string as a `TemplateType`.