doc

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

README

doc

import github.com/projectbadger/autodoc/doc

Index

func AddConst(string, string, string)

AddConst parses *doc.Value that contains constants data and appends a new Var struct to the provided data *Package.

func AddConst(data *Package, node *doc.Value, path string)

func AddExample(string, string, string)

AddVar parses *doc.Example containing example data and appends a new *Example to the provided data *Package.

func AddExample(data *Package, node *doc.Example, path string)

func AddFunc(string, string, string)

AddFunc parses *doc.Func and appends a new *Func to the provided data *Package.

func AddFunc(data *Package, node *doc.Func, path string)

func AddFuncExample(string, string, string)

AddFuncExample parses *doc.Example containing example data and appends a new *Example to the provided data *Package.

func AddFuncExample(data *Func, node *doc.Example, path string)

func AddType(string, string, string)

AddType parses *doc.Type and appends a new *Type to the provided data *Package.

func AddType(data *Package, node *doc.Type, path string)

func AddTypeExample(string, string, string)

AddTypeExample parses *doc.Example containing example data and appends a new *Example to the provided data *Package.

func AddTypeExample(data *Type, node *doc.Example, path string)

func AddTypeFunc(string, string, string)

AddTypeFunc parses *doc.Func from a *doc.Type and appends a new *Func to the provided data *Package.

func AddTypeFunc(data *Type, node *doc.Func, path string)

func AddTypeMethod(string, string, string)

AddTypeMethod parses *doc.Func from a *doc.Type and appends a new *Func to the provided data *Package.

func AddTypeMethod(data *Type, node *doc.Func, path string)

func AddVar(string, string, string)

AddVar parses *doc.Value that contains variables data and appends a new Var struct to the provided data *Package.

func AddVar(data *Package, node *doc.Value, path string)

func GetDirectories(string)

func GetDirectories(path string) []string

func GetGoFiles(string)

func GetGoFiles(path string) []*ast.File

func GetGoFilesInDir(string)

func GetGoFilesInDir(path string) []*ast.File

func GetPackageDocumentation(string, string) error

func GetPackageDocumentation(packageFilePath, packageImportPath string) (*doc.Package, error)

func GetPackagesDataFromDirRecursive(string, bool, string) error

GetPackagesDataFromDirRecursive parses all the .go files in the directories in the path recursively and returns them as a map[string]*Package with path as key.

func GetPackagesDataFromDirRecursive(dirPath string, includeRoot bool, rootImportPath string) (map[string]*Package, error)

func ParseGoMod(string, string) error

ParseGoMod parses a go.mod file and fills the data in the provided *Package.

func ParseGoMod(pkg *Package, path string) error

func ParseGoModFile(string, string) error

ParseGoModFile parses a go.mod file.

func ParseGoModFile(module *Module, path string) error

func SeekGoMod(string, string, int) error

SeekGoMod seeks a go.mod file for a provided number of levels upwards.

func SeekGoMod(pkg *Package, path string, levels int) error

type Const

type Const struct {
	Name		string
	Definition	string
	Doc		string
	Filename	string
	Line		int
}

type Example

Example holds documentation example data.

type Example struct {
	Name		string
	Definition	string
	Doc		string
}

type Func

Func holds function data.

type Func struct {
	Name		string
	Definition	string
	Recv		FuncVar
	Params		[]FuncVar
	Results		[]FuncVar
	Doc		string
	Examples	[]*Example
	Filename	string
	Line		int
}

func NewFunc(string, string) Func

NewFunc parses *doc.Func and returns a *Func.

func NewFunc(node *doc.Func, path string) *Func

func (*Func) FormatParams() string

FormatParams returns function parameters with names removed.

func (f *Func) FormatParams() string

func (*Func) FormatParamsBrackets() string

FormatParams returns function parameters in brackets with names removed.

func (f *Func) FormatParamsBrackets() string

func (*Func) FormatResults() string

FormatResults returns function results with names removed.

func (f *Func) FormatResults() string

func (*Func) FormatResultsBrackets() string

FormatResultsBrackets returns function results with names removed in brackets.

func (f *Func) FormatResultsBrackets() string

func (*Func) GetHeadingHREF() string

GetHeadingHREF returns function definition, formated as a name for a relative link.

func (f *Func) GetHeadingHREF() string

type FuncVar

type FuncVar struct {
	Name	string
	Type	string
	Pointer	bool
}

type Module

Module holds module info.

type Module struct {
	Name		string			`json:"name" yaml:"name"`
	GoVersion	string			`json:"go_version" yaml:"go_version"`
	Heading		string			`json:"heading" yaml:"heading"`
	Overview	string			`json:"overview" yaml:"overview"`
	ImportPath	string			`json:"import_path" yaml:"import_path"`
	Submodules	map[string]*Package	`json:"submodules" yaml:"submodules"`
}

func ParseModule(string) (Module, error)

ParseModule parses a go module in the provided path and returns a *Module.

func ParseModule(path string) (*Module, error)

type Package

Package holds package data for use in templates.

type Package struct {
	ImportPath	string
	Name		string
	Definition	string
	Doc		string
	Subpackages	map[string]*Package
	Examples	[]*Example
	Funcs		[]*Func
	Types		[]*Type
	Constants	[]*Const
	Vars		[]*Var
	CustomVars	map[string]string
	Path		string
	PathAbs		string
	ShowName	bool
	ShowDoc		bool
	ShowExamples	bool
	ShowIndex	bool
	ShowFuncs	bool
	ShowTypes	bool
	ShowConsts	bool
	ShowVars	bool
	ShowSubpackages	bool
	ShowOverview	bool
	ShowImportPath	bool
}

func GetPackageDataFromDir(string) (Package, error)

GetPackageDataFromDirRecursive parses all the .go files in the provided directory.

func GetPackageDataFromDir(path string) (*Package, error)

func GetPackageDataFromDirRecursive(string) (Package, error)

GetPackageDataFromDirRecursive parses all the .go files in the path recursively.

func GetPackageDataFromDirRecursive(path string) (*Package, error)

func ParsePackage(string, string) (Package, error)

ParsePackage parses go files in a directory and returns a *Package.

func ParsePackage(docs *doc.Package, path string) (*Package, error)

func (Package) PathIndent()

PathIdent returns 2 spaces for every '/' character in the path.

func (p Package) PathIndent() func(string) string

func (*Package) PathSplit()

PathSplit returns the package relative path, split by the '/' character.

func (p *Package) PathSplit() []string

type Type

Type holds type data.

type Type struct {
	Name		string
	Definition	string
	Doc		string
	Examples	[]*Example
	Methods		[]*Func
	Funcs		[]*Func
	Filename	string
	Line		int
}

func (*Type) GetHeadingHREF() string

GetHeadingHREF returns type definition, formated as a name for a relative link.

func (t *Type) GetHeadingHREF() string

type Var

Var holds variable data.

type Var struct {
	Name		string
	Definition	string
	Doc		string
	Filename	string
	Line		int
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConst

func AddConst(data *Package, node *doc.Value, path string)

AddConst parses *doc.Value that contains constants data and appends a new Var struct to the provided data *Package.

func AddExample

func AddExample(data *Package, node *doc.Example, path string)

AddVar parses *doc.Example containing example data and appends a new *Example to the provided data *Package.

func AddFunc

func AddFunc(data *Package, node *doc.Func, path string)

AddFunc parses *doc.Func and appends a new *Func to the provided data *Package.

func AddFuncExample

func AddFuncExample(data *Func, node *doc.Example, path string)

AddFuncExample parses *doc.Example containing example data and appends a new *Example to the provided data *Package.

func AddType

func AddType(data *Package, node *doc.Type, path string)

AddType parses *doc.Type and appends a new *Type to the provided data *Package.

func AddTypeExample

func AddTypeExample(data *Type, node *doc.Example, path string)

AddTypeExample parses *doc.Example containing example data and appends a new *Example to the provided data *Package.

func AddTypeFunc

func AddTypeFunc(data *Type, node *doc.Func, path string)

AddTypeFunc parses *doc.Func from a *doc.Type and appends a new *Func to the provided data *Package.

func AddTypeMethod

func AddTypeMethod(data *Type, node *doc.Func, path string)

AddTypeMethod parses *doc.Func from a *doc.Type and appends a new *Func to the provided data *Package.

func AddVar

func AddVar(data *Package, node *doc.Value, path string)

AddVar parses *doc.Value that contains variables data and appends a new Var struct to the provided data *Package.

func GetDirectories

func GetDirectories(path string) []string

func GetGoFiles

func GetGoFiles(path string) []*ast.File

func GetGoFilesInDir

func GetGoFilesInDir(path string) []*ast.File

func GetPackageDocumentation

func GetPackageDocumentation(packageFilePath, packageImportPath string) (*doc.Package, error)

func GetPackagesDataFromDirRecursive

func GetPackagesDataFromDirRecursive(dirPath string, includeRoot bool, rootImportPath string) (map[string]*Package, error)

GetPackagesDataFromDirRecursive parses all the .go files in the directories in the path recursively and returns them as a map[string]*Package with path as key.

func ParseGoMod

func ParseGoMod(pkg *Package, path string) error

ParseGoMod parses a go.mod file and fills the data in the provided *Package.

func ParseGoModFile

func ParseGoModFile(module *Module, path string) error

ParseGoModFile parses a go.mod file.

func SeekGoMod

func SeekGoMod(pkg *Package, path string, levels int) error

SeekGoMod seeks a go.mod file for a provided number of levels upwards.

Types

type Const

type Const struct {
	Name       string
	Definition string
	Doc        string
	Filename   string
	Line       int
}

type Example

type Example struct {
	Name       string
	Definition string
	Doc        string
}

Example holds documentation example data.

type Func

type Func struct {
	Name       string
	Definition string
	Recv       FuncVar
	Params     []FuncVar
	Results    []FuncVar
	Doc        string
	Examples   []*Example
	Filename   string
	Line       int
}

Func holds function data.

func NewFunc added in v0.0.5

func NewFunc(node *doc.Func, path string) *Func

NewFunc parses *doc.Func and returns a *Func.

func (*Func) FormatParams added in v0.0.3

func (f *Func) FormatParams() string

FormatParams returns function parameters with names removed.

func (*Func) FormatParamsBrackets added in v0.0.3

func (f *Func) FormatParamsBrackets() string

FormatParams returns function parameters in brackets with names removed.

func (*Func) FormatResults added in v0.0.3

func (f *Func) FormatResults() string

FormatResults returns function results with names removed.

func (*Func) FormatResultsBrackets added in v0.0.3

func (f *Func) FormatResultsBrackets() string

FormatResultsBrackets returns function results with names removed in brackets.

func (*Func) GetHeadingHREF added in v0.0.3

func (f *Func) GetHeadingHREF() string

GetHeadingHREF returns function definition, formated as a name for a relative link.

type FuncVar added in v0.0.3

type FuncVar struct {
	Name    string
	Type    string
	Pointer bool
}

type Module

type Module struct {
	Name       string              `json:"name" yaml:"name"`
	GoVersion  string              `json:"go_version" yaml:"go_version"`
	Heading    string              `json:"heading" yaml:"heading"`
	Overview   string              `json:"overview" yaml:"overview"`
	ImportPath string              `json:"import_path" yaml:"import_path"`
	Submodules map[string]*Package `json:"submodules" yaml:"submodules"`
}

Module holds module info.

func ParseModule

func ParseModule(path string) (*Module, error)

ParseModule parses a go module in the provided path and returns a *Module.

type Package

type Package struct {
	ImportPath      string
	Name            string
	Definition      string
	Doc             string
	Subpackages     map[string]*Package
	Examples        []*Example
	Funcs           []*Func
	Types           []*Type
	Constants       []*Const
	Vars            []*Var
	CustomVars      map[string]string
	Path            string
	PathAbs         string
	ShowName        bool
	ShowDoc         bool
	ShowExamples    bool
	ShowIndex       bool
	ShowFuncs       bool
	ShowTypes       bool
	ShowConsts      bool
	ShowVars        bool
	ShowSubpackages bool
	ShowOverview    bool
	ShowImportPath  bool
}

Package holds package data for use in templates.

func GetPackageDataFromDir

func GetPackageDataFromDir(path string) (*Package, error)

GetPackageDataFromDirRecursive parses all the .go files in the provided directory.

func GetPackageDataFromDirRecursive

func GetPackageDataFromDirRecursive(path string) (*Package, error)

GetPackageDataFromDirRecursive parses all the .go files in the path recursively.

func ParsePackage

func ParsePackage(docs *doc.Package, path string) (*Package, error)

ParsePackage parses go files in a directory and returns a *Package.

func (Package) PathIndent added in v0.0.8

func (p Package) PathIndent() func(string) string

PathIdent returns 2 spaces for every '/' character in the path.

func (*Package) PathSplit added in v0.0.8

func (p *Package) PathSplit() []string

PathSplit returns the package relative path, split by the '/' character.

type Type

type Type struct {
	Name       string
	Definition string
	Doc        string
	Examples   []*Example
	Methods    []*Func
	Funcs      []*Func
	Filename   string
	Line       int
}

Type holds type data.

func (*Type) GetHeadingHREF added in v0.0.4

func (t *Type) GetHeadingHREF() string

GetHeadingHREF returns type definition, formated as a name for a relative link.

type Var

type Var struct {
	Name       string
	Definition string
	Doc        string
	Filename   string
	Line       int
}

Var holds variable data.

Jump to

Keyboard shortcuts

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