Documentation
¶
Index ¶
- Variables
- func CleanRuntime(src string) string
- func CollectGoDeps(moduleNames []string) []string
- func CollectGoReplace(moduleNames []string) []string
- func IsModule(name string) bool
- func LookupFunc(module, funcName string) (string, bool)
- func Names() []string
- func Register(m *Module)
- type ArgType
- type FuncDef
- type Module
Constants ¶
This section is empty.
Variables ¶
var Sources embed.FS
Sources embeds module.go and all module subdirectory source files needed to reconstruct the modules package tree in an external module cache. Test files are excluded.
Functions ¶
func CleanRuntime ¶
CleanRuntime strips //go:build directives, the package declaration, and import blocks from Go source so it can be emitted into a generated program.
func CollectGoDeps ¶
CollectGoDeps returns all GoDeps from the named modules (deduped, sorted).
func CollectGoReplace ¶ added in v0.15.0
CollectGoReplace returns all GoReplace directives from the named modules (deduped).
func LookupFunc ¶
LookupFunc resolves a module function to its Go runtime wrapper name.
Types ¶
type FuncDef ¶
type FuncDef struct {
// Name is the rugo function name (e.g. "exec").
Name string
// Args lists the expected typed arguments. The wrapper will convert
// interface{} args to these types before calling the implementation.
Args []ArgType
// ArgNames provides display names for arguments in documentation.
// When empty, generic names (arg0, arg1, ...) are used.
ArgNames []string
// Variadic, when true, passes remaining args beyond Args as ...interface{}.
// The implementation function should accept extra ...interface{} as its last parameter.
Variadic bool
// Doc is the documentation string shown by `rugo doc`.
Doc string
}
FuncDef describes a function exposed by a module. The implementation function must be named <module>_<Name> in runtime.go and use typed parameters matching Args (e.g. func os_exec(command string) interface{}).
type Module ¶
type Module struct {
// Name is the rugo import name (e.g. "os", "http", "conv").
Name string
// Type is the Go struct type name used as the method receiver (e.g. "OS", "HTTP").
Type string
// Funcs describes the functions this module exposes.
Funcs []FuncDef
// GoImports lists additional Go imports this module needs beyond the base set.
GoImports []string
// GoDeps lists Go module dependencies (require lines for go.mod) that the
// generated program needs. Each entry should be "module version", e.g.
// "github.com/gosimple/slug v1.15.0". Only needed for external modules
// that depend on third-party Go packages.
GoDeps []string
// GoReplace lists replace directives for go.mod. Each entry should be
// "module => path" or "module version => path", e.g.
// "github.com/rubiojr/rugo => /path/to/local/rugo".
GoReplace []string
// Runtime is the Go source for the struct type and its methods (from embedded runtime.go).
Runtime string
// DispatchEntry, when set, names the module function that triggers dispatch.
// The compiler generates a typed map (rugo_<mod>_dispatch) mapping user-defined
// function names to their Go implementations, which the module's runtime uses
// to route commands to handlers.
DispatchEntry string
// DispatchTransform maps a handler name from source (e.g. the string argument
// in web.get("/", "handler") or cli.cmd("db:seed", "...")) to the Go function
// name used in the dispatch map. When nil, the identity transform is used
// (handler name == function name). Only functions whose transformed names match
// a def function are included in the dispatch map.
DispatchTransform func(string) string
// DispatchMainOnly, when true, restricts the dispatch map to functions
// defined in the main file (i.e. rugofn_* only), excluding namespaced
// functions from required modules.
DispatchMainOnly bool
// Doc is the module-level documentation shown by `rugo doc`.
Doc string
}
Module represents a Rugo stdlib module that can be imported.
func (*Module) FullRuntime ¶
FullRuntime returns the complete runtime source: the struct type and methods from Runtime plus auto-generated wrappers that handle interface{} conversion.