Documentation ¶
Index ¶
Constants ¶
const (
DefaultAPIVersion = "0.0.1"
)
Variables ¶
var ( // DefaultBuilder is a builder that will build a prototype from a source string. DefaultBuilder = JsonnetParse )
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index interface { List() (Prototypes, error) SearchNames(query string, opts SearchOptions) (Prototypes, error) }
Index represents a queryable index of prototype specifications.
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.
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 Prototype ¶ added in v0.11.0
type Prototype 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"` }
Prototype is the JSON-serializable representation of a prototype specification.
func JsonnetParse ¶ added in v0.11.0
JsonnetParse parses a source Jsonnet document into a Prototype.
func Unmarshal ¶
Unmarshal takes the bytes of a JSON-encoded prototype specification, and de-serializes them to a `SpecificationSchema`.
func (*Prototype) OptionalParams ¶ added in v0.11.0
func (s *Prototype) OptionalParams() ParamSchemas
OptionalParams retrieves all parameters that can optionally be provided to a prototype.
func (*Prototype) RequiredParams ¶ added in v0.11.0
func (s *Prototype) RequiredParams() ParamSchemas
RequiredParams retrieves all parameters that are required by a prototype.
type Prototypes ¶ added in v0.11.0
type Prototypes []*Prototype
Prototypes is a slice of pointer to `SpecificationSchema`.
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 suffixes. 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 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`.