go.bigb.es/curator
Index
Functions
func HighlightDecl(src string) string
func HighlightDeclLinked(src string, symbols map[string]string, importLinks map[string]string) string
HighlightDeclLinked returns syntax-highlighted HTML with cross-references. symbols maps local names to anchors (e.g., "Client" → "#Client"). importLinks maps package aliases to base doc URLs (e.g., "http" → "https://pkg.go.dev/net/http"). When a qualified name like http.Client is found, it links to <baseURL>#Client.
func HighlightGo(src []byte) string
HighlightGo returns syntax-highlighted HTML for Go source code. Uses go/scanner to tokenize and wraps tokens in <span> elements with CSS classes. The output includes line numbers with anchor targets for deep linking.
Types
type FuncDoc struct { Name string Doc string // HTML Decl string // signature Recv string // receiver type, empty for top-level functions ShortDecl string // one-line signature for index SourceFile string // file containing the declaration SourceLine int // line number }
FuncDoc represents a function.
type PackageDoc struct { ImportPath string Name string Synopsis string Doc string // HTML-rendered doc comment Consts []ValueDoc Vars []ValueDoc Funcs []FuncDoc Types []TypeDoc Files []string Imports map[string]string // alias → import path (e.g., "http" → "net/http") // Module-level info (populated by caller). Module string Version string Versions []string SubPackages []SubPkgSummary }
PackageDoc holds parsed documentation for a Go package.
func ParsePackage(gitCache *git.Cache, repoPath, rev, pkgDir, importPath string) (*PackageDoc, error)
ParsePackage reads Go source files from a git revision and produces documentation.
type SubPkgSummary struct { RelPath string // relative path from module root ImportPath string Synopsis string }
SubPkgSummary describes a sub-package for the module overview.
func ListSubPackages(gitCache *git.Cache, repoPath, rev, modulePath string) ([]SubPkgSummary, error)
ListSubPackages discovers sub-packages in a module.
type TypeDoc struct { Name string Doc string // HTML Decl string // type declaration source Consts []ValueDoc Vars []ValueDoc Funcs []FuncDoc // associated constructors Methods []FuncDoc SourceFile string // file containing the declaration SourceLine int // line number }
TypeDoc represents a type with its methods and associated functions.
HighlightDecl returns syntax-highlighted HTML for a Go declaration snippet.