docgen

package
v2.0.0-b6 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package docgen provides tools for extracting and storing documentation from Go source code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateGoFile

func GenerateGoFile(pkgName string, content []byte) []byte

func GenerateYAML

func GenerateYAML(sourceFiles []string, auxTypes []*TypeDoc, methods []*FunctionDoc) ([]byte, error)

GenerateYAML generates YAML documentation from service documentation.

Types

type Extractor

type Extractor struct {
	// contains filtered or unexported fields
}

Extractor extracts documentation from Go source code.

func NewExtractor

func NewExtractor(pkg *packages.Package, pkgSet map[string]*packages.Package) *Extractor

NewExtractor creates a new documentation extractor.

func (*Extractor) ExtractFunction

func (e *Extractor) ExtractFunction(t *types.Signature, obj types.Object) (*FunctionDoc, error)

func (*Extractor) ExtractType

func (e *Extractor) ExtractType(t *types.Named) (map[string]TypeDoc, error)

ExtractType extracts documentation from any type, creating a TypeDoc.

type FieldArrayDoc

type FieldArrayDoc struct {
	Type string
}

type FieldDoc

type FieldDoc struct {
	Name       string
	Type       string // Full type name
	Comment    string
	Tags       string
	FilePath   string
	Line       int
	Nullable   bool
	IsEmbedded bool
	IsMap      *FieldMapDoc
	IsArray    *FieldArrayDoc
}

FieldDoc represents documentation for a struct field.

type FieldMapDoc

type FieldMapDoc struct {
	TypeKey   string
	TypeValue string
}

type FunctionDoc

type FunctionDoc struct {
	Package string
	Name    string
	Comment string
	File    string
	Line    int
	Params  []FunctionParamDoc
	Returns []FunctionParamDoc
}

FunctionDoc is some function's documentation.

type FunctionParamDoc

type FunctionParamDoc struct {
	Name string
	Type string
}

type TypeDoc

type TypeDoc struct {
	Name     string
	Package  string
	File     string
	Line     int
	Comment  string
	Fields   []FieldDoc
	Methods  []FunctionDoc
	IsStruct bool
}

TypeDoc represents documentation for a type.

type YAMLDoc

type YAMLDoc struct {
	Checksum  string                `yaml:"checksum"`
	Types     map[string]YAMLType   `yaml:"types"`
	Functions map[string]YAMLMethod `yaml:"functions"`
}

YAMLDoc represents the YAML documentation format.

type YAMLField

type YAMLField struct {
	Name       string          `yaml:"name"`
	Type       string          `yaml:"type"`
	Comment    string          `yaml:"comment,omitempty"`
	Tags       string          `yaml:"tags,omitempty"`
	Nullable   bool            `yaml:"nullable,omitempty"`
	IsMap      *YAMLFieldMap   `yaml:"is_map,omitempty"`
	IsArray    *YAMLFieldArray `yaml:"is_array,omitempty"`
	IsEmbedded bool            `yaml:"is_embedded,omitempty"`
}

YAMLField represents a field in YAML format.

type YAMLFieldArray

type YAMLFieldArray struct {
	Type string `yaml:"type"`
}

type YAMLFieldMap

type YAMLFieldMap struct {
	TypeKey   string `yaml:"key"`
	TypeValue string `yaml:"value"`
}

type YAMLMethod

type YAMLMethod struct {
	Comment string            `yaml:"comment,omitempty"`
	File    string            `yaml:"file"`
	Line    int               `yaml:"line"`
	Inputs  []YAMLMethodParam `yaml:"inputs"`
	Outputs []YAMLMethodParam `yaml:"outputs"`
}

Method represents a service method in YAML format.

type YAMLMethodParam

type YAMLMethodParam struct {
	Name string `yaml:"name"`
	Type string `yaml:"type"`
}

type YAMLType

type YAMLType struct {
	ID       string                `yaml:"id"`
	PkgPath  string                `yaml:"package"`
	Name     string                `yaml:"name"`
	File     string                `yaml:"file"`
	Line     int                   `yaml:"line"`
	Comment  string                `yaml:"comment,omitempty"`
	Fields   []YAMLField           `yaml:"fields,omitempty"`
	Methods  map[string]YAMLMethod `yaml:"methods,omitempty"`
	IsStruct bool                  `yaml:"is_struct"`
}

YAMLType represents a type in YAML format.

Directories

Path Synopsis
Package docregistry provides a registry for documentation entities extracted from the comments.
Package docregistry provides a registry for documentation entities extracted from the comments.

Jump to

Keyboard shortcuts

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