gen

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package gen implements code generation from TL schema.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Funcs added in v0.19.0

func Funcs() template.FuncMap

Funcs returns functions which used in templates.

func Template

func Template() *template.Template

Template parses and returns vendored code generation templates.

Types

type FileSystem

type FileSystem interface {
	WriteFile(baseName string, source []byte) error
}

FileSystem represents a directory of generated package.

type Generator

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

Generator generates go types from tl.Schema.

func NewGenerator

func NewGenerator(s *tl.Schema, options ...Option) (*Generator, error)

NewGenerator initializes and returns new Generator from tl.Schema.

func (*Generator) WriteSource

func (g *Generator) WriteSource(fs FileSystem, pkgName string, t *template.Template) error

WriteSource writes generated definitions to fs.

type Option added in v0.48.0

type Option func(o *generateOptions)

Option that configures generation.

func WithDocumentation added in v0.48.0

func WithDocumentation(base string) Option

WithDocumentation will embed documentation references to generated code.

If base is https://core.telegram.org, documentation content will be also embedded.

func WithServer added in v0.48.0

func WithServer() Option

WithServer enables experimental server generation.

Directories

Path Synopsis
Package td contains generated code from example schema and is used for codegen testing.
Package td contains generated code from example schema and is used for codegen testing.

Jump to

Keyboard shortcuts

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