Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FieldInfo ¶
type FieldInfo struct {
Name string // The field name (from JSON tag)
TypeKey string // The Lua type annotation (e.g., "string", "number", "corev1.Container")
IsArray bool // Whether this field is an array
}
FieldInfo: stores information about a struct field for Lua stub generation
type Translator ¶
type Translator struct{}
Translator: handles conversion between Go values and Lua values
func NewTranslator ¶
func NewTranslator() *Translator
NewTranslator: creates a new Translator instance
func (*Translator) FromLua ¶
FromLua: converts a Lua value to a Go value. Works similar to json.Unmarshal - pass a state, Lua value and output object. The conversion process:
- Create Go value from Lua value (map[string]interface{} for tables, primitives for others)
- Marshal the value to JSON
- Unmarshal JSON into output object
type TypeInfo ¶
type TypeInfo struct {
Name string // The Lua-friendly type name (e.g., "corev1.Pod")
GoType reflect.Type // The original Go type
Fields map[string]*FieldInfo // Map of field name to field information
IsArray bool // Whether this is an array type
ElementKey string // For arrays, the type key of the element
}
TypeInfo: stores information about a registered Go type for Lua stub generation
type TypeRegistry ¶
type TypeRegistry struct {
// contains filtered or unexported fields
}
TypeRegistry: manages type registration and stub generation for Lua. It processes Go types recursively and generates Lua LSP annotations.
func NewTypeRegistry ¶
func NewTypeRegistry() *TypeRegistry
NewTypeRegistry: creates a new TypeRegistry instance
func (*TypeRegistry) GenerateStubs ¶
func (r *TypeRegistry) GenerateStubs() (string, error)
GenerateStubs: generates Lua annotation stubs for all registered types. Returns a string containing ---@class and ---@field annotations.
Example output:
---@class corev1.Pod ---@field metadata corev1.ObjectMeta ---@field spec corev1.PodSpec
func (*TypeRegistry) Process ¶
func (r *TypeRegistry) Process() error
Process: processes all registered types and discovers dependencies. Call this after registering all root types with Register().
func (*TypeRegistry) Register ¶
func (r *TypeRegistry) Register(obj interface{}) error
Register: adds a Go type to the registry for stub generation. The object is queued for processing to discover all dependent types. Returns an error if the object is nil or not a valid type.