apigen

package
v0.0.0-...-05a9aa5 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultParseOpts = &ParseOpts{
	IgnoreH3: []string{
		"Recent changes",
		"Authorizing your bot",
		"Making requests",
		"Using a Local Bot API Server",
	},
	IgnoreH4: []string{
		"Available types$Sending files",
		"Available types$Inline mode objects",
		"Available methods$Formatting options",
	},
}

Functions

func ChapterNameToFilename

func ChapterNameToFilename(name string) string

func Codegen

func Codegen(api *ParsedAPI, opts *GenOpts) error

func CodegenChapter

func CodegenChapter(chap *Chapter, opts *GenOpts) (*jen.File, error)

func CodegenFunc

func CodegenFunc(obj *Object, f *jen.File, opts *GenOpts) error

func CodegenStruct

func CodegenStruct(obj *Object, f *jen.File, opts *GenOpts) error

func FieldToCode

func FieldToCode(f Field, objectName string, opts *GenOpts) (jen.Code, error)

func FieldToGo

func FieldToGo(name string) (string, error)

func FuncNameToGo

func FuncNameToGo(name string) (string, error)

func TypeNameToGo

func TypeNameToGo(name string) (string, error)

func TypeToGo

func TypeToGo(t Type) (string, error)

Types

type Chapter

type Chapter struct {
	Name    string
	Objects []*Object
}

func (*Chapter) GetObject

func (p *Chapter) GetObject(name string) *Object

type Field

type Field struct {
	Name        string
	Type        Type
	Description string
	IsOptional  bool
	IsRequired  bool
}

type GenOpts

type GenOpts struct {
	PackageName      string
	Dest             string
	TypeExceptions   []TypeException
	MethodExceptions []MethodException
	StructExceptions []StructException
}

type MethodException

type MethodException struct {
	Method       string
	OverrideType string
}

type Object

type Object struct {
	IsType     bool
	IsFunction bool
	Name       string
	Notes      []string
	Fields     []Field

	// Function-specific fields
	ReturnType string
}

type ParseOpts

type ParseOpts struct {
	IgnoreH3 []string
	IgnoreH4 []string
}

type ParsedAPI

type ParsedAPI struct {
	Chapters map[string]*Chapter
}

func Parse

func Parse(r io.Reader, opts *ParseOpts) (*ParsedAPI, error)

func (*ParsedAPI) GetChapter

func (p *ParsedAPI) GetChapter(key string) *Chapter

type StructException

type StructException struct {
	StructName string
	Skip       bool
}

type Type

type Type struct {
	Name    string
	HasLink bool // indicated reference to object
}

type TypeException

type TypeException struct {
	Domain     string // if Domain matches type's location prefix
	TypeString string // and TypeString matches type
	GoType     string // use GoType instead
}

Jump to

Keyboard shortcuts

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