stubgen

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analyzer

type Analyzer struct {
	// contains filtered or unexported fields
}

Analyzer: scans Go source files and extracts Lua module definitions

func NewAnalyzer

func NewAnalyzer() *Analyzer

NewAnalyzer: creates a new code analyzer instance

func (*Analyzer) GenerateModuleStub

func (a *Analyzer) GenerateModuleStub(moduleName string) (string, error)

GenerateModuleStub: generates a Lua annotation stub for a single module. This is the recommended format for per-module files in a library/ directory.

func (*Analyzer) GenerateStubs

func (a *Analyzer) GenerateStubs() (string, error)

GenerateStubs: generates Lua annotation stubs for all discovered modules

func (*Analyzer) GetModules

func (a *Analyzer) GetModules() map[string]*LuaModule

GetModules: returns a map of module names to module definitions

func (*Analyzer) ModuleCount

func (a *Analyzer) ModuleCount() int

ModuleCount: returns the number of modules discovered

func (*Analyzer) ScanDirectory

func (a *Analyzer) ScanDirectory(dir string) error

ScanDirectory: recursively scans a directory for Go files and extracts Lua module metadata. It parses comment annotations like @luamodule, @luafunc, @luaparam, @luareturn.

type GenerateConfig added in v0.0.2

type GenerateConfig struct {
	// ScanDir is the directory to scan for Go files with @luafunc annotations
	ScanDir string
	// OutputDir is the output directory for generated Lua files
	OutputDir string
	// ModuleName is the name of the module for Lua code generation
	ModuleName string
	// OutputFile is the name of the generated Lua file (e.g., "k8sclient.gen.lua")
	OutputFile string
	// Types is an optional list of types to register for stub generation
	Types []interface{}
}

GenerateConfig: configuration for stub generation

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator: combines function stub generation (from annotations) and type stub generation (from TypeRegistry). This provides a simple API for modules to generate complete Lua stubs.

func NewGenerator

func NewGenerator() *Generator

NewGenerator: creates a new Generator instance

func (*Generator) Generate added in v0.0.2

func (g *Generator) Generate(config GenerateConfig) (string, error)

Generate: generates Lua stubs for a module based on the provided configuration. This method orchestrates the entire stub generation process: 1. Scans the specified directory for annotated functions 2. Registers any provided types 3. Processes type dependencies 4. Generates combined stubs 5. Writes output to the specified file

Returns the path to the generated file or an error.

func (*Generator) GenerateModule

func (g *Generator) GenerateModule(moduleName string) (string, error)

GenerateModule: generates complete Lua stubs for a module (functions + types merged into one file). Returns the combined stub content or an error.

func (*Generator) ProcessTypes

func (g *Generator) ProcessTypes() error

ProcessTypes: processes all registered types to discover dependencies

func (*Generator) RegisterType

func (g *Generator) RegisterType(obj interface{}) error

RegisterType: registers a Go type for Lua stub generation

func (*Generator) ScanDirectory

func (g *Generator) ScanDirectory(dir string) error

ScanDirectory: scans a directory for Go files with @luafunc annotations

type LuaClass added in v0.0.2

type LuaClass struct {
	Name              string
	Description       string
	Methods           []*LuaMethod
	Fields            []*LuaField
	CustomAnnotations []string
}

LuaClass: represents a Lua class (UserData type with methods)

type LuaConst added in v0.0.2

type LuaConst struct {
	Name        string
	Type        string
	Description string
}

LuaConst: represents a constant exported by a module

type LuaField added in v0.0.2

type LuaField struct {
	Name        string
	Type        string
	Description string
}

LuaField: represents a field in a Lua class

type LuaFunction

type LuaFunction struct {
	Name              string
	Description       string
	Params            []*LuaParam
	Returns           []*LuaReturn
	CustomAnnotations []string // Function-level custom annotations
}

LuaFunction: represents a Lua function exported by a module

type LuaMethod added in v0.0.2

type LuaMethod struct {
	Name              string
	Description       string
	Params            []*LuaParam
	Returns           []*LuaReturn
	CustomAnnotations []string
}

LuaMethod: represents a method on a Lua class

type LuaModule

type LuaModule struct {
	Name              string
	Functions         []*LuaFunction
	Classes           []*LuaClass
	Constants         []*LuaConst
	CustomAnnotations []string // Module-level custom annotations
}

LuaModule: represents a discovered Lua module

type LuaParam

type LuaParam struct {
	Name        string
	Type        string
	Description string
}

LuaParam: represents a function parameter

type LuaReturn

type LuaReturn struct {
	Type        string
	Description string
}

LuaReturn: represents a function return value

Jump to

Keyboard shortcuts

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