doc

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package doc extracts documentation from Rugo source files.

It uses the compiler's ParseSource API to get AST nodes and struct metadata, then correlates doc comments from the raw source using line numbers. The attachment rule: consecutive # lines immediately before a def/struct declaration (no blank line gap) are attached as the doc comment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatAllModules

func FormatAllModules() string

FormatAllModules lists all available modules and bridge packages.

func FormatBridgePackage

func FormatBridgePackage(pkg *gobridge.Package) string

FormatBridgePackage formats a Go bridge package for terminal display.

func FormatFile

func FormatFile(fd *FileDoc) string

FormatFile formats a FileDoc for terminal display. When items have Source set (from recursive extraction), they are grouped by source file with headers.

func FormatModule

func FormatModule(m *modules.Module) string

FormatModule formats a stdlib module for terminal display.

func FormatSymbol

func FormatSymbol(docStr, signature string) string

FormatSymbol formats a single symbol lookup result.

func LookupSymbol

func LookupSymbol(fd *FileDoc, name string) (doc string, signature string, found bool)

LookupSymbol finds a specific function or struct by name in a FileDoc.

Types

type FileDoc

type FileDoc struct {
	Path    string
	Doc     string // file-level doc (first # block before any code)
	Funcs   []FuncDoc
	Structs []StructDoc
}

FileDoc holds all extracted documentation for a single Rugo file.

func Extract

func Extract(src, path string) *FileDoc

Extract parses raw Rugo source and returns structured documentation. It uses the compiler API for AST and struct metadata, and correlates doc comments from the raw source by line number.

func ExtractDir

func ExtractDir(dir, entryFile string) (*FileDoc, error)

ExtractDir reads all Rugo files in a directory (non-recursive) and returns aggregated documentation. The entry file's doc becomes the top-level doc. Other files contribute their functions and structs.

func ExtractDirRecursive added in v0.14.4

func ExtractDirRecursive(dir, entryFile string) (*FileDoc, error)

ExtractDirRecursive walks a directory tree and aggregates documentation from all non-test Rugo files. Test files (*_test.rugo) are excluded. The entry file's doc becomes the top-level doc.

func ExtractFile

func ExtractFile(path string) (*FileDoc, error)

ExtractFile reads a Rugo file and extracts all documentation.

type FuncDoc

type FuncDoc struct {
	Name   string   // e.g. "factorial" or "Dog.bark"
	Params []string // parameter names
	Doc    string
	Line   int    // 1-based line number of the def
	Source string // relative path of the source file (set by recursive extraction)
}

FuncDoc describes a documented function.

type StructDoc

type StructDoc struct {
	Name   string
	Fields []string
	Doc    string
	Line   int    // 1-based line number of the struct keyword
	Source string // relative path of the source file (set by recursive extraction)
}

StructDoc describes a documented struct.

Jump to

Keyboard shortcuts

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