gendoc

package
v0.0.0-...-fba9dd7 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: GPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const MetaPrefix = "@"
View Source
const WorkDirectory = "../../"

Variables

View Source
var (
	Logger = zaplog.NewPackage("goscript", "gendoc").Sugar()

	OptionDirectory = filepath.Join(WorkDirectory, "./options")

	GoPackageConfig = &gopackage.Config{
		Mode:       gopackage.NeedName | gopackage.NeedFiles | gopackage.NeedSyntax,
		Dir:        OptionDirectory,
		BuildFlags: []string{"-tags=debug"},
		Context:    context.Background(),
		Logf:       Logger.Infof,
		Env:        os.Environ(),
		Fset:       gotoken.NewFileSet(),
	}
)
View Source
var ErrMissingMetaValue = errors.New("missing meta value")
View Source
var LangList = []LangCode{LangZhCn, LangEnUS}
View Source
var LangMap map[string]LangCode
View Source
var RegisteredOption = map[string]struct{}{
	"Options":      {},
	"LogOption":    {},
	"DomainOption": {},

	"ConnectOption": {},
	"DNSOption":     {},
	"HTTPOption":    {},

	"DatasourceOption":              {},
	"CommandDatasourceOption":       {},
	"HTTPDatasourceOption":          {},
	"NetlinkDatasourceOption":       {},
	"DatasourceGroupFailoverOption": {},
	"DatasourceGroupSumOption":      {},

	"ProviderOption":           {},
	"CloudflareProviderOption": {},
}

Functions

func Run

func Run(ctx context.Context)

Types

type BaseDocument

type BaseDocument struct {
	Name string
	Lang map[LangCode]string
}

func (*BaseDocument) FromComment

func (o *BaseDocument) FromComment(comment *goast.CommentGroup,
	tokenHandler TokenNameHandler,
) error

func (*BaseDocument) FromToken

func (o *BaseDocument) FromToken(token *Tokenizer,
	tokenHandler TokenNameHandler,
) error

type FieldDocument

type FieldDocument struct {
	BaseDocument

	Ast *goast.Field

	YAML     *jsonschema.FieldTagInfo
	Values   []string
	Platform []string
	Shared   bool
}

func NewField

func NewField(ast *goast.Field) (*FieldDocument, error)

func (*FieldDocument) FromTokenName

func (o *FieldDocument) FromTokenName(name string, t *Tokenizer) error

func (*FieldDocument) Required

func (o *FieldDocument) Required() bool

type LangCode

type LangCode string
const (
	LangDefault = LangEnUS

	LangZhCn LangCode = "ZH_CN"
	LangEnUS LangCode = "EN_US"
)

type StructDocument

type StructDocument struct {
	BaseDocument

	Ast         *goast.StructType
	AstTypeSpec *goast.TypeSpec

	Fields []*FieldDocument

	Shared bool
}

func NewStruct

func NewStruct(gendecl *goast.GenDecl, typeSpec *goast.TypeSpec, structType *goast.StructType) (*StructDocument, error)

func (*StructDocument) FromTokenName

func (o *StructDocument) FromTokenName(name string, token *Tokenizer) error

type TokenNameHandler

type TokenNameHandler interface {
	FromTokenName(name string, token *Tokenizer) error
}

type Tokenizer

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

func NewTokenizer

func NewTokenizer(r io.Reader) *Tokenizer

func NewTokenizerString

func NewTokenizerString(s string) *Tokenizer

func (*Tokenizer) Err

func (t *Tokenizer) Err() error

func (*Tokenizer) Fragment

func (t *Tokenizer) Fragment() []byte

func (*Tokenizer) FragmentText

func (t *Tokenizer) FragmentText() string

func (*Tokenizer) MetaName

func (t *Tokenizer) MetaName() string

func (*Tokenizer) NextMeta

func (t *Tokenizer) NextMeta() bool

func (*Tokenizer) Reset

func (t *Tokenizer) Reset()

Jump to

Keyboard shortcuts

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