completion

package
v0.109.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2021 License: AGPL-3.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Completion

type Completion struct {
	Types         []Type      `json:"types"`
	Root          []*Property `json:"root"`
	RootNoSession []*Property `json:"root_no_session"`
}

Completion generates auto-complete paths

func NewCompletion

func NewCompletion(types []Type, root []*Property) *Completion

NewCompletion creates a new empty completion

func (*Completion) EnumerateNodes

func (c *Completion) EnumerateNodes(context *Context) []Node

EnumerateNodes walks the context to enumerate all possible nodes

func (*Completion) Validate

func (c *Completion) Validate() error

Validate checks that all type references are valid

type Context

type Context struct {
	KeySources map[string][]string
}

Context is the runtime information required to generate completions

func NewContext

func NewContext(keySources map[string][]string) *Context

NewContext creates a new completion context

type Node

type Node struct {
	Path string
	Help string
}

Node represents a part of the context that can be referenced

type Property

type Property struct {
	Key   string `json:"key"`
	Help  string `json:"help"`
	Type  string `json:"type"`
	Array bool   `json:"array,omitempty"`
}

Property is a field of a context type which can be accessed in the context with the dot operator

func NewArrayProperty

func NewArrayProperty(key, help string, typeRef string) *Property

NewArrayProperty creates a new array property

func NewProperty

func NewProperty(key, help string, typeRef string) *Property

NewProperty creates a new property

func ParseProperty

func ParseProperty(line string) *Property

ParseProperty parses a property from a docstring line

type Type

type Type interface {
	Name() string
	TypeRefs() []string
	EnumerateProperties(context *Context) []*Property
}

Type is a type that exists in the context

func NewDynamicType

func NewDynamicType(name, keySource string, propertyTemplate *Property) Type

NewDynamicType creates a new dynamic type, i.e. properties determined at runtime

func NewStaticType

func NewStaticType(name string, properties []*Property) Type

NewStaticType creates a new static type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL