stubgen

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 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 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) 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 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 LuaModule

type LuaModule struct {
	Name              string
	Functions         []*LuaFunction
	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