docsgenerator

package
v0.74.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	Name        string    `yaml:"name"`
	Description string    `yaml:"description"`
	Note        string    `yaml:"note"`
	Default     string    `yaml:"default"`
	Examples    []Example `yaml:"examples"`
	Example     Example   `yaml:"example"`
	Values      []string  `yaml:"values"`
	// Makes item param if specified param is defined
	OptionalIf  string `yaml:"optional_if"`
	RequiredlIf string `yaml:"required_if"`
}

type Example

type Example struct {
	Name  string `yaml:"name"`
	Value string `yaml:"value"`
	Type  string `yaml:"type"`
}

type FieldDoc

type FieldDoc struct {
	// Name represents struct name or field name.
	Name string
	// Type represents struct name or field type.
	Type string
	// Description represents the full description for the item.
	Description string
	// Note is rendered as a note for the example in markdown file.
	Note string

	Optional   bool
	OptionalIf string
	RequiredIf string
	Default    string

	// Examples: List of example values for the item.
	Examples []Example
	// Values is only used to render valid values listed in the documentation.
	Values []string

	// Options renders extra options for this field.
	Options []string
	// contains filtered or unexported fields
}

Doc represents a struct documentation rendered from comments by docgen.

type FileDoc

type FileDoc struct {
	// Description: File description, supports markdown.
	Description string
	// Types structs defined in the file.
	Types   []*TypeDoc
	Anchors map[string]string
	// contains filtered or unexported fields
}

FileDoc represents a single go file documentation.

func NewFileDoc

func NewFileDoc(description string, types []*TypeDoc) *FileDoc

func (*FileDoc) Encode

func (fd *FileDoc) Encode() ([]byte, error)

Encode: Encodes file documentation as .md file.

func (*FileDoc) Write

func (fd *FileDoc) Write(path, frontmatter string) error

Write: Dumps documentation string to folder.

type TypeDoc

type TypeDoc struct {
	// Name represents struct name or field name.
	Name string
	// Type represents struct name or field type.
	Type string
	// Description represents the full description for the item.
	Description string
	// Note is rendered as a note for the example in markdown file.
	Note string
	// Fields contains fields documentation if related item is a struct.
	Fields []FieldDoc
	// Example values for the type.
	Example Example
}

Example of usage:

name: Type Document type: TypeDoc description: TypeDoc represents the types of documentation in a file node: A note to be displayed at the end of the doc example:

type: json
name: JSON usage
value: { "Name": "name", "Type": "type", "Description": "description" }

type TypeDocGenerator

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

func NewTypeDocGenerator

func NewTypeDocGenerator(dir, tagName string) (*TypeDocGenerator, error)

func (*TypeDocGenerator) Generate

func (gen *TypeDocGenerator) Generate(typesNames ...string) ([]*TypeDoc, error)

Jump to

Keyboard shortcuts

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