doc

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package doc extracts documentation from Rugo source files.

It works on raw .rg source before preprocessing, since the compiler's stripComments phase destroys comments. The extraction rule is simple: consecutive # lines immediately before a def/struct declaration (no blank line gap) are attached as the doc comment for that declaration.

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.

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 .rg file.

func Extract

func Extract(src, path string) *FileDoc

Extract parses raw Rugo source and returns structured documentation.

func ExtractDir

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

ExtractDir reads all .rg 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 ExtractFile

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

ExtractFile reads a .rg 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
}

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
}

StructDoc describes a documented struct.

Jump to

Keyboard shortcuts

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