Help us shape the future of Go! Take the 2026 Go Developer Survey

doc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DynamicIDGroups = map[string]bool{
	"models": true, "schemas": true, "stores": true,
	"fs": true, "tasks": true, "schedules": true,
}

DynamicIDGroups lists groups whose process.make() uses group.<id>.method addressing. The handler key in process.Handlers is "group.method" (without <id>), but users call them as "group.<id>.method".

Exported so that CLI layers can build the callable pattern for display.

Functions

func AutoDiscover

func AutoDiscover() []string

AutoDiscover compares process.Handlers with registered doc entries and returns a sorted list of handler names that have no documentation.

func CallableName

func CallableName(e *Entry) string

CallableName returns the user-facing callable pattern for a process entry. For dynamic-ID groups (models, schemas, stores, fs, tasks, schedules) the handler key is "group.method" but users call "group.<id>.method", so this function returns "models.<id>.find". For all other groups it returns the entry name as-is.

func Groups

func Groups(entryType EntryType) []string

Groups returns a sorted list of distinct group names for the given type.

func LoadYAML

func LoadYAML(data []byte) error

LoadYAML unmarshals embedded YAML data and registers all entries. Process entry names are normalised to match the handler key stored in process.Handlers (gou/process/process.go RegisterGroup):

group="models", name="find"   → "models.find"  (handler key)
group="http",   name="get"    → "http.get"     (handler key)
group="encoding", name="encoding.base64.Encode" → unchanged

func Register

func Register(entry *Entry)

Register manually registers a single entry.

func Reset

func Reset()

Reset clears all registered entries (testing only).

func Stats

func Stats() map[EntryType]*StatInfo

Stats returns documentation coverage statistics keyed by EntryType.

Types

type DocFile

type DocFile struct {
	Group   string    `yaml:"group"`
	Type    EntryType `yaml:"type"`
	Entries []Entry   `yaml:"entries"`
}

DocFile is the top-level structure of a doc.yml file.

type Endpoint

type Endpoint struct {
	Method string `json:"method"            yaml:"method"`
	Path   string `json:"path"              yaml:"path"`
	Guard  string `json:"guard,omitempty"   yaml:"guard,omitempty"`
}

Endpoint describes an HTTP API endpoint (reserved for OpenAPI).

type Entry

type Entry struct {
	Name     string      `json:"name"               yaml:"name"`
	Type     EntryType   `json:"type"               yaml:"type"`
	Group    string      `json:"group"              yaml:"group"`
	Desc     string      `json:"desc"               yaml:"desc"`
	Args     []TypeValue `json:"args,omitempty"     yaml:"args,omitempty"`
	Return   *TypeValue  `json:"return,omitempty"   yaml:"return,omitempty"`
	Methods  []Method    `json:"methods,omitempty"  yaml:"methods,omitempty"`
	Endpoint *Endpoint   `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
}

Entry is a single documentation item.

func All

func All() []*Entry

All returns a snapshot of every registered entry.

func Get

func Get(t EntryType, name string) (*Entry, bool)

Get retrieves a single entry by type and name (case-insensitive). For process entries it also resolves callable names like "models.user.find" to the handler key "models.find".

func List

func List(entryType EntryType, opts ...ListOption) []*Entry

List returns entries of the given type, optionally filtered.

func Search(keyword string) []*Entry

Search returns entries whose name or description contains the keyword.

type EntryType

type EntryType string

EntryType identifies the kind of documented item.

const (
	TypeProcess    EntryType = "process"
	TypeJSObject   EntryType = "js_object"
	TypeJSFunction EntryType = "js_function"
	TypeJSClass    EntryType = "js_class"
	TypeOpenAPI    EntryType = "openapi"
)

type ListOption

type ListOption struct {
	Group  string
	Search string
}

ListOption controls filtering for List calls.

type Method

type Method struct {
	Name   string      `json:"name"              yaml:"name"`
	Desc   string      `json:"desc"              yaml:"desc"`
	Args   []TypeValue `json:"args,omitempty"    yaml:"args,omitempty"`
	Return *TypeValue  `json:"return,omitempty"  yaml:"return,omitempty"`
}

Method describes a method on a JS object or class.

type StatInfo

type StatInfo struct {
	Total        int `json:"total"`
	Documented   int `json:"documented"`
	Undocumented int `json:"undocumented"`
}

StatInfo holds documentation coverage statistics for one EntryType.

type TypeValue

type TypeValue struct {
	Type     string      `json:"type"               yaml:"type"`
	Desc     string      `json:"desc,omitempty"     yaml:"desc,omitempty"`
	Example  any         `json:"example,omitempty"  yaml:"example,omitempty"`
	Fields   []TypeValue `json:"fields,omitempty"   yaml:"fields,omitempty"`
	Items    *TypeValue  `json:"items,omitempty"    yaml:"items,omitempty"`
	Variants []TypeValue `json:"variants,omitempty" yaml:"variants,omitempty"`
	Name     string      `json:"name,omitempty"     yaml:"name,omitempty"`
	Required bool        `json:"required,omitempty" yaml:"required,omitempty"`
}

TypeValue is the universal value descriptor used for arguments, return values, fields and method signatures. Its Type field follows the bridge.go Go↔JS mapping:

Base:     null, undefined, bool, number, bigint, string, object, array,
          bytes, error, function, promise, external
Extended: void, any, union
Named:    Response, Paginated, CodeBlock, … (object with fields)

type ValidationResult

type ValidationResult struct {
	Valid      bool     `json:"valid"`
	Status     string   `json:"status"`
	Name       string   `json:"name"`
	Suggestion []string `json:"suggestion,omitempty"`
	Message    string   `json:"message"`
	Entry      *Entry   `json:"entry,omitempty"`
}

ValidationResult holds the outcome of a Validate call.

func Validate

func Validate(entryType EntryType, name string) *ValidationResult

Validate checks whether a named entry of the given type is documented. For process entries it also resolves callable names like "models.user.find" to their handler key "models.find" (stripping the dynamic <id> segment).

Jump to

Keyboard shortcuts

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