Documentation ¶
Overview ¶
Package getdoc provides a way to transform Telegram TL documentation into machine-readable format.
Index ¶
Examples ¶
Constants ¶
const ( CategoryType = "type" CategoryConstructor = "constructor" CategoryMethod = "method" )
const LayerLatest = 133
LayerLatest is id of latest layer.
Variables ¶
var ErrNotFound = errors.New("layer not found")
ErrNotFound means that current package version does not support requested layer.
var Layers = []int{
121,
133,
}
Layers is list of supported layers.
Functions ¶
func LayerExists ¶
LayerExists returns true if layer is included in package.
Types ¶
type Constructor ¶
type Constructor struct { Name string `json:"name"` Description []string `json:"description,omitempty"` Links []string `json:"links,omitempty"` Fields map[string]ParamDescription `json:"fields,omitempty"` }
Constructor represents constructor documentation.
func ParseConstructor ¶
func ParseConstructor(reader io.Reader) (*Constructor, error)
ParseConstructor parses html documentation from reader and produces Constructor.
type Doc ¶
type Doc struct { Index Index `json:"index"` Constructors map[string]Constructor `json:"constructors"` Types map[string]Type `json:"types"` Methods map[string]Method `json:"methods"` Errors map[string]Error `json:"errors"` }
Doc represents full documentation description.
func Extract ¶
func Extract(ctx context.Context, d Downloader) (*Doc, error)
Extract uses Downloader to extract documentation.
func ExtractLayer ¶ added in v0.4.0
ExtractLayer uses Downloader to extract documentation of specified layer.
func Load ¶
Load layer documentation.
Example ¶
package main import ( "fmt" "github.com/gotd/getdoc" ) func main() { layer := 133 if !getdoc.LayerExists(121) { panic("not exists") } if !getdoc.LayerExists(133) { panic("not exists") } doc, err := getdoc.Load(layer) if err != nil { panic(err) } fmt.Printf("Layer %d, constructors: %d\n", doc.Index.Layer, len(doc.Constructors)) }
Output: Layer 133, constructors: 926
type Downloader ¶
Downloader abstracts documentation fetching.
type Error ¶
type Error struct { Code int `json:"code"` Type string `json:"type"` Description string `json:"description,omitempty"` }
Error represent possible error documentation.
type Method ¶
type Method struct { Name string `json:"name"` Description []string `json:"description,omitempty"` Links []string `json:"links,omitempty"` Parameters map[string]ParamDescription `json:"parameters,omitempty"` Errors []Error `json:"errors,omitempty"` BotCanUse bool `json:"bot_can_use,omitempty"` }
Method represents method documentation.