diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..453419d --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +/.vscode/ +.idea + +.DS_Store + +# tests coverage +coverage.out + +# test data artifacts +test/node_modules/ +test/output.json + +# plaintask todo files +*.todo + +# generated markdown previews +README.html +CHANGELOG.html +LICENSE.html diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..89dd58d --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2022 Guido Zuidhof +Copyright (c) 2023-present Gani Georgiev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9445744 --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ +(EXP) tygoja +[![GoDoc](https://godoc.org/github.com/pocketbase/tygoja?status.svg)](https://pkg.go.dev/github.com/pocketbase/tygoja) +====================================================================== + +**tygoja** is a small helper library for generating TypeScript declarations from Go code. + +The generated typings are intended to be used as import helpers to provide [ambient TypeScript declarations](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html) (aka. `.d.ts`) for [goja](https://github.com/dop251/goja) bindings. + +> **⚠️ Don't use it directly in production! It is not tagged and may change without notice.** +> +> **It was created to semi-automate the documentation of the goja integration for PocketBase.** +> +> **Use it only as a reference or as a non-critical step in your dev pipeline.** + +**tygoja** is a heavily modified fork of [tygo](https://github.com/gzuidhof/tygo) and extends its scope with: + +- custom field and method names formatters +- types for interfaces (exported and unexported) +- types for exported interface methods +- types for exported struct methods +- types for exported package level functions (_must enable `PackageConfig.WithPackageFunctions`_) +- inheritance declarations for embeded structs (_embedded pointers are treated as values_) +- autoloading all unmapped argument and return types (_when possible_) +- applying the same [goja's rules](https://pkg.go.dev/github.com/dop251/goja#hdr-Nil) when resolving the return types of exported function and methods +- combining multiple packages typings in a single output +- generating all declarations in namespaces with the packages name (both unmapped and mapped) +- preserving comment block new lines +- converting Go comment code blocks to Markdown code blocks +- and others... + +Note that by default the generated typings are not generated with `export` since the intended usage is to map them to your custom goja bindings. +This mapping could be defined in the `Config.Heading` field usually with the `declare` keyword (eg. `declare let someGojaProp: app.Cache`). + +## Example + +```go +package main + +import ( + "log" + "os" + + "github.com/pocketbase/tygoja" +) + +func main() { + gen := tygoja.New(tygoja.Config{ + Packages: map[string][]string{ + "github.com/pocketbase/tygoja/test/a": {"*"}, + "github.com/pocketbase/tygoja/test/b": {"*"}, + "github.com/pocketbase/tygoja/test/c": {"Example2", "Handler"}, + }, + Heading: `declare var $app: c.Handler; // bind other fields `, + WithPackageFunctions: true, + }) + + result, err := gen.Generate() + if err != nil { + log.Fatal(err) + } + + if err := os.WriteFile("./types.d.ts", []byte(result), 0644); err != nil { + log.Fatal(err) + } +} +``` + +You can also combine it with [typedoc](https://typedoc.org/) to create HTML/JSON docs from the generated declaration(s). + +See the package `/test` directory for example output. + +For a more detailed example you can also explore the [PocketBase's jsvm plugin](https://github.com/pocketbase/pocketbase/tree/develop/plugins/jsvm/internal/docs). + + +## Known issues and limitations + +- Multiple versions of the same package may have unexpected declaration since all versions will be under the same namespace. +- For easier generation, it relies on TypeScript declarations merging, meaning that the generated types may not be very compact. +- Package level functions and constants, that are reserved JS identifier, are prefixed with underscore (eg. `_in()`). diff --git a/config.go b/config.go new file mode 100644 index 0000000..063068a --- /dev/null +++ b/config.go @@ -0,0 +1,82 @@ +package tygoja + +const ( + defaultIndent = " " + + // custom base types that every package has access to + BaseTypeDict = "_TygojaDict" // Record type alternative as a more generic map-like type + BaseTypeAny = "_TygojaAny" // any type alias to allow easier extends generation +) + +// FieldNameFormatterFunc defines a function for formatting a field name. +type FieldNameFormatterFunc func(string) string + +// MethodNameFormatterFunc defines a function for formatting a method name. +type MethodNameFormatterFunc func(string) string + +type Config struct { + // Packages is a list of package paths just like you would import them in Go. + // Use "*" to generate all package types. + // + // Example: + // + // Packages: map[string][]string{ + // "time": {"Time"}, + // "github.com/pocketbase/pocketbase/core": {"*"}, + // } + Packages map[string][]string + + // Heading specifies a content that will be put at the top of the output declaration file. + // + // You would generally use this to import custom types or some custom TS declarations. + Heading string + + // TypeMappings specifies custom type translations. + // + // Useful for for mapping 3rd party package types, eg "unsafe.Pointer" => "CustomType". + // + // Be default unrecognized types will be recursively generated by + // traversing their import package (when possible). + TypeMappings map[string]string + + // WithConstants indicates whether to generate types for constants + // ("false" by default). + WithConstants bool + + // WithPackageFunctions indicates whether to generate types + // for package level functions ("false" by default). + WithPackageFunctions bool + + // FieldNameFormatter allows specifying a custom struct field name formatter. + FieldNameFormatter FieldNameFormatterFunc + + // MethodNameFormatter allows specifying a custom method name formatter. + MethodNameFormatter MethodNameFormatterFunc + + // StartModifier usually should be "export" or declare but as of now prevents + // the LSP autocompletion so we keep it empty. + // + // See also: + // https://github.com/microsoft/TypeScript/issues/54330 + // https://github.com/microsoft/TypeScript/pull/49644 + StartModifier string + + // Indent allow customizing the default indentation (use \t if you want tabs). + Indent string +} + +// Initializes the defaults (if not already) of the current config. +func (c *Config) InitDefaults() { + if c.Indent == "" { + c.Indent = defaultIndent + } + + if c.TypeMappings == nil { + c.TypeMappings = make(map[string]string) + } + + // special case for the unsafe package because it doesn't return its types in pkg.Syntax + if _, ok := c.TypeMappings["unsafe.Pointer"]; !ok { + c.TypeMappings["unsafe.Pointer"] = "number" + } +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..bf5bd42 --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module github.com/pocketbase/tygoja + +go 1.22.0 + +require golang.org/x/tools v0.26.0 + +require ( + golang.org/x/mod v0.21.0 // indirect + golang.org/x/sync v0.8.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..1bf208c --- /dev/null +++ b/go.sum @@ -0,0 +1,6 @@ +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= +golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= diff --git a/iota.go b/iota.go new file mode 100644 index 0000000..7710ec5 --- /dev/null +++ b/iota.go @@ -0,0 +1,38 @@ +package tygoja + +import ( + "fmt" + "strconv" + "strings" +) + +func isProbablyIotaType(groupType string) bool { + groupType = strings.Trim(groupType, "()") + return groupType == "iota" || strings.HasPrefix(groupType, "iota +") || strings.HasSuffix(groupType, "+ iota") +} + +func basicIotaOffsetValueParse(groupType string) (int, error) { + if !isProbablyIotaType(groupType) { + panic("can't parse non-iota type") + } + + groupType = strings.Trim(groupType, "()") + if groupType == "iota" { + return 0, nil + } + parts := strings.Split(groupType, " + ") + + var numPart string + if parts[0] == "iota" { + numPart = parts[1] + } else { + numPart = parts[0] + } + + addValue, err := strconv.ParseInt(numPart, 10, 64) + if err != nil { + return 0, fmt.Errorf("Failed to guesstimate initial iota value for \"%s\": %w", groupType, err) + } + + return int(addValue), nil +} diff --git a/package_generator.go b/package_generator.go new file mode 100644 index 0000000..9080a8d --- /dev/null +++ b/package_generator.go @@ -0,0 +1,104 @@ +package tygoja + +import ( + "go/ast" + "go/token" + "strings" + + "golang.org/x/tools/go/packages" +) + +// PackageGenerator is responsible for generating the code for a single input package. +type PackageGenerator struct { + conf *Config + pkg *packages.Package + types []string + withPkgDoc bool + + generatedTypes map[string]struct{} + unknownTypes map[string]struct{} + imports map[string][]string // path -> []names/aliases +} + +// Generate generates the typings for a single package. +func (g *PackageGenerator) Generate() (string, error) { + s := new(strings.Builder) + + namespace := packageNameFromPath(g.pkg.ID) + + s.WriteString("\n") + + if g.withPkgDoc { + for _, f := range g.pkg.Syntax { + if f.Doc == nil || len(f.Doc.List) == 0 { + continue + } + g.writeCommentGroup(s, f.Doc, 0) + } + } + + g.writeStartModifier(s, 0) + s.WriteString("namespace ") + s.WriteString(namespace) + s.WriteString(" {\n") + + // register the aliased imports within the package namespace + // (see https://www.typescriptlang.org/docs/handbook/namespaces.html#aliases) + loadedAliases := map[string]struct{}{} + for _, file := range g.pkg.Syntax { + for _, imp := range file.Imports { + path := strings.Trim(imp.Path.Value, `"' `) + + pgkName := packageNameFromPath(path) + alias := pgkName + + if imp.Name != nil && imp.Name.Name != "" && imp.Name.Name != "_" { + alias = imp.Name.Name + + if _, ok := loadedAliases[alias]; ok { + continue // already registered + } + + loadedAliases[alias] = struct{}{} + + g.writeIndent(s, 1) + s.WriteString("// @ts-ignore\n") + g.writeIndent(s, 1) + s.WriteString("import ") + s.WriteString(alias) + s.WriteString(" = ") + s.WriteString(pgkName) + s.WriteString("\n") + } + + // register the import to export its package later + if !exists(g.imports[path], alias) { + if g.imports[path] == nil { + g.imports[path] = []string{} + } + g.imports[path] = append(g.imports[path], alias) + } + } + + ast.Inspect(file, func(n ast.Node) bool { + switch x := n.(type) { + case *ast.FuncDecl: // FuncDecl can be package level function or struct method + g.writeFuncDecl(s, x, 1) + return false + case *ast.GenDecl: // GenDecl can be an import, type, var, or const expression + if x.Tok == token.VAR || x.Tok == token.IMPORT { + return false // ignore variables and import statements for now + } + + g.writeGroupDecl(s, x, 1) + return false + } + + return true + }) + } + + s.WriteString("}\n") + + return s.String(), nil +} diff --git a/random.go b/random.go new file mode 100644 index 0000000..f6653ea --- /dev/null +++ b/random.go @@ -0,0 +1,31 @@ +package tygoja + +import ( + mathRand "math/rand" + "time" +) + +const defaultRandomAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + +func init() { + mathRand.Seed(time.Now().UnixNano()) +} + +// PseudorandomString generates a pseudorandom string from the default +// alphabet with the specified length. +func PseudorandomString(length int) string { + return PseudorandomStringWithAlphabet(length, defaultRandomAlphabet) +} + +// PseudorandomStringWithAlphabet generates a pseudorandom string +// with the specified length and characters set. +func PseudorandomStringWithAlphabet(length int, alphabet string) string { + b := make([]byte, length) + max := len(alphabet) + + for i := range b { + b[i] = alphabet[mathRand.Intn(max)] + } + + return string(b) +} diff --git a/test/a/interfaces.go b/test/a/interfaces.go new file mode 100644 index 0000000..f687e32 --- /dev/null +++ b/test/a/interfaces.go @@ -0,0 +1,36 @@ +package a + +import "time" + +type Empty interface{} + +// unexported interface +type interfaceA[T any] interface { + // some comment + unexportedFunc() + + // some comment above the function + Method0() + + Method1() string // inline comment + + // multi + // line + // comment + Method2(argA, argB string) (T, int) + + Method3(argA int, argB ...string) (T, []string, error) +} + +// multi +// line +// comment +type InterfaceB interface { + Empty + interfaceA[int] + + // "replace" Method0 from interfaceA + Method0() + + CustomMethod() time.Time +} diff --git a/test/a/structs.go b/test/a/structs.go new file mode 100644 index 0000000..273cd9b --- /dev/null +++ b/test/a/structs.go @@ -0,0 +1,49 @@ +package a + +type unexported struct { + field0 string + Field1 string +} + +// structA comment +type structA struct { + Field1 string // after + + // multi + // line + // comment + // with union type + Field2 []byte +} + +func (s structA) method0() {} + +// method comment +func (s structA) Method1(arg1 int) {} + +func (s *structA) Method2(arg1 int, arg2 ...string) {} // after + +// structB comment +type StructB[T any] struct { + *unexported + structA + + Field3 T +} + +// StructB.Method3 comment +func (s *StructB[T]) Method3(arg1 int) (a int, b string, c error) { + return +} + +// structC with multiple mixed generic types +type StructC[A string, B, C any] struct { + Field4 A + Field5 B + Field6 C +} + +// StructC.Method4 comment +func (s *StructC[A, B, C]) Method4(arg1 A) (a B, b C, c error) { + return +} diff --git a/test/a/vars.go b/test/a/vars.go new file mode 100644 index 0000000..023d9f8 --- /dev/null +++ b/test/a/vars.go @@ -0,0 +1,76 @@ +// package a docs +// lorem ipsum dolor... +package a + +import "time" + +// ------------------------------------------------------------------- +// variables (note: currently are ignored) +// ------------------------------------------------------------------- + +var unexportedVar int = 123 + +// comment +var VarA = 123 // after + +var VarB any = "test" + +// external package type +var VarC time.Time = time.Now() + +// chan +var VarD = make(chan int) + +// composite +var VarE = map[string]func(){"test": func() {}} + +// ------------------------------------------------------------------- +// constants +// ------------------------------------------------------------------- + +const unexportedConst = "123" + +// comment +const ConstA string = "test" // after + +// multi +// line +// comment +const ConstB = 123 + +// some generic group comment +const ( + ConstC0 = iota + ConstC1 // after + ConstC2 +) + +// ------------------------------------------------------------------- +// type alias with methods +// ------------------------------------------------------------------- + +// type comment +type SliceAlias[T any] []T // after + +// func comment +func (s SliceAlias[T]) funcA() { +} + +// multi +// line +// comment +func (s SliceAlias[T]) funcB(argA, argB int) { +} + +func (s SliceAlias[T]) funcC(argA int, argB ...string) (a T, b int, c error) { + return +} + +// ------------------------------------------------------------------- +// function type +// ------------------------------------------------------------------- + +// multi +// line +// comment +type Handler[T comparable] func() (T, int) // after diff --git a/test/b/functions.go b/test/b/functions.go new file mode 100644 index 0000000..51ecf57 --- /dev/null +++ b/test/b/functions.go @@ -0,0 +1,51 @@ +// package b +package b + +func func0() {} + +// single comment +func Func1() {} + +// multi +// line +// comment +func Func2[T any](arg1 int) (a T, b error) { + return +} + +// function with multiple generic types +func Func3[A string, B, C any](arg1 A, arg2 B, arg3 int) (a A, b C) { + return +} + +// function that returns a function +func Func4(arg1 int) (a func() int) { + return a +} + +// function with ommited argument types +func Func5(arg0 string, arg1, arg2 int) { +} + +// function with reserved argument name and variadic type +func Func6(catch string, optional ...string) { +} + +// function with ommited argument names +func Func7(string, int, ...bool) { +} + +// function with named return values +func Func8() (b int, c string) { + return +} + +// function with shortened return values +func Func9() (b, c string) { + return +} + +// function with named and shortened return values +func Func10() (a int, b, c string) { + return +} diff --git a/test/c/c.go b/test/c/c.go new file mode 100644 index 0000000..dacbb73 --- /dev/null +++ b/test/c/c.go @@ -0,0 +1,59 @@ +package c + +import "time" + +// func type comment +type Handler func() string // after + +type Raw []byte + +type Example1 struct { + Name string +} + +// Example: +// +// Some +// code +// sample +type Example2 struct { + Title string + Json Raw + Bytes []byte // should be union +} + +func (e *Example1) DemoEx1() string { + return "" +} + +func (e *Example2) DemoEx2() time.Time { + return time.Time{} +} + +// Pointer as argument vs return type +func (e *Example2) DemoEx3(arg *Example1) (*Example1, error) { + return nil, nil +} + +// ommited types +func (e *Example2) DemoEx4(n1, n2, n3 string) { +} + +// ommited names +func (e *Example2) DemoEx5(string, int) { +} + +// named return values +func (e *Example2) DemoEx6() (b int, c string) { + return +} + +// shortened return values +func (e *Example2) DemoEx7() (b, c string) { + return +} + +// named and shortened return values +func (e *Example2) DemoEx8() (a int, b, c string) { + return +} diff --git a/test/htmldocs/.nojekyll b/test/htmldocs/.nojekyll new file mode 100644 index 0000000..e2ac661 --- /dev/null +++ b/test/htmldocs/.nojekyll @@ -0,0 +1 @@ +TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. \ No newline at end of file diff --git a/test/htmldocs/assets/highlight.css b/test/htmldocs/assets/highlight.css new file mode 100644 index 0000000..77e81e0 --- /dev/null +++ b/test/htmldocs/assets/highlight.css @@ -0,0 +1,85 @@ +:root { + --light-hl-0: #0000FF; + --dark-hl-0: #569CD6; + --light-hl-1: #000000; + --dark-hl-1: #D4D4D4; + --light-hl-2: #A31515; + --dark-hl-2: #CE9178; + --light-hl-3: #795E26; + --dark-hl-3: #DCDCAA; + --light-hl-4: #001080; + --dark-hl-4: #9CDCFE; + --light-hl-5: #267F99; + --dark-hl-5: #4EC9B0; + --light-hl-6: #AF00DB; + --dark-hl-6: #C586C0; + --light-hl-7: #098658; + --dark-hl-7: #B5CEA8; + --light-hl-8: #000000; + --dark-hl-8: #C8C8C8; + --light-code-background: #FFFFFF; + --dark-code-background: #1E1E1E; +} + +@media (prefers-color-scheme: light) { :root { + --hl-0: var(--light-hl-0); + --hl-1: var(--light-hl-1); + --hl-2: var(--light-hl-2); + --hl-3: var(--light-hl-3); + --hl-4: var(--light-hl-4); + --hl-5: var(--light-hl-5); + --hl-6: var(--light-hl-6); + --hl-7: var(--light-hl-7); + --hl-8: var(--light-hl-8); + --code-background: var(--light-code-background); +} } + +@media (prefers-color-scheme: dark) { :root { + --hl-0: var(--dark-hl-0); + --hl-1: var(--dark-hl-1); + --hl-2: var(--dark-hl-2); + --hl-3: var(--dark-hl-3); + --hl-4: var(--dark-hl-4); + --hl-5: var(--dark-hl-5); + --hl-6: var(--dark-hl-6); + --hl-7: var(--dark-hl-7); + --hl-8: var(--dark-hl-8); + --code-background: var(--dark-code-background); +} } + +:root[data-theme='light'] { + --hl-0: var(--light-hl-0); + --hl-1: var(--light-hl-1); + --hl-2: var(--light-hl-2); + --hl-3: var(--light-hl-3); + --hl-4: var(--light-hl-4); + --hl-5: var(--light-hl-5); + --hl-6: var(--light-hl-6); + --hl-7: var(--light-hl-7); + --hl-8: var(--light-hl-8); + --code-background: var(--light-code-background); +} + +:root[data-theme='dark'] { + --hl-0: var(--dark-hl-0); + --hl-1: var(--dark-hl-1); + --hl-2: var(--dark-hl-2); + --hl-3: var(--dark-hl-3); + --hl-4: var(--dark-hl-4); + --hl-5: var(--dark-hl-5); + --hl-6: var(--dark-hl-6); + --hl-7: var(--dark-hl-7); + --hl-8: var(--dark-hl-8); + --code-background: var(--dark-code-background); +} + +.hl-0 { color: var(--hl-0); } +.hl-1 { color: var(--hl-1); } +.hl-2 { color: var(--hl-2); } +.hl-3 { color: var(--hl-3); } +.hl-4 { color: var(--hl-4); } +.hl-5 { color: var(--hl-5); } +.hl-6 { color: var(--hl-6); } +.hl-7 { color: var(--hl-7); } +.hl-8 { color: var(--hl-8); } +pre, code { background: var(--code-background); } diff --git a/test/htmldocs/assets/main.js b/test/htmldocs/assets/main.js new file mode 100644 index 0000000..4c8fa61 --- /dev/null +++ b/test/htmldocs/assets/main.js @@ -0,0 +1,58 @@ +"use strict"; +"use strict";(()=>{var Se=Object.create;var re=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty;var Pe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Ie=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Te(e))!Qe.call(t,i)&&i!==r&&re(t,i,{get:()=>e[i],enumerable:!(n=we(e,i))||n.enumerable});return t};var Ce=(t,e,r)=>(r=t!=null?Se(ke(t)):{},Ie(e||!t||!t.__esModule?re(r,"default",{value:t,enumerable:!0}):r,t));var ae=Pe((se,oe)=>{(function(){var t=function(e){var r=new t.Builder;return r.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),r.searchPipeline.add(t.stemmer),e.call(r,r),r.build()};t.version="2.3.9";t.utils={},t.utils.warn=function(e){return function(r){e.console&&console.warn&&console.warn(r)}}(this),t.utils.asString=function(e){return e==null?"":e.toString()},t.utils.clone=function(e){if(e==null)return e;for(var r=Object.create(null),n=Object.keys(e),i=0;i0){var d=t.utils.clone(r)||{};d.position=[a,u],d.index=s.length,s.push(new t.Token(n.slice(a,o),d))}a=o+1}}return s},t.tokenizer.separator=/[\s\-]+/;t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions=Object.create(null),t.Pipeline.registerFunction=function(e,r){r in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+r),e.label=r,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var r=e.label&&e.label in this.registeredFunctions;r||t.utils.warn(`Function is not registered with pipeline. This may cause problems when serialising the index. +`,e)},t.Pipeline.load=function(e){var r=new t.Pipeline;return e.forEach(function(n){var i=t.Pipeline.registeredFunctions[n];if(i)r.add(i);else throw new Error("Cannot load unregistered function: "+n)}),r},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(r){t.Pipeline.warnIfFunctionNotRegistered(r),this._stack.push(r)},this)},t.Pipeline.prototype.after=function(e,r){t.Pipeline.warnIfFunctionNotRegistered(r);var n=this._stack.indexOf(e);if(n==-1)throw new Error("Cannot find existingFn");n=n+1,this._stack.splice(n,0,r)},t.Pipeline.prototype.before=function(e,r){t.Pipeline.warnIfFunctionNotRegistered(r);var n=this._stack.indexOf(e);if(n==-1)throw new Error("Cannot find existingFn");this._stack.splice(n,0,r)},t.Pipeline.prototype.remove=function(e){var r=this._stack.indexOf(e);r!=-1&&this._stack.splice(r,1)},t.Pipeline.prototype.run=function(e){for(var r=this._stack.length,n=0;n1&&(oe&&(n=s),o!=e);)i=n-r,s=r+Math.floor(i/2),o=this.elements[s*2];if(o==e||o>e)return s*2;if(ol?d+=2:a==l&&(r+=n[u+1]*i[d+1],u+=2,d+=2);return r},t.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},t.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),r=1,n=0;r0){var o=s.str.charAt(0),a;o in s.node.edges?a=s.node.edges[o]:(a=new t.TokenSet,s.node.edges[o]=a),s.str.length==1&&(a.final=!0),i.push({node:a,editsRemaining:s.editsRemaining,str:s.str.slice(1)})}if(s.editsRemaining!=0){if("*"in s.node.edges)var l=s.node.edges["*"];else{var l=new t.TokenSet;s.node.edges["*"]=l}if(s.str.length==0&&(l.final=!0),i.push({node:l,editsRemaining:s.editsRemaining-1,str:s.str}),s.str.length>1&&i.push({node:s.node,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)}),s.str.length==1&&(s.node.final=!0),s.str.length>=1){if("*"in s.node.edges)var u=s.node.edges["*"];else{var u=new t.TokenSet;s.node.edges["*"]=u}s.str.length==1&&(u.final=!0),i.push({node:u,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)})}if(s.str.length>1){var d=s.str.charAt(0),m=s.str.charAt(1),y;m in s.node.edges?y=s.node.edges[m]:(y=new t.TokenSet,s.node.edges[m]=y),s.str.length==1&&(y.final=!0),i.push({node:y,editsRemaining:s.editsRemaining-1,str:d+s.str.slice(2)})}}}return n},t.TokenSet.fromString=function(e){for(var r=new t.TokenSet,n=r,i=0,s=e.length;i=e;r--){var n=this.uncheckedNodes[r],i=n.child.toString();i in this.minimizedNodes?n.parent.edges[n.char]=this.minimizedNodes[i]:(n.child._str=i,this.minimizedNodes[i]=n.child),this.uncheckedNodes.pop()}};t.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},t.Index.prototype.search=function(e){return this.query(function(r){var n=new t.QueryParser(e,r);n.parse()})},t.Index.prototype.query=function(e){for(var r=new t.Query(this.fields),n=Object.create(null),i=Object.create(null),s=Object.create(null),o=Object.create(null),a=Object.create(null),l=0;l1?this._b=1:this._b=e},t.Builder.prototype.k1=function(e){this._k1=e},t.Builder.prototype.add=function(e,r){var n=e[this._ref],i=Object.keys(this._fields);this._documents[n]=r||{},this.documentCount+=1;for(var s=0;s=this.length)return t.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},t.QueryLexer.prototype.width=function(){return this.pos-this.start},t.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},t.QueryLexer.prototype.backup=function(){this.pos-=1},t.QueryLexer.prototype.acceptDigitRun=function(){var e,r;do e=this.next(),r=e.charCodeAt(0);while(r>47&&r<58);e!=t.QueryLexer.EOS&&this.backup()},t.QueryLexer.prototype.more=function(){return this.pos1&&(e.backup(),e.emit(t.QueryLexer.TERM)),e.ignore(),e.more())return t.QueryLexer.lexText},t.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.EDIT_DISTANCE),t.QueryLexer.lexText},t.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.BOOST),t.QueryLexer.lexText},t.QueryLexer.lexEOS=function(e){e.width()>0&&e.emit(t.QueryLexer.TERM)},t.QueryLexer.termSeparator=t.tokenizer.separator,t.QueryLexer.lexText=function(e){for(;;){var r=e.next();if(r==t.QueryLexer.EOS)return t.QueryLexer.lexEOS;if(r.charCodeAt(0)==92){e.escapeCharacter();continue}if(r==":")return t.QueryLexer.lexField;if(r=="~")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexEditDistance;if(r=="^")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexBoost;if(r=="+"&&e.width()===1||r=="-"&&e.width()===1)return e.emit(t.QueryLexer.PRESENCE),t.QueryLexer.lexText;if(r.match(t.QueryLexer.termSeparator))return t.QueryLexer.lexTerm}},t.QueryParser=function(e,r){this.lexer=new t.QueryLexer(e),this.query=r,this.currentClause={},this.lexemeIdx=0},t.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=t.QueryParser.parseClause;e;)e=e(this);return this.query},t.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},t.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},t.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},t.QueryParser.parseClause=function(e){var r=e.peekLexeme();if(r!=null)switch(r.type){case t.QueryLexer.PRESENCE:return t.QueryParser.parsePresence;case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var n="expected either a field or a term, found "+r.type;throw r.str.length>=1&&(n+=" with value '"+r.str+"'"),new t.QueryParseError(n,r.start,r.end)}},t.QueryParser.parsePresence=function(e){var r=e.consumeLexeme();if(r!=null){switch(r.str){case"-":e.currentClause.presence=t.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=t.Query.presence.REQUIRED;break;default:var n="unrecognised presence operator'"+r.str+"'";throw new t.QueryParseError(n,r.start,r.end)}var i=e.peekLexeme();if(i==null){var n="expecting term or field, found nothing";throw new t.QueryParseError(n,r.start,r.end)}switch(i.type){case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var n="expecting term or field, found '"+i.type+"'";throw new t.QueryParseError(n,i.start,i.end)}}},t.QueryParser.parseField=function(e){var r=e.consumeLexeme();if(r!=null){if(e.query.allFields.indexOf(r.str)==-1){var n=e.query.allFields.map(function(o){return"'"+o+"'"}).join(", "),i="unrecognised field '"+r.str+"', possible fields: "+n;throw new t.QueryParseError(i,r.start,r.end)}e.currentClause.fields=[r.str];var s=e.peekLexeme();if(s==null){var i="expecting term, found nothing";throw new t.QueryParseError(i,r.start,r.end)}switch(s.type){case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var i="expecting term, found '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseTerm=function(e){var r=e.consumeLexeme();if(r!=null){e.currentClause.term=r.str.toLowerCase(),r.str.indexOf("*")!=-1&&(e.currentClause.usePipeline=!1);var n=e.peekLexeme();if(n==null){e.nextClause();return}switch(n.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+n.type+"'";throw new t.QueryParseError(i,n.start,n.end)}}},t.QueryParser.parseEditDistance=function(e){var r=e.consumeLexeme();if(r!=null){var n=parseInt(r.str,10);if(isNaN(n)){var i="edit distance must be numeric";throw new t.QueryParseError(i,r.start,r.end)}e.currentClause.editDistance=n;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseBoost=function(e){var r=e.consumeLexeme();if(r!=null){var n=parseInt(r.str,10);if(isNaN(n)){var i="boost must be numeric";throw new t.QueryParseError(i,r.start,r.end)}e.currentClause.boost=n;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},function(e,r){typeof define=="function"&&define.amd?define(r):typeof se=="object"?oe.exports=r():e.lunr=r()}(this,function(){return t})})()});var ne=[];function G(t,e){ne.push({selector:e,constructor:t})}var U=class{constructor(){this.alwaysVisibleMember=null;this.createComponents(document.body),this.ensureActivePageVisible(),this.ensureFocusedElementVisible(),this.listenForCodeCopies(),window.addEventListener("hashchange",()=>this.ensureFocusedElementVisible())}createComponents(e){ne.forEach(r=>{e.querySelectorAll(r.selector).forEach(n=>{n.dataset.hasInstance||(new r.constructor({el:n,app:this}),n.dataset.hasInstance=String(!0))})})}filterChanged(){this.ensureFocusedElementVisible()}ensureActivePageVisible(){let e=document.querySelector(".tsd-navigation .current"),r=e?.parentElement;for(;r&&!r.classList.contains(".tsd-navigation");)r instanceof HTMLDetailsElement&&(r.open=!0),r=r.parentElement;if(e){let n=e.getBoundingClientRect().top-document.documentElement.clientHeight/4;document.querySelector(".site-menu").scrollTop=n}}ensureFocusedElementVisible(){if(this.alwaysVisibleMember&&(this.alwaysVisibleMember.classList.remove("always-visible"),this.alwaysVisibleMember.firstElementChild.remove(),this.alwaysVisibleMember=null),!location.hash)return;let e=document.getElementById(location.hash.substring(1));if(!e)return;let r=e.parentElement;for(;r&&r.tagName!=="SECTION";)r=r.parentElement;if(r&&r.offsetParent==null){this.alwaysVisibleMember=r,r.classList.add("always-visible");let n=document.createElement("p");n.classList.add("warning"),n.textContent="This member is normally hidden due to your filter settings.",r.prepend(n)}}listenForCodeCopies(){document.querySelectorAll("pre > button").forEach(e=>{let r;e.addEventListener("click",()=>{e.previousElementSibling instanceof HTMLElement&&navigator.clipboard.writeText(e.previousElementSibling.innerText.trim()),e.textContent="Copied!",e.classList.add("visible"),clearTimeout(r),r=setTimeout(()=>{e.classList.remove("visible"),r=setTimeout(()=>{e.textContent="Copy"},100)},1e3)})})}};var ie=(t,e=100)=>{let r;return()=>{clearTimeout(r),r=setTimeout(()=>t(),e)}};var ce=Ce(ae());function de(){let t=document.getElementById("tsd-search");if(!t)return;let e=document.getElementById("tsd-search-script");t.classList.add("loading"),e&&(e.addEventListener("error",()=>{t.classList.remove("loading"),t.classList.add("failure")}),e.addEventListener("load",()=>{t.classList.remove("loading"),t.classList.add("ready")}),window.searchData&&t.classList.remove("loading"));let r=document.querySelector("#tsd-search input"),n=document.querySelector("#tsd-search .results");if(!r||!n)throw new Error("The input field or the result list wrapper was not found");let i=!1;n.addEventListener("mousedown",()=>i=!0),n.addEventListener("mouseup",()=>{i=!1,t.classList.remove("has-focus")}),r.addEventListener("focus",()=>t.classList.add("has-focus")),r.addEventListener("blur",()=>{i||(i=!1,t.classList.remove("has-focus"))});let s={base:t.dataset.base+"/"};Oe(t,n,r,s)}function Oe(t,e,r,n){r.addEventListener("input",ie(()=>{Re(t,e,r,n)},200));let i=!1;r.addEventListener("keydown",s=>{i=!0,s.key=="Enter"?Fe(e,r):s.key=="Escape"?r.blur():s.key=="ArrowUp"?ue(e,-1):s.key==="ArrowDown"?ue(e,1):i=!1}),r.addEventListener("keypress",s=>{i&&s.preventDefault()}),document.body.addEventListener("keydown",s=>{s.altKey||s.ctrlKey||s.metaKey||!r.matches(":focus")&&s.key==="/"&&(r.focus(),s.preventDefault())})}function _e(t,e){t.index||window.searchData&&(e.classList.remove("loading"),e.classList.add("ready"),t.data=window.searchData,t.index=ce.Index.load(window.searchData.index))}function Re(t,e,r,n){if(_e(n,t),!n.index||!n.data)return;e.textContent="";let i=r.value.trim(),s=i?n.index.search(`*${i}*`):[];for(let o=0;oa.score-o.score);for(let o=0,a=Math.min(10,s.length);o${le(l.parent,i)}.${u}`);let d=document.createElement("li");d.classList.value=l.classes??"";let m=document.createElement("a");m.href=n.base+l.url,m.innerHTML=u,d.append(m),e.appendChild(d)}}function ue(t,e){let r=t.querySelector(".current");if(!r)r=t.querySelector(e==1?"li:first-child":"li:last-child"),r&&r.classList.add("current");else{let n=r;if(e===1)do n=n.nextElementSibling??void 0;while(n instanceof HTMLElement&&n.offsetParent==null);else do n=n.previousElementSibling??void 0;while(n instanceof HTMLElement&&n.offsetParent==null);n&&(r.classList.remove("current"),n.classList.add("current"))}}function Fe(t,e){let r=t.querySelector(".current");if(r||(r=t.querySelector("li:first-child")),r){let n=r.querySelector("a");n&&(window.location.href=n.href),e.blur()}}function le(t,e){if(e==="")return t;let r=t.toLocaleLowerCase(),n=e.toLocaleLowerCase(),i=[],s=0,o=r.indexOf(n);for(;o!=-1;)i.push(K(t.substring(s,o)),`${K(t.substring(o,o+n.length))}`),s=o+n.length,o=r.indexOf(n,s);return i.push(K(t.substring(s))),i.join("")}var Me={"&":"&","<":"<",">":">","'":"'",'"':"""};function K(t){return t.replace(/[&<>"'"]/g,e=>Me[e])}var P=class{constructor(e){this.el=e.el,this.app=e.app}};var M="mousedown",fe="mousemove",N="mouseup",J={x:0,y:0},he=!1,ee=!1,De=!1,D=!1,pe=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);document.documentElement.classList.add(pe?"is-mobile":"not-mobile");pe&&"ontouchstart"in document.documentElement&&(De=!0,M="touchstart",fe="touchmove",N="touchend");document.addEventListener(M,t=>{ee=!0,D=!1;let e=M=="touchstart"?t.targetTouches[0]:t;J.y=e.pageY||0,J.x=e.pageX||0});document.addEventListener(fe,t=>{if(ee&&!D){let e=M=="touchstart"?t.targetTouches[0]:t,r=J.x-(e.pageX||0),n=J.y-(e.pageY||0);D=Math.sqrt(r*r+n*n)>10}});document.addEventListener(N,()=>{ee=!1});document.addEventListener("click",t=>{he&&(t.preventDefault(),t.stopImmediatePropagation(),he=!1)});var X=class extends P{constructor(r){super(r);this.className=this.el.dataset.toggle||"",this.el.addEventListener(N,n=>this.onPointerUp(n)),this.el.addEventListener("click",n=>n.preventDefault()),document.addEventListener(M,n=>this.onDocumentPointerDown(n)),document.addEventListener(N,n=>this.onDocumentPointerUp(n))}setActive(r){if(this.active==r)return;this.active=r,document.documentElement.classList.toggle("has-"+this.className,r),this.el.classList.toggle("active",r);let n=(this.active?"to-has-":"from-has-")+this.className;document.documentElement.classList.add(n),setTimeout(()=>document.documentElement.classList.remove(n),500)}onPointerUp(r){D||(this.setActive(!0),r.preventDefault())}onDocumentPointerDown(r){if(this.active){if(r.target.closest(".col-sidebar, .tsd-filter-group"))return;this.setActive(!1)}}onDocumentPointerUp(r){if(!D&&this.active&&r.target.closest(".col-sidebar")){let n=r.target.closest("a");if(n){let i=window.location.href;i.indexOf("#")!=-1&&(i=i.substring(0,i.indexOf("#"))),n.href.substring(0,i.length)==i&&setTimeout(()=>this.setActive(!1),250)}}}};var te;try{te=localStorage}catch{te={getItem(){return null},setItem(){}}}var Q=te;var me=document.head.appendChild(document.createElement("style"));me.dataset.for="filters";var Y=class extends P{constructor(r){super(r);this.key=`filter-${this.el.name}`,this.value=this.el.checked,this.el.addEventListener("change",()=>{this.setLocalStorage(this.el.checked)}),this.setLocalStorage(this.fromLocalStorage()),me.innerHTML+=`html:not(.${this.key}) .tsd-is-${this.el.name} { display: none; } +`}fromLocalStorage(){let r=Q.getItem(this.key);return r?r==="true":this.el.checked}setLocalStorage(r){Q.setItem(this.key,r.toString()),this.value=r,this.handleValueChange()}handleValueChange(){this.el.checked=this.value,document.documentElement.classList.toggle(this.key,this.value),this.app.filterChanged(),document.querySelectorAll(".tsd-index-section").forEach(r=>{r.style.display="block";let n=Array.from(r.querySelectorAll(".tsd-index-link")).every(i=>i.offsetParent==null);r.style.display=n?"none":"block"})}};var Z=class extends P{constructor(r){super(r);this.summary=this.el.querySelector(".tsd-accordion-summary"),this.icon=this.summary.querySelector("svg"),this.key=`tsd-accordion-${this.summary.dataset.key??this.summary.textContent.trim().replace(/\s+/g,"-").toLowerCase()}`;let n=Q.getItem(this.key);this.el.open=n?n==="true":this.el.open,this.el.addEventListener("toggle",()=>this.update()),this.update()}update(){this.icon.style.transform=`rotate(${this.el.open?0:-90}deg)`,Q.setItem(this.key,this.el.open.toString())}};function ve(t){let e=Q.getItem("tsd-theme")||"os";t.value=e,ye(e),t.addEventListener("change",()=>{Q.setItem("tsd-theme",t.value),ye(t.value)})}function ye(t){document.documentElement.dataset.theme=t}de();G(X,"a[data-toggle]");G(Z,".tsd-index-accordion");G(Y,".tsd-filter-item input[type=checkbox]");var ge=document.getElementById("tsd-theme");ge&&ve(ge);var Ae=new U;Object.defineProperty(window,"app",{value:Ae});document.querySelectorAll("summary a").forEach(t=>{t.addEventListener("click",()=>{location.assign(t.href)})});})(); +/*! Bundled license information: + +lunr/lunr.js: + (** + * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.9 + * Copyright (C) 2020 Oliver Nightingale + * @license MIT + *) + (*! + * lunr.utils + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.Set + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.tokenizer + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.Pipeline + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.Vector + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.stemmer + * Copyright (C) 2020 Oliver Nightingale + * Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt + *) + (*! + * lunr.stopWordFilter + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.trimmer + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.TokenSet + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.Index + * Copyright (C) 2020 Oliver Nightingale + *) + (*! + * lunr.Builder + * Copyright (C) 2020 Oliver Nightingale + *) +*/ diff --git a/test/htmldocs/assets/search.js b/test/htmldocs/assets/search.js new file mode 100644 index 0000000..b5c8f69 --- /dev/null +++ b/test/htmldocs/assets/search.js @@ -0,0 +1 @@ +window.searchData = JSON.parse("{\"rows\":[{\"kind\":64,\"name\":\"$app\",\"url\":\"functions/_app.html\",\"classes\":\"\"},{\"kind\":4194304,\"name\":\"_TygojaDict\",\"url\":\"types/_TygojaDict.html\",\"classes\":\"\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/_TygojaDict.html#__type\",\"classes\":\"\",\"parent\":\"_TygojaDict\"},{\"kind\":4194304,\"name\":\"_TygojaAny\",\"url\":\"types/_TygojaAny.html\",\"classes\":\"\"},{\"kind\":4,\"name\":\"a\",\"url\":\"modules/a.html\",\"classes\":\"\"},{\"kind\":256,\"name\":\"Empty\",\"url\":\"interfaces/a.Empty.html\",\"classes\":\"\",\"parent\":\"a\"},{\"kind\":256,\"name\":\"interfaceA\",\"url\":\"interfaces/a.interfaceA.html\",\"classes\":\"\",\"parent\":\"a\"},{\"kind\":2048,\"name\":\"Method0\",\"url\":\"interfaces/a.interfaceA.html#Method0\",\"classes\":\"\",\"parent\":\"a.interfaceA\"},{\"kind\":2048,\"name\":\"Method1\",\"url\":\"interfaces/a.interfaceA.html#Method1\",\"classes\":\"\",\"parent\":\"a.interfaceA\"},{\"kind\":2048,\"name\":\"Method2\",\"url\":\"interfaces/a.interfaceA.html#Method2\",\"classes\":\"\",\"parent\":\"a.interfaceA\"},{\"kind\":2048,\"name\":\"Method3\",\"url\":\"interfaces/a.interfaceA.html#Method3\",\"classes\":\"\",\"parent\":\"a.interfaceA\"},{\"kind\":256,\"name\":\"InterfaceB\",\"url\":\"interfaces/a.InterfaceB.html\",\"classes\":\"\",\"parent\":\"a\"},{\"kind\":2048,\"name\":\"Method0\",\"url\":\"interfaces/a.InterfaceB.html#Method0\",\"classes\":\"\",\"parent\":\"a.InterfaceB\"},{\"kind\":2048,\"name\":\"CustomMethod\",\"url\":\"interfaces/a.InterfaceB.html#CustomMethod\",\"classes\":\"\",\"parent\":\"a.InterfaceB\"},{\"kind\":256,\"name\":\"unexported\",\"url\":\"interfaces/a.unexported.html\",\"classes\":\"\",\"parent\":\"a\"},{\"kind\":1024,\"name\":\"Field1\",\"url\":\"interfaces/a.unexported.html#Field1\",\"classes\":\"\",\"parent\":\"a.unexported\"},{\"kind\":256,\"name\":\"structA\",\"url\":\"interfaces/a.structA.html\",\"classes\":\"\",\"parent\":\"a\"},{\"kind\":1024,\"name\":\"Field1\",\"url\":\"interfaces/a.structA.html#Field1\",\"classes\":\"\",\"parent\":\"a.structA\"},{\"kind\":1024,\"name\":\"Field2\",\"url\":\"interfaces/a.structA.html#Field2\",\"classes\":\"\",\"parent\":\"a.structA\"},{\"kind\":2048,\"name\":\"Method1\",\"url\":\"interfaces/a.structA.html#Method1\",\"classes\":\"\",\"parent\":\"a.structA\"},{\"kind\":2048,\"name\":\"Method2\",\"url\":\"interfaces/a.structA.html#Method2\",\"classes\":\"\",\"parent\":\"a.structA\"},{\"kind\":4194304,\"name\":\"_subOLPog\",\"url\":\"types/a._subOLPog.html\",\"classes\":\"\",\"parent\":\"a\"},{\"kind\":256,\"name\":\"StructB\",\"url\":\"interfaces/a.StructB.html\",\"classes\":\"\",\"parent\":\"a\"},{\"kind\":1024,\"name\":\"Field3\",\"url\":\"interfaces/a.StructB.html#Field3\",\"classes\":\"\",\"parent\":\"a.StructB\"},{\"kind\":2048,\"name\":\"Method3\",\"url\":\"interfaces/a.StructB.html#Method3\",\"classes\":\"\",\"parent\":\"a.StructB\"},{\"kind\":1024,\"name\":\"Field1\",\"url\":\"interfaces/a.StructB.html#Field1\",\"classes\":\"tsd-is-inherited\",\"parent\":\"a.StructB\"},{\"kind\":1024,\"name\":\"Field2\",\"url\":\"interfaces/a.StructB.html#Field2\",\"classes\":\"tsd-is-inherited\",\"parent\":\"a.StructB\"},{\"kind\":2048,\"name\":\"Method1\",\"url\":\"interfaces/a.StructB.html#Method1\",\"classes\":\"tsd-is-inherited\",\"parent\":\"a.StructB\"},{\"kind\":2048,\"name\":\"Method2\",\"url\":\"interfaces/a.StructB.html#Method2\",\"classes\":\"tsd-is-inherited\",\"parent\":\"a.StructB\"},{\"kind\":256,\"name\":\"SliceAlias\",\"url\":\"interfaces/a.SliceAlias.html\",\"classes\":\"\",\"parent\":\"a\"},{\"kind\":256,\"name\":\"Handler\",\"url\":\"interfaces/a.Handler.html\",\"classes\":\"\",\"parent\":\"a\"},{\"kind\":4,\"name\":\"b\",\"url\":\"modules/b.html\",\"classes\":\"\"},{\"kind\":256,\"name\":\"Func1\",\"url\":\"interfaces/b.Func1.html\",\"classes\":\"\",\"parent\":\"b\"},{\"kind\":256,\"name\":\"Func2\",\"url\":\"interfaces/b.Func2.html\",\"classes\":\"\",\"parent\":\"b\"},{\"kind\":256,\"name\":\"Func3\",\"url\":\"interfaces/b.Func3.html\",\"classes\":\"\",\"parent\":\"b\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"interfaces/b.Func3.html#Func3.__type\",\"classes\":\"\",\"parent\":\"b.Func3.Func3\"},{\"kind\":256,\"name\":\"Func4\",\"url\":\"interfaces/b.Func4.html\",\"classes\":\"\",\"parent\":\"b\"},{\"kind\":256,\"name\":\"Func5\",\"url\":\"interfaces/b.Func5.html\",\"classes\":\"\",\"parent\":\"b\"},{\"kind\":256,\"name\":\"Func6\",\"url\":\"interfaces/b.Func6.html\",\"classes\":\"\",\"parent\":\"b\"},{\"kind\":256,\"name\":\"Func7\",\"url\":\"interfaces/b.Func7.html\",\"classes\":\"\",\"parent\":\"b\"},{\"kind\":256,\"name\":\"Func8\",\"url\":\"interfaces/b.Func8.html\",\"classes\":\"\",\"parent\":\"b\"},{\"kind\":256,\"name\":\"Func9\",\"url\":\"interfaces/b.Func9.html\",\"classes\":\"\",\"parent\":\"b\"},{\"kind\":4,\"name\":\"c\",\"url\":\"modules/c.html\",\"classes\":\"\"},{\"kind\":256,\"name\":\"Handler\",\"url\":\"interfaces/c.Handler.html\",\"classes\":\"\",\"parent\":\"c\"},{\"kind\":256,\"name\":\"Example2\",\"url\":\"interfaces/c.Example2.html\",\"classes\":\"\",\"parent\":\"c\"},{\"kind\":1024,\"name\":\"Title\",\"url\":\"interfaces/c.Example2.html#Title\",\"classes\":\"\",\"parent\":\"c.Example2\"},{\"kind\":1024,\"name\":\"Json\",\"url\":\"interfaces/c.Example2.html#Json\",\"classes\":\"\",\"parent\":\"c.Example2\"},{\"kind\":1024,\"name\":\"Bytes\",\"url\":\"interfaces/c.Example2.html#Bytes\",\"classes\":\"\",\"parent\":\"c.Example2\"},{\"kind\":2048,\"name\":\"DemoEx2\",\"url\":\"interfaces/c.Example2.html#DemoEx2\",\"classes\":\"\",\"parent\":\"c.Example2\"},{\"kind\":2048,\"name\":\"DemoEx3\",\"url\":\"interfaces/c.Example2.html#DemoEx3\",\"classes\":\"\",\"parent\":\"c.Example2\"},{\"kind\":2048,\"name\":\"DemoEx4\",\"url\":\"interfaces/c.Example2.html#DemoEx4\",\"classes\":\"\",\"parent\":\"c.Example2\"},{\"kind\":2048,\"name\":\"DemoEx5\",\"url\":\"interfaces/c.Example2.html#DemoEx5\",\"classes\":\"\",\"parent\":\"c.Example2\"},{\"kind\":2048,\"name\":\"DemoEx6\",\"url\":\"interfaces/c.Example2.html#DemoEx6\",\"classes\":\"\",\"parent\":\"c.Example2\"},{\"kind\":2048,\"name\":\"DemoEx7\",\"url\":\"interfaces/c.Example2.html#DemoEx7\",\"classes\":\"\",\"parent\":\"c.Example2\"},{\"kind\":2048,\"name\":\"DemoEx8\",\"url\":\"interfaces/c.Example2.html#DemoEx8\",\"classes\":\"\",\"parent\":\"c.Example2\"},{\"kind\":256,\"name\":\"Raw\",\"url\":\"interfaces/c.Raw.html\",\"classes\":\"\",\"parent\":\"c\"},{\"kind\":256,\"name\":\"Example1\",\"url\":\"interfaces/c.Example1.html\",\"classes\":\"\",\"parent\":\"c\"},{\"kind\":1024,\"name\":\"Name\",\"url\":\"interfaces/c.Example1.html#Name\",\"classes\":\"\",\"parent\":\"c.Example1\"},{\"kind\":2048,\"name\":\"DemoEx1\",\"url\":\"interfaces/c.Example1.html#DemoEx1\",\"classes\":\"\",\"parent\":\"c.Example1\"},{\"kind\":4,\"name\":\"time\",\"url\":\"modules/time.html\",\"classes\":\"\"},{\"kind\":256,\"name\":\"Time\",\"url\":\"interfaces/time.Time.html\",\"classes\":\"\",\"parent\":\"time\"},{\"kind\":2048,\"name\":\"String\",\"url\":\"interfaces/time.Time.html#String\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"GoString\",\"url\":\"interfaces/time.Time.html#GoString\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Format\",\"url\":\"interfaces/time.Time.html#Format\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"AppendFormat\",\"url\":\"interfaces/time.Time.html#AppendFormat\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"After\",\"url\":\"interfaces/time.Time.html#After\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Before\",\"url\":\"interfaces/time.Time.html#Before\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Compare\",\"url\":\"interfaces/time.Time.html#Compare\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Equal\",\"url\":\"interfaces/time.Time.html#Equal\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"IsZero\",\"url\":\"interfaces/time.Time.html#IsZero\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Date\",\"url\":\"interfaces/time.Time.html#Date\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Year\",\"url\":\"interfaces/time.Time.html#Year\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Month\",\"url\":\"interfaces/time.Time.html#Month\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Day\",\"url\":\"interfaces/time.Time.html#Day\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Weekday\",\"url\":\"interfaces/time.Time.html#Weekday\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"ISOWeek\",\"url\":\"interfaces/time.Time.html#ISOWeek\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Clock\",\"url\":\"interfaces/time.Time.html#Clock\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Hour\",\"url\":\"interfaces/time.Time.html#Hour\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Minute\",\"url\":\"interfaces/time.Time.html#Minute\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Second\",\"url\":\"interfaces/time.Time.html#Second\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Nanosecond\",\"url\":\"interfaces/time.Time.html#Nanosecond\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"YearDay\",\"url\":\"interfaces/time.Time.html#YearDay\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Add\",\"url\":\"interfaces/time.Time.html#Add\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Sub\",\"url\":\"interfaces/time.Time.html#Sub\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"AddDate\",\"url\":\"interfaces/time.Time.html#AddDate\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"UTC\",\"url\":\"interfaces/time.Time.html#UTC\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Local\",\"url\":\"interfaces/time.Time.html#Local\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"In\",\"url\":\"interfaces/time.Time.html#In\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Location\",\"url\":\"interfaces/time.Time.html#Location\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Zone\",\"url\":\"interfaces/time.Time.html#Zone\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"ZoneBounds\",\"url\":\"interfaces/time.Time.html#ZoneBounds\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Unix\",\"url\":\"interfaces/time.Time.html#Unix\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"UnixMilli\",\"url\":\"interfaces/time.Time.html#UnixMilli\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"UnixMicro\",\"url\":\"interfaces/time.Time.html#UnixMicro\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"UnixNano\",\"url\":\"interfaces/time.Time.html#UnixNano\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"MarshalBinary\",\"url\":\"interfaces/time.Time.html#MarshalBinary\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"UnmarshalBinary\",\"url\":\"interfaces/time.Time.html#UnmarshalBinary\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"GobEncode\",\"url\":\"interfaces/time.Time.html#GobEncode\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"GobDecode\",\"url\":\"interfaces/time.Time.html#GobDecode\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"MarshalJSON\",\"url\":\"interfaces/time.Time.html#MarshalJSON\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"UnmarshalJSON\",\"url\":\"interfaces/time.Time.html#UnmarshalJSON\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"MarshalText\",\"url\":\"interfaces/time.Time.html#MarshalText\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"UnmarshalText\",\"url\":\"interfaces/time.Time.html#UnmarshalText\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"IsDST\",\"url\":\"interfaces/time.Time.html#IsDST\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Truncate\",\"url\":\"interfaces/time.Time.html#Truncate\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":2048,\"name\":\"Round\",\"url\":\"interfaces/time.Time.html#Round\",\"classes\":\"\",\"parent\":\"time.Time\"},{\"kind\":256,\"name\":\"Month\",\"url\":\"interfaces/time.Month.html\",\"classes\":\"\",\"parent\":\"time\"},{\"kind\":2048,\"name\":\"String\",\"url\":\"interfaces/time.Month.html#String\",\"classes\":\"\",\"parent\":\"time.Month\"},{\"kind\":256,\"name\":\"Weekday\",\"url\":\"interfaces/time.Weekday.html\",\"classes\":\"\",\"parent\":\"time\"},{\"kind\":2048,\"name\":\"String\",\"url\":\"interfaces/time.Weekday.html#String\",\"classes\":\"\",\"parent\":\"time.Weekday\"},{\"kind\":256,\"name\":\"Duration\",\"url\":\"interfaces/time.Duration.html\",\"classes\":\"\",\"parent\":\"time\"},{\"kind\":2048,\"name\":\"String\",\"url\":\"interfaces/time.Duration.html#String\",\"classes\":\"\",\"parent\":\"time.Duration\"},{\"kind\":2048,\"name\":\"Nanoseconds\",\"url\":\"interfaces/time.Duration.html#Nanoseconds\",\"classes\":\"\",\"parent\":\"time.Duration\"},{\"kind\":2048,\"name\":\"Microseconds\",\"url\":\"interfaces/time.Duration.html#Microseconds\",\"classes\":\"\",\"parent\":\"time.Duration\"},{\"kind\":2048,\"name\":\"Milliseconds\",\"url\":\"interfaces/time.Duration.html#Milliseconds\",\"classes\":\"\",\"parent\":\"time.Duration\"},{\"kind\":2048,\"name\":\"Seconds\",\"url\":\"interfaces/time.Duration.html#Seconds\",\"classes\":\"\",\"parent\":\"time.Duration\"},{\"kind\":2048,\"name\":\"Minutes\",\"url\":\"interfaces/time.Duration.html#Minutes\",\"classes\":\"\",\"parent\":\"time.Duration\"},{\"kind\":2048,\"name\":\"Hours\",\"url\":\"interfaces/time.Duration.html#Hours\",\"classes\":\"\",\"parent\":\"time.Duration\"},{\"kind\":2048,\"name\":\"Truncate\",\"url\":\"interfaces/time.Duration.html#Truncate\",\"classes\":\"\",\"parent\":\"time.Duration\"},{\"kind\":2048,\"name\":\"Round\",\"url\":\"interfaces/time.Duration.html#Round\",\"classes\":\"\",\"parent\":\"time.Duration\"},{\"kind\":2048,\"name\":\"Abs\",\"url\":\"interfaces/time.Duration.html#Abs\",\"classes\":\"\",\"parent\":\"time.Duration\"},{\"kind\":256,\"name\":\"Location\",\"url\":\"interfaces/time.Location.html\",\"classes\":\"\",\"parent\":\"time\"},{\"kind\":2048,\"name\":\"String\",\"url\":\"interfaces/time.Location.html#String\",\"classes\":\"\",\"parent\":\"time.Location\"}],\"index\":{\"version\":\"2.3.9\",\"fields\":[\"name\",\"comment\"],\"fieldVectors\":[[\"name/0\",[0,44.148]],[\"comment/0\",[]],[\"name/1\",[1,44.148]],[\"comment/1\",[]],[\"name/2\",[2,39.04]],[\"comment/2\",[]],[\"name/3\",[3,44.148]],[\"comment/3\",[]],[\"name/4\",[4,44.148]],[\"comment/4\",[]],[\"name/5\",[5,44.148]],[\"comment/5\",[]],[\"name/6\",[6,44.148]],[\"comment/6\",[]],[\"name/7\",[7,39.04]],[\"comment/7\",[]],[\"name/8\",[8,35.675]],[\"comment/8\",[]],[\"name/9\",[9,35.675]],[\"comment/9\",[]],[\"name/10\",[10,39.04]],[\"comment/10\",[]],[\"name/11\",[11,44.148]],[\"comment/11\",[]],[\"name/12\",[7,39.04]],[\"comment/12\",[]],[\"name/13\",[12,44.148]],[\"comment/13\",[]],[\"name/14\",[13,44.148]],[\"comment/14\",[]],[\"name/15\",[14,35.675]],[\"comment/15\",[]],[\"name/16\",[15,44.148]],[\"comment/16\",[]],[\"name/17\",[14,35.675]],[\"comment/17\",[]],[\"name/18\",[16,39.04]],[\"comment/18\",[]],[\"name/19\",[8,35.675]],[\"comment/19\",[]],[\"name/20\",[9,35.675]],[\"comment/20\",[]],[\"name/21\",[17,44.148]],[\"comment/21\",[]],[\"name/22\",[18,44.148]],[\"comment/22\",[]],[\"name/23\",[19,44.148]],[\"comment/23\",[]],[\"name/24\",[10,39.04]],[\"comment/24\",[]],[\"name/25\",[14,35.675]],[\"comment/25\",[]],[\"name/26\",[16,39.04]],[\"comment/26\",[]],[\"name/27\",[8,35.675]],[\"comment/27\",[]],[\"name/28\",[9,35.675]],[\"comment/28\",[]],[\"name/29\",[20,44.148]],[\"comment/29\",[]],[\"name/30\",[21,39.04]],[\"comment/30\",[]],[\"name/31\",[22,44.148]],[\"comment/31\",[]],[\"name/32\",[23,44.148]],[\"comment/32\",[]],[\"name/33\",[24,44.148]],[\"comment/33\",[]],[\"name/34\",[25,44.148]],[\"comment/34\",[]],[\"name/35\",[2,39.04]],[\"comment/35\",[]],[\"name/36\",[26,44.148]],[\"comment/36\",[]],[\"name/37\",[27,44.148]],[\"comment/37\",[]],[\"name/38\",[28,44.148]],[\"comment/38\",[]],[\"name/39\",[29,44.148]],[\"comment/39\",[]],[\"name/40\",[30,44.148]],[\"comment/40\",[]],[\"name/41\",[31,44.148]],[\"comment/41\",[]],[\"name/42\",[32,44.148]],[\"comment/42\",[]],[\"name/43\",[21,39.04]],[\"comment/43\",[]],[\"name/44\",[33,44.148]],[\"comment/44\",[]],[\"name/45\",[34,44.148]],[\"comment/45\",[]],[\"name/46\",[35,44.148]],[\"comment/46\",[]],[\"name/47\",[36,44.148]],[\"comment/47\",[]],[\"name/48\",[37,44.148]],[\"comment/48\",[]],[\"name/49\",[38,44.148]],[\"comment/49\",[]],[\"name/50\",[39,44.148]],[\"comment/50\",[]],[\"name/51\",[40,44.148]],[\"comment/51\",[]],[\"name/52\",[41,44.148]],[\"comment/52\",[]],[\"name/53\",[42,44.148]],[\"comment/53\",[]],[\"name/54\",[43,44.148]],[\"comment/54\",[]],[\"name/55\",[44,44.148]],[\"comment/55\",[]],[\"name/56\",[45,44.148]],[\"comment/56\",[]],[\"name/57\",[46,44.148]],[\"comment/57\",[]],[\"name/58\",[47,44.148]],[\"comment/58\",[]],[\"name/59\",[48,39.04]],[\"comment/59\",[]],[\"name/60\",[48,39.04]],[\"comment/60\",[]],[\"name/61\",[49,31.155]],[\"comment/61\",[]],[\"name/62\",[50,44.148]],[\"comment/62\",[]],[\"name/63\",[51,44.148]],[\"comment/63\",[]],[\"name/64\",[52,44.148]],[\"comment/64\",[]],[\"name/65\",[53,44.148]],[\"comment/65\",[]],[\"name/66\",[54,44.148]],[\"comment/66\",[]],[\"name/67\",[55,44.148]],[\"comment/67\",[]],[\"name/68\",[56,44.148]],[\"comment/68\",[]],[\"name/69\",[57,44.148]],[\"comment/69\",[]],[\"name/70\",[58,44.148]],[\"comment/70\",[]],[\"name/71\",[59,44.148]],[\"comment/71\",[]],[\"name/72\",[60,39.04]],[\"comment/72\",[]],[\"name/73\",[61,44.148]],[\"comment/73\",[]],[\"name/74\",[62,39.04]],[\"comment/74\",[]],[\"name/75\",[63,44.148]],[\"comment/75\",[]],[\"name/76\",[64,44.148]],[\"comment/76\",[]],[\"name/77\",[65,44.148]],[\"comment/77\",[]],[\"name/78\",[66,44.148]],[\"comment/78\",[]],[\"name/79\",[67,44.148]],[\"comment/79\",[]],[\"name/80\",[68,44.148]],[\"comment/80\",[]],[\"name/81\",[69,44.148]],[\"comment/81\",[]],[\"name/82\",[70,44.148]],[\"comment/82\",[]],[\"name/83\",[71,44.148]],[\"comment/83\",[]],[\"name/84\",[72,44.148]],[\"comment/84\",[]],[\"name/85\",[73,44.148]],[\"comment/85\",[]],[\"name/86\",[74,44.148]],[\"comment/86\",[]],[\"name/87\",[75,44.148]],[\"comment/87\",[]],[\"name/88\",[76,39.04]],[\"comment/88\",[]],[\"name/89\",[77,44.148]],[\"comment/89\",[]],[\"name/90\",[78,44.148]],[\"comment/90\",[]],[\"name/91\",[79,44.148]],[\"comment/91\",[]],[\"name/92\",[80,44.148]],[\"comment/92\",[]],[\"name/93\",[81,44.148]],[\"comment/93\",[]],[\"name/94\",[82,44.148]],[\"comment/94\",[]],[\"name/95\",[83,44.148]],[\"comment/95\",[]],[\"name/96\",[84,44.148]],[\"comment/96\",[]],[\"name/97\",[85,44.148]],[\"comment/97\",[]],[\"name/98\",[86,44.148]],[\"comment/98\",[]],[\"name/99\",[87,44.148]],[\"comment/99\",[]],[\"name/100\",[88,44.148]],[\"comment/100\",[]],[\"name/101\",[89,44.148]],[\"comment/101\",[]],[\"name/102\",[90,44.148]],[\"comment/102\",[]],[\"name/103\",[91,44.148]],[\"comment/103\",[]],[\"name/104\",[92,39.04]],[\"comment/104\",[]],[\"name/105\",[93,39.04]],[\"comment/105\",[]],[\"name/106\",[60,39.04]],[\"comment/106\",[]],[\"name/107\",[49,31.155]],[\"comment/107\",[]],[\"name/108\",[62,39.04]],[\"comment/108\",[]],[\"name/109\",[49,31.155]],[\"comment/109\",[]],[\"name/110\",[94,44.148]],[\"comment/110\",[]],[\"name/111\",[49,31.155]],[\"comment/111\",[]],[\"name/112\",[95,44.148]],[\"comment/112\",[]],[\"name/113\",[96,44.148]],[\"comment/113\",[]],[\"name/114\",[97,44.148]],[\"comment/114\",[]],[\"name/115\",[98,44.148]],[\"comment/115\",[]],[\"name/116\",[99,44.148]],[\"comment/116\",[]],[\"name/117\",[100,44.148]],[\"comment/117\",[]],[\"name/118\",[92,39.04]],[\"comment/118\",[]],[\"name/119\",[93,39.04]],[\"comment/119\",[]],[\"name/120\",[101,44.148]],[\"comment/120\",[]],[\"name/121\",[76,39.04]],[\"comment/121\",[]],[\"name/122\",[49,31.155]],[\"comment/122\",[]]],\"invertedIndex\":[[\"__type\",{\"_index\":2,\"name\":{\"2\":{},\"35\":{}},\"comment\":{}}],[\"_subolpog\",{\"_index\":17,\"name\":{\"21\":{}},\"comment\":{}}],[\"_tygojaany\",{\"_index\":3,\"name\":{\"3\":{}},\"comment\":{}}],[\"_tygojadict\",{\"_index\":1,\"name\":{\"1\":{}},\"comment\":{}}],[\"a\",{\"_index\":4,\"name\":{\"4\":{}},\"comment\":{}}],[\"abs\",{\"_index\":101,\"name\":{\"120\":{}},\"comment\":{}}],[\"add\",{\"_index\":70,\"name\":{\"82\":{}},\"comment\":{}}],[\"adddate\",{\"_index\":72,\"name\":{\"84\":{}},\"comment\":{}}],[\"after\",{\"_index\":53,\"name\":{\"65\":{}},\"comment\":{}}],[\"app\",{\"_index\":0,\"name\":{\"0\":{}},\"comment\":{}}],[\"appendformat\",{\"_index\":52,\"name\":{\"64\":{}},\"comment\":{}}],[\"b\",{\"_index\":22,\"name\":{\"31\":{}},\"comment\":{}}],[\"before\",{\"_index\":54,\"name\":{\"66\":{}},\"comment\":{}}],[\"bytes\",{\"_index\":36,\"name\":{\"47\":{}},\"comment\":{}}],[\"c\",{\"_index\":32,\"name\":{\"42\":{}},\"comment\":{}}],[\"clock\",{\"_index\":64,\"name\":{\"76\":{}},\"comment\":{}}],[\"compare\",{\"_index\":55,\"name\":{\"67\":{}},\"comment\":{}}],[\"custommethod\",{\"_index\":12,\"name\":{\"13\":{}},\"comment\":{}}],[\"date\",{\"_index\":58,\"name\":{\"70\":{}},\"comment\":{}}],[\"day\",{\"_index\":61,\"name\":{\"73\":{}},\"comment\":{}}],[\"demoex1\",{\"_index\":47,\"name\":{\"58\":{}},\"comment\":{}}],[\"demoex2\",{\"_index\":37,\"name\":{\"48\":{}},\"comment\":{}}],[\"demoex3\",{\"_index\":38,\"name\":{\"49\":{}},\"comment\":{}}],[\"demoex4\",{\"_index\":39,\"name\":{\"50\":{}},\"comment\":{}}],[\"demoex5\",{\"_index\":40,\"name\":{\"51\":{}},\"comment\":{}}],[\"demoex6\",{\"_index\":41,\"name\":{\"52\":{}},\"comment\":{}}],[\"demoex7\",{\"_index\":42,\"name\":{\"53\":{}},\"comment\":{}}],[\"demoex8\",{\"_index\":43,\"name\":{\"54\":{}},\"comment\":{}}],[\"duration\",{\"_index\":94,\"name\":{\"110\":{}},\"comment\":{}}],[\"empty\",{\"_index\":5,\"name\":{\"5\":{}},\"comment\":{}}],[\"equal\",{\"_index\":56,\"name\":{\"68\":{}},\"comment\":{}}],[\"example1\",{\"_index\":45,\"name\":{\"56\":{}},\"comment\":{}}],[\"example2\",{\"_index\":33,\"name\":{\"44\":{}},\"comment\":{}}],[\"field1\",{\"_index\":14,\"name\":{\"15\":{},\"17\":{},\"25\":{}},\"comment\":{}}],[\"field2\",{\"_index\":16,\"name\":{\"18\":{},\"26\":{}},\"comment\":{}}],[\"field3\",{\"_index\":19,\"name\":{\"23\":{}},\"comment\":{}}],[\"format\",{\"_index\":51,\"name\":{\"63\":{}},\"comment\":{}}],[\"func1\",{\"_index\":23,\"name\":{\"32\":{}},\"comment\":{}}],[\"func2\",{\"_index\":24,\"name\":{\"33\":{}},\"comment\":{}}],[\"func3\",{\"_index\":25,\"name\":{\"34\":{}},\"comment\":{}}],[\"func4\",{\"_index\":26,\"name\":{\"36\":{}},\"comment\":{}}],[\"func5\",{\"_index\":27,\"name\":{\"37\":{}},\"comment\":{}}],[\"func6\",{\"_index\":28,\"name\":{\"38\":{}},\"comment\":{}}],[\"func7\",{\"_index\":29,\"name\":{\"39\":{}},\"comment\":{}}],[\"func8\",{\"_index\":30,\"name\":{\"40\":{}},\"comment\":{}}],[\"func9\",{\"_index\":31,\"name\":{\"41\":{}},\"comment\":{}}],[\"gobdecode\",{\"_index\":86,\"name\":{\"98\":{}},\"comment\":{}}],[\"gobencode\",{\"_index\":85,\"name\":{\"97\":{}},\"comment\":{}}],[\"gostring\",{\"_index\":50,\"name\":{\"62\":{}},\"comment\":{}}],[\"handler\",{\"_index\":21,\"name\":{\"30\":{},\"43\":{}},\"comment\":{}}],[\"hour\",{\"_index\":65,\"name\":{\"77\":{}},\"comment\":{}}],[\"hours\",{\"_index\":100,\"name\":{\"117\":{}},\"comment\":{}}],[\"in\",{\"_index\":75,\"name\":{\"87\":{}},\"comment\":{}}],[\"interfacea\",{\"_index\":6,\"name\":{\"6\":{}},\"comment\":{}}],[\"interfaceb\",{\"_index\":11,\"name\":{\"11\":{}},\"comment\":{}}],[\"isdst\",{\"_index\":91,\"name\":{\"103\":{}},\"comment\":{}}],[\"isoweek\",{\"_index\":63,\"name\":{\"75\":{}},\"comment\":{}}],[\"iszero\",{\"_index\":57,\"name\":{\"69\":{}},\"comment\":{}}],[\"json\",{\"_index\":35,\"name\":{\"46\":{}},\"comment\":{}}],[\"local\",{\"_index\":74,\"name\":{\"86\":{}},\"comment\":{}}],[\"location\",{\"_index\":76,\"name\":{\"88\":{},\"121\":{}},\"comment\":{}}],[\"marshalbinary\",{\"_index\":83,\"name\":{\"95\":{}},\"comment\":{}}],[\"marshaljson\",{\"_index\":87,\"name\":{\"99\":{}},\"comment\":{}}],[\"marshaltext\",{\"_index\":89,\"name\":{\"101\":{}},\"comment\":{}}],[\"method0\",{\"_index\":7,\"name\":{\"7\":{},\"12\":{}},\"comment\":{}}],[\"method1\",{\"_index\":8,\"name\":{\"8\":{},\"19\":{},\"27\":{}},\"comment\":{}}],[\"method2\",{\"_index\":9,\"name\":{\"9\":{},\"20\":{},\"28\":{}},\"comment\":{}}],[\"method3\",{\"_index\":10,\"name\":{\"10\":{},\"24\":{}},\"comment\":{}}],[\"microseconds\",{\"_index\":96,\"name\":{\"113\":{}},\"comment\":{}}],[\"milliseconds\",{\"_index\":97,\"name\":{\"114\":{}},\"comment\":{}}],[\"minute\",{\"_index\":66,\"name\":{\"78\":{}},\"comment\":{}}],[\"minutes\",{\"_index\":99,\"name\":{\"116\":{}},\"comment\":{}}],[\"month\",{\"_index\":60,\"name\":{\"72\":{},\"106\":{}},\"comment\":{}}],[\"name\",{\"_index\":46,\"name\":{\"57\":{}},\"comment\":{}}],[\"nanosecond\",{\"_index\":68,\"name\":{\"80\":{}},\"comment\":{}}],[\"nanoseconds\",{\"_index\":95,\"name\":{\"112\":{}},\"comment\":{}}],[\"raw\",{\"_index\":44,\"name\":{\"55\":{}},\"comment\":{}}],[\"round\",{\"_index\":93,\"name\":{\"105\":{},\"119\":{}},\"comment\":{}}],[\"second\",{\"_index\":67,\"name\":{\"79\":{}},\"comment\":{}}],[\"seconds\",{\"_index\":98,\"name\":{\"115\":{}},\"comment\":{}}],[\"slicealias\",{\"_index\":20,\"name\":{\"29\":{}},\"comment\":{}}],[\"string\",{\"_index\":49,\"name\":{\"61\":{},\"107\":{},\"109\":{},\"111\":{},\"122\":{}},\"comment\":{}}],[\"structa\",{\"_index\":15,\"name\":{\"16\":{}},\"comment\":{}}],[\"structb\",{\"_index\":18,\"name\":{\"22\":{}},\"comment\":{}}],[\"sub\",{\"_index\":71,\"name\":{\"83\":{}},\"comment\":{}}],[\"time\",{\"_index\":48,\"name\":{\"59\":{},\"60\":{}},\"comment\":{}}],[\"title\",{\"_index\":34,\"name\":{\"45\":{}},\"comment\":{}}],[\"truncate\",{\"_index\":92,\"name\":{\"104\":{},\"118\":{}},\"comment\":{}}],[\"unexported\",{\"_index\":13,\"name\":{\"14\":{}},\"comment\":{}}],[\"unix\",{\"_index\":79,\"name\":{\"91\":{}},\"comment\":{}}],[\"unixmicro\",{\"_index\":81,\"name\":{\"93\":{}},\"comment\":{}}],[\"unixmilli\",{\"_index\":80,\"name\":{\"92\":{}},\"comment\":{}}],[\"unixnano\",{\"_index\":82,\"name\":{\"94\":{}},\"comment\":{}}],[\"unmarshalbinary\",{\"_index\":84,\"name\":{\"96\":{}},\"comment\":{}}],[\"unmarshaljson\",{\"_index\":88,\"name\":{\"100\":{}},\"comment\":{}}],[\"unmarshaltext\",{\"_index\":90,\"name\":{\"102\":{}},\"comment\":{}}],[\"utc\",{\"_index\":73,\"name\":{\"85\":{}},\"comment\":{}}],[\"weekday\",{\"_index\":62,\"name\":{\"74\":{},\"108\":{}},\"comment\":{}}],[\"year\",{\"_index\":59,\"name\":{\"71\":{}},\"comment\":{}}],[\"yearday\",{\"_index\":69,\"name\":{\"81\":{}},\"comment\":{}}],[\"zone\",{\"_index\":77,\"name\":{\"89\":{}},\"comment\":{}}],[\"zonebounds\",{\"_index\":78,\"name\":{\"90\":{}},\"comment\":{}}]],\"pipeline\":[]}}"); \ No newline at end of file diff --git a/test/htmldocs/assets/style.css b/test/htmldocs/assets/style.css new file mode 100644 index 0000000..18b4f8f --- /dev/null +++ b/test/htmldocs/assets/style.css @@ -0,0 +1,1367 @@ +:root { + /* Light */ + --light-color-background: #f2f4f8; + --light-color-background-secondary: #eff0f1; + --light-color-warning-text: #222; + --light-color-background-warning: #e6e600; + --light-color-icon-background: var(--light-color-background); + --light-color-accent: #c5c7c9; + --light-color-active-menu-item: var(--light-color-accent); + --light-color-text: #222; + --light-color-text-aside: #6e6e6e; + --light-color-link: #1f70c2; + + --light-color-ts-project: #b111c9; + --light-color-ts-module: var(--light-color-ts-project); + --light-color-ts-namespace: var(--light-color-ts-project); + --light-color-ts-enum: #7e6f15; + --light-color-ts-enum-member: var(--light-color-ts-enum); + --light-color-ts-variable: #4760ec; + --light-color-ts-function: #572be7; + --light-color-ts-class: #1f70c2; + --light-color-ts-interface: #108024; + --light-color-ts-constructor: var(--light-color-ts-class); + --light-color-ts-property: var(--light-color-ts-variable); + --light-color-ts-method: var(--light-color-ts-function); + --light-color-ts-call-signature: var(--light-color-ts-method); + --light-color-ts-index-signature: var(--light-color-ts-property); + --light-color-ts-constructor-signature: var(--light-color-ts-constructor); + --light-color-ts-parameter: var(--light-color-ts-variable); + /* type literal not included as links will never be generated to it */ + --light-color-ts-type-parameter: var(--light-color-ts-type-alias); + --light-color-ts-accessor: var(--light-color-ts-property); + --light-color-ts-get-signature: var(--light-color-ts-accessor); + --light-color-ts-set-signature: var(--light-color-ts-accessor); + /* object literal not included as it is not used and will be removed in 0.25 */ + --light-color-ts-type-alias: #d51270; + /* reference not included as links will be colored with the kind that it points to */ + + --light-external-icon: url("data:image/svg+xml;utf8,"); + --light-color-scheme: light; + + /* Dark */ + --dark-color-background: #2b2e33; + --dark-color-background-secondary: #1e2024; + --dark-color-background-warning: #bebe00; + --dark-color-warning-text: #222; + --dark-color-icon-background: var(--dark-color-background-secondary); + --dark-color-accent: #9096a2; + --dark-color-active-menu-item: #5d5d6a; + --dark-color-text: #f5f5f5; + --dark-color-text-aside: #dddddd; + --dark-color-link: #00aff4; + + --dark-color-ts-project: #e358ff; + --dark-color-ts-module: var(--dark-color-ts-project); + --dark-color-ts-namespace: var(--dark-color-ts-project); + --dark-color-ts-enum: #f4d93e; + --dark-color-ts-enum-member: var(--dark-color-ts-enum); + --dark-color-ts-variable: #798dff; + --dark-color-ts-function: #a280ff; + --dark-color-ts-class: #8ac4ff; + --dark-color-ts-interface: #6cff87; + --dark-color-ts-constructor: var(--dark-color-ts-class); + --dark-color-ts-property: var(--dark-color-ts-variable); + --dark-color-ts-method: var(--dark-color-ts-function); + --dark-color-ts-call-signature: var(--dark-color-ts-method); + --dark-color-ts-index-signature: var(--dark-color-ts-property); + --dark-color-ts-constructor-signature: var(--dark-color-ts-constructor); + --dark-color-ts-parameter: var(--dark-color-ts-variable); + /* type literal not included as links will never be generated to it */ + --dark-color-ts-type-parameter: var(--dark-color-ts-type-alias); + --dark-color-ts-accessor: var(--dark-color-ts-property); + --dark-color-ts-get-signature: var(--dark-color-ts-accessor); + --dark-color-ts-set-signature: var(--dark-color-ts-accessor); + /* object literal not included as it is not used and will be removed in 0.25 */ + --dark-color-ts-type-alias: #ff6492; + /* reference not included as links will be colored with the kind that it points to */ + + --dark-external-icon: url("data:image/svg+xml;utf8,"); + --dark-color-scheme: dark; +} + +@media (prefers-color-scheme: light) { + :root { + --color-background: var(--light-color-background); + --color-background-secondary: var(--light-color-background-secondary); + --color-background-warning: var(--light-color-background-warning); + --color-warning-text: var(--light-color-warning-text); + --color-icon-background: var(--light-color-icon-background); + --color-accent: var(--light-color-accent); + --color-active-menu-item: var(--light-color-active-menu-item); + --color-text: var(--light-color-text); + --color-text-aside: var(--light-color-text-aside); + --color-link: var(--light-color-link); + + --color-ts-module: var(--light-color-ts-module); + --color-ts-namespace: var(--light-color-ts-namespace); + --color-ts-enum: var(--light-color-ts-enum); + --color-ts-enum-member: var(--light-color-ts-enum-member); + --color-ts-variable: var(--light-color-ts-variable); + --color-ts-function: var(--light-color-ts-function); + --color-ts-class: var(--light-color-ts-class); + --color-ts-interface: var(--light-color-ts-interface); + --color-ts-constructor: var(--light-color-ts-constructor); + --color-ts-property: var(--light-color-ts-property); + --color-ts-method: var(--light-color-ts-method); + --color-ts-call-signature: var(--light-color-ts-call-signature); + --color-ts-index-signature: var(--light-color-ts-index-signature); + --color-ts-constructor-signature: var( + --light-color-ts-constructor-signature + ); + --color-ts-parameter: var(--light-color-ts-parameter); + --color-ts-type-parameter: var(--light-color-ts-type-parameter); + --color-ts-accessor: var(--light-color-ts-accessor); + --color-ts-get-signature: var(--light-color-ts-get-signature); + --color-ts-set-signature: var(--light-color-ts-set-signature); + --color-ts-type-alias: var(--light-color-ts-type-alias); + + --external-icon: var(--light-external-icon); + --color-scheme: var(--light-color-scheme); + } +} + +@media (prefers-color-scheme: dark) { + :root { + --color-background: var(--dark-color-background); + --color-background-secondary: var(--dark-color-background-secondary); + --color-background-warning: var(--dark-color-background-warning); + --color-warning-text: var(--dark-color-warning-text); + --color-icon-background: var(--dark-color-icon-background); + --color-accent: var(--dark-color-accent); + --color-active-menu-item: var(--dark-color-active-menu-item); + --color-text: var(--dark-color-text); + --color-text-aside: var(--dark-color-text-aside); + --color-link: var(--dark-color-link); + + --color-ts-module: var(--dark-color-ts-module); + --color-ts-namespace: var(--dark-color-ts-namespace); + --color-ts-enum: var(--dark-color-ts-enum); + --color-ts-enum-member: var(--dark-color-ts-enum-member); + --color-ts-variable: var(--dark-color-ts-variable); + --color-ts-function: var(--dark-color-ts-function); + --color-ts-class: var(--dark-color-ts-class); + --color-ts-interface: var(--dark-color-ts-interface); + --color-ts-constructor: var(--dark-color-ts-constructor); + --color-ts-property: var(--dark-color-ts-property); + --color-ts-method: var(--dark-color-ts-method); + --color-ts-call-signature: var(--dark-color-ts-call-signature); + --color-ts-index-signature: var(--dark-color-ts-index-signature); + --color-ts-constructor-signature: var( + --dark-color-ts-constructor-signature + ); + --color-ts-parameter: var(--dark-color-ts-parameter); + --color-ts-type-parameter: var(--dark-color-ts-type-parameter); + --color-ts-accessor: var(--dark-color-ts-accessor); + --color-ts-get-signature: var(--dark-color-ts-get-signature); + --color-ts-set-signature: var(--dark-color-ts-set-signature); + --color-ts-type-alias: var(--dark-color-ts-type-alias); + + --external-icon: var(--dark-external-icon); + --color-scheme: var(--dark-color-scheme); + } +} + +html { + color-scheme: var(--color-scheme); +} + +body { + margin: 0; +} + +:root[data-theme="light"] { + --color-background: var(--light-color-background); + --color-background-secondary: var(--light-color-background-secondary); + --color-background-warning: var(--light-color-background-warning); + --color-warning-text: var(--light-color-warning-text); + --color-icon-background: var(--light-color-icon-background); + --color-accent: var(--light-color-accent); + --color-active-menu-item: var(--light-color-active-menu-item); + --color-text: var(--light-color-text); + --color-text-aside: var(--light-color-text-aside); + --color-link: var(--light-color-link); + + --color-ts-module: var(--light-color-ts-module); + --color-ts-namespace: var(--light-color-ts-namespace); + --color-ts-enum: var(--light-color-ts-enum); + --color-ts-enum-member: var(--light-color-ts-enum-member); + --color-ts-variable: var(--light-color-ts-variable); + --color-ts-function: var(--light-color-ts-function); + --color-ts-class: var(--light-color-ts-class); + --color-ts-interface: var(--light-color-ts-interface); + --color-ts-constructor: var(--light-color-ts-constructor); + --color-ts-property: var(--light-color-ts-property); + --color-ts-method: var(--light-color-ts-method); + --color-ts-call-signature: var(--light-color-ts-call-signature); + --color-ts-index-signature: var(--light-color-ts-index-signature); + --color-ts-constructor-signature: var( + --light-color-ts-constructor-signature + ); + --color-ts-parameter: var(--light-color-ts-parameter); + --color-ts-type-parameter: var(--light-color-ts-type-parameter); + --color-ts-accessor: var(--light-color-ts-accessor); + --color-ts-get-signature: var(--light-color-ts-get-signature); + --color-ts-set-signature: var(--light-color-ts-set-signature); + --color-ts-type-alias: var(--light-color-ts-type-alias); + + --external-icon: var(--light-external-icon); + --color-scheme: var(--light-color-scheme); +} + +:root[data-theme="dark"] { + --color-background: var(--dark-color-background); + --color-background-secondary: var(--dark-color-background-secondary); + --color-background-warning: var(--dark-color-background-warning); + --color-warning-text: var(--dark-color-warning-text); + --color-icon-background: var(--dark-color-icon-background); + --color-accent: var(--dark-color-accent); + --color-active-menu-item: var(--dark-color-active-menu-item); + --color-text: var(--dark-color-text); + --color-text-aside: var(--dark-color-text-aside); + --color-link: var(--dark-color-link); + + --color-ts-module: var(--dark-color-ts-module); + --color-ts-namespace: var(--dark-color-ts-namespace); + --color-ts-enum: var(--dark-color-ts-enum); + --color-ts-enum-member: var(--dark-color-ts-enum-member); + --color-ts-variable: var(--dark-color-ts-variable); + --color-ts-function: var(--dark-color-ts-function); + --color-ts-class: var(--dark-color-ts-class); + --color-ts-interface: var(--dark-color-ts-interface); + --color-ts-constructor: var(--dark-color-ts-constructor); + --color-ts-property: var(--dark-color-ts-property); + --color-ts-method: var(--dark-color-ts-method); + --color-ts-call-signature: var(--dark-color-ts-call-signature); + --color-ts-index-signature: var(--dark-color-ts-index-signature); + --color-ts-constructor-signature: var( + --dark-color-ts-constructor-signature + ); + --color-ts-parameter: var(--dark-color-ts-parameter); + --color-ts-type-parameter: var(--dark-color-ts-type-parameter); + --color-ts-accessor: var(--dark-color-ts-accessor); + --color-ts-get-signature: var(--dark-color-ts-get-signature); + --color-ts-set-signature: var(--dark-color-ts-set-signature); + --color-ts-type-alias: var(--dark-color-ts-type-alias); + + --external-icon: var(--dark-external-icon); + --color-scheme: var(--dark-color-scheme); +} + +.always-visible, +.always-visible .tsd-signatures { + display: inherit !important; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + line-height: 1.2; +} + +h1 > a, +h2 > a, +h3 > a, +h4 > a, +h5 > a, +h6 > a { + text-decoration: none; + color: var(--color-text); +} + +h1 { + font-size: 1.875rem; + margin: 0.67rem 0; +} + +h2 { + font-size: 1.5rem; + margin: 0.83rem 0; +} + +h3 { + font-size: 1.25rem; + margin: 1rem 0; +} + +h4 { + font-size: 1.05rem; + margin: 1.33rem 0; +} + +h5 { + font-size: 1rem; + margin: 1.5rem 0; +} + +h6 { + font-size: 0.875rem; + margin: 2.33rem 0; +} + +.uppercase { + text-transform: uppercase; +} + +dl, +menu, +ol, +ul { + margin: 1em 0; +} + +dd { + margin: 0 0 0 40px; +} + +.container { + max-width: 1700px; + padding: 0 2rem; +} + +/* Footer */ +.tsd-generator { + border-top: 1px solid var(--color-accent); + padding-top: 1rem; + padding-bottom: 1rem; + max-height: 3.5rem; +} + +.tsd-generator > p { + margin-top: 0; + margin-bottom: 0; + padding: 0 1rem; +} + +.container-main { + margin: 0 auto; + /* toolbar, footer, margin */ + min-height: calc(100vh - 41px - 56px - 4rem); +} + +@keyframes fade-in { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +@keyframes fade-out { + from { + opacity: 1; + visibility: visible; + } + to { + opacity: 0; + } +} +@keyframes fade-in-delayed { + 0% { + opacity: 0; + } + 33% { + opacity: 0; + } + 100% { + opacity: 1; + } +} +@keyframes fade-out-delayed { + 0% { + opacity: 1; + visibility: visible; + } + 66% { + opacity: 0; + } + 100% { + opacity: 0; + } +} +@keyframes pop-in-from-right { + from { + transform: translate(100%, 0); + } + to { + transform: translate(0, 0); + } +} +@keyframes pop-out-to-right { + from { + transform: translate(0, 0); + visibility: visible; + } + to { + transform: translate(100%, 0); + } +} +body { + background: var(--color-background); + font-family: "Segoe UI", sans-serif; + font-size: 16px; + color: var(--color-text); +} + +a { + color: var(--color-link); + text-decoration: none; +} +a:hover { + text-decoration: underline; +} +a.external[target="_blank"] { + background-image: var(--external-icon); + background-position: top 3px right; + background-repeat: no-repeat; + padding-right: 13px; +} + +code, +pre { + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; + padding: 0.2em; + margin: 0; + font-size: 0.875rem; + border-radius: 0.8em; +} + +pre { + position: relative; + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; + padding: 10px; + border: 1px solid var(--color-accent); +} +pre code { + padding: 0; + font-size: 100%; +} +pre > button { + position: absolute; + top: 10px; + right: 10px; + opacity: 0; + transition: opacity 0.1s; + box-sizing: border-box; +} +pre:hover > button, +pre > button.visible { + opacity: 1; +} + +blockquote { + margin: 1em 0; + padding-left: 1em; + border-left: 4px solid gray; +} + +.tsd-typography { + line-height: 1.333em; +} +.tsd-typography ul { + list-style: square; + padding: 0 0 0 20px; + margin: 0; +} +.tsd-typography h4, +.tsd-typography .tsd-index-panel h3, +.tsd-index-panel .tsd-typography h3, +.tsd-typography h5, +.tsd-typography h6 { + font-size: 1em; + margin: 0; +} +.tsd-typography h5, +.tsd-typography h6 { + font-weight: normal; +} +.tsd-typography p, +.tsd-typography ul, +.tsd-typography ol { + margin: 1em 0; +} + +.tsd-breadcrumb { + margin: 0; + padding: 0; + color: var(--color-text-aside); +} +.tsd-breadcrumb a { + color: var(--color-text-aside); + text-decoration: none; +} +.tsd-breadcrumb a:hover { + text-decoration: underline; +} +.tsd-breadcrumb li { + display: inline; +} +.tsd-breadcrumb li:after { + content: " / "; +} + +.tsd-comment-tags { + display: flex; + flex-direction: column; +} +dl.tsd-comment-tag-group { + display: flex; + align-items: center; + overflow: hidden; + margin: 0.5em 0; +} +dl.tsd-comment-tag-group dt { + display: flex; + margin-right: 0.5em; + font-size: 0.875em; + font-weight: normal; +} +dl.tsd-comment-tag-group dd { + margin: 0; +} +code.tsd-tag { + padding: 0.25em 0.4em; + border: 0.1em solid var(--color-accent); + margin-right: 0.25em; + font-size: 70%; +} +h1 code.tsd-tag:first-of-type { + margin-left: 0.25em; +} + +dl.tsd-comment-tag-group dd:before, +dl.tsd-comment-tag-group dd:after { + content: " "; +} +dl.tsd-comment-tag-group dd pre, +dl.tsd-comment-tag-group dd:after { + clear: both; +} +dl.tsd-comment-tag-group p { + margin: 0; +} + +.tsd-panel.tsd-comment .lead { + font-size: 1.1em; + line-height: 1.333em; + margin-bottom: 2em; +} +.tsd-panel.tsd-comment .lead:last-child { + margin-bottom: 0; +} + +.tsd-filter-visibility h4 { + font-size: 1rem; + padding-top: 0.75rem; + padding-bottom: 0.5rem; + margin: 0; +} +.tsd-filter-item:not(:last-child) { + margin-bottom: 0.5rem; +} +.tsd-filter-input { + display: flex; + width: fit-content; + width: -moz-fit-content; + align-items: center; + user-select: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + cursor: pointer; +} +.tsd-filter-input input[type="checkbox"] { + cursor: pointer; + position: absolute; + width: 1.5em; + height: 1.5em; + opacity: 0; +} +.tsd-filter-input input[type="checkbox"]:disabled { + pointer-events: none; +} +.tsd-filter-input svg { + cursor: pointer; + width: 1.5em; + height: 1.5em; + margin-right: 0.5em; + border-radius: 0.33em; + /* Leaving this at full opacity breaks event listeners on Firefox. + Don't remove unless you know what you're doing. */ + opacity: 0.99; +} +.tsd-filter-input input[type="checkbox"]:focus + svg { + transform: scale(0.95); +} +.tsd-filter-input input[type="checkbox"]:focus:not(:focus-visible) + svg { + transform: scale(1); +} +.tsd-checkbox-background { + fill: var(--color-accent); +} +input[type="checkbox"]:checked ~ svg .tsd-checkbox-checkmark { + stroke: var(--color-text); +} +.tsd-filter-input input:disabled ~ svg > .tsd-checkbox-background { + fill: var(--color-background); + stroke: var(--color-accent); + stroke-width: 0.25rem; +} +.tsd-filter-input input:disabled ~ svg > .tsd-checkbox-checkmark { + stroke: var(--color-accent); +} + +.tsd-theme-toggle { + padding-top: 0.75rem; +} +.tsd-theme-toggle > h4 { + display: inline; + vertical-align: middle; + margin-right: 0.75rem; +} + +.tsd-hierarchy { + list-style: square; + margin: 0; +} +.tsd-hierarchy .target { + font-weight: bold; +} + +.tsd-panel-group.tsd-index-group { + margin-bottom: 0; +} +.tsd-index-panel .tsd-index-list { + list-style: none; + line-height: 1.333em; + margin: 0; + padding: 0.25rem 0 0 0; + overflow: hidden; + display: grid; + grid-template-columns: repeat(3, 1fr); + column-gap: 1rem; + grid-template-rows: auto; +} +@media (max-width: 1024px) { + .tsd-index-panel .tsd-index-list { + grid-template-columns: repeat(2, 1fr); + } +} +@media (max-width: 768px) { + .tsd-index-panel .tsd-index-list { + grid-template-columns: repeat(1, 1fr); + } +} +.tsd-index-panel .tsd-index-list li { + -webkit-page-break-inside: avoid; + -moz-page-break-inside: avoid; + -ms-page-break-inside: avoid; + -o-page-break-inside: avoid; + page-break-inside: avoid; +} + +.tsd-flag { + display: inline-block; + padding: 0.25em 0.4em; + border-radius: 4px; + color: var(--color-comment-tag-text); + background-color: var(--color-comment-tag); + text-indent: 0; + font-size: 75%; + line-height: 1; + font-weight: normal; +} + +.tsd-anchor { + position: relative; + top: -100px; +} + +.tsd-member { + position: relative; +} +.tsd-member .tsd-anchor + h3 { + display: flex; + align-items: center; + margin-top: 0; + margin-bottom: 0; + border-bottom: none; +} + +.tsd-navigation.settings { + margin: 1rem 0; +} +.tsd-navigation > a, +.tsd-navigation .tsd-accordion-summary { + width: calc(100% - 0.5rem); +} +.tsd-navigation a, +.tsd-navigation summary > span, +.tsd-page-navigation a { + display: inline-flex; + align-items: center; + padding: 0.25rem; + color: var(--color-text); + text-decoration: none; + box-sizing: border-box; +} +.tsd-navigation a.current, +.tsd-page-navigation a.current { + background: var(--color-active-menu-item); +} +.tsd-navigation a:hover, +.tsd-page-navigation a:hover { + text-decoration: underline; +} +.tsd-navigation ul, +.tsd-page-navigation ul { + margin-top: 0; + margin-bottom: 0; + padding: 0; + list-style: none; +} +.tsd-navigation li, +.tsd-page-navigation li { + padding: 0; + max-width: 100%; +} +.tsd-nested-navigation { + margin-left: 3rem; +} +.tsd-nested-navigation > li > details { + margin-left: -1.5rem; +} +.tsd-small-nested-navigation { + margin-left: 1.5rem; +} +.tsd-small-nested-navigation > li > details { + margin-left: -1.5rem; +} + +.tsd-nested-navigation > li > a, +.tsd-nested-navigation > li > span { + width: calc(100% - 1.75rem - 0.5rem); +} + +.tsd-page-navigation ul { + padding-left: 1.75rem; +} + +#tsd-sidebar-links a { + margin-top: 0; + margin-bottom: 0.5rem; + line-height: 1.25rem; +} +#tsd-sidebar-links a:last-of-type { + margin-bottom: 0; +} + +a.tsd-index-link { + padding: 0.25rem 0 !important; + font-size: 1rem; + line-height: 1.25rem; + display: inline-flex; + align-items: center; + color: var(--color-text); +} +.tsd-accordion-summary { + list-style-type: none; /* hide marker on non-safari */ + outline: none; /* broken on safari, so just hide it */ +} +.tsd-accordion-summary::-webkit-details-marker { + display: none; /* hide marker on safari */ +} +.tsd-accordion-summary, +.tsd-accordion-summary a { + user-select: none; + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + + cursor: pointer; +} +.tsd-accordion-summary a { + width: calc(100% - 1.5rem); +} +.tsd-accordion-summary > * { + margin-top: 0; + margin-bottom: 0; + padding-top: 0; + padding-bottom: 0; +} +.tsd-index-accordion .tsd-accordion-summary > svg { + margin-left: 0.25rem; +} +.tsd-index-content > :not(:first-child) { + margin-top: 0.75rem; +} +.tsd-index-heading { + margin-top: 1.5rem; + margin-bottom: 0.75rem; +} + +.tsd-kind-icon { + margin-right: 0.5rem; + width: 1.25rem; + height: 1.25rem; + min-width: 1.25rem; + min-height: 1.25rem; +} +.tsd-kind-icon path { + transform-origin: center; + transform: scale(1.1); +} +.tsd-signature > .tsd-kind-icon { + margin-right: 0.8rem; +} + +.tsd-panel { + margin-bottom: 2.5rem; +} +.tsd-panel.tsd-member { + margin-bottom: 4rem; +} +.tsd-panel:empty { + display: none; +} +.tsd-panel > h1, +.tsd-panel > h2, +.tsd-panel > h3 { + margin: 1.5rem -1.5rem 0.75rem -1.5rem; + padding: 0 1.5rem 0.75rem 1.5rem; +} +.tsd-panel > h1.tsd-before-signature, +.tsd-panel > h2.tsd-before-signature, +.tsd-panel > h3.tsd-before-signature { + margin-bottom: 0; + border-bottom: none; +} + +.tsd-panel-group { + margin: 4rem 0; +} +.tsd-panel-group.tsd-index-group { + margin: 2rem 0; +} +.tsd-panel-group.tsd-index-group details { + margin: 2rem 0; +} + +#tsd-search { + transition: background-color 0.2s; +} +#tsd-search .title { + position: relative; + z-index: 2; +} +#tsd-search .field { + position: absolute; + left: 0; + top: 0; + right: 2.5rem; + height: 100%; +} +#tsd-search .field input { + box-sizing: border-box; + position: relative; + top: -50px; + z-index: 1; + width: 100%; + padding: 0 10px; + opacity: 0; + outline: 0; + border: 0; + background: transparent; + color: var(--color-text); +} +#tsd-search .field label { + position: absolute; + overflow: hidden; + right: -40px; +} +#tsd-search .field input, +#tsd-search .title, +#tsd-toolbar-links a { + transition: opacity 0.2s; +} +#tsd-search .results { + position: absolute; + visibility: hidden; + top: 40px; + width: 100%; + margin: 0; + padding: 0; + list-style: none; + box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); +} +#tsd-search .results li { + padding: 0 10px; + background-color: var(--color-background); +} +#tsd-search .results li:nth-child(even) { + background-color: var(--color-background-secondary); +} +#tsd-search .results li.state { + display: none; +} +#tsd-search .results li.current, +#tsd-search .results li:hover { + background-color: var(--color-accent); +} +#tsd-search .results a { + display: block; +} +#tsd-search .results a:before { + top: 10px; +} +#tsd-search .results span.parent { + color: var(--color-text-aside); + font-weight: normal; +} +#tsd-search.has-focus { + background-color: var(--color-accent); +} +#tsd-search.has-focus .field input { + top: 0; + opacity: 1; +} +#tsd-search.has-focus .title, +#tsd-search.has-focus #tsd-toolbar-links a { + z-index: 0; + opacity: 0; +} +#tsd-search.has-focus .results { + visibility: visible; +} +#tsd-search.loading .results li.state.loading { + display: block; +} +#tsd-search.failure .results li.state.failure { + display: block; +} + +#tsd-toolbar-links { + position: absolute; + top: 0; + right: 2rem; + height: 100%; + display: flex; + align-items: center; + justify-content: flex-end; +} +#tsd-toolbar-links a { + margin-left: 1.5rem; +} +#tsd-toolbar-links a:hover { + text-decoration: underline; +} + +.tsd-signature { + margin: 0 0 1rem 0; + padding: 1rem 0.5rem; + border: 1px solid var(--color-accent); + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; + font-size: 14px; + overflow-x: auto; +} + +.tsd-signature-symbol { + color: var(--color-text-aside); + font-weight: normal; +} + +.tsd-signature-type { + font-style: italic; + font-weight: normal; +} + +.tsd-signatures { + padding: 0; + margin: 0 0 1em 0; + list-style-type: none; +} +.tsd-signatures .tsd-signature { + margin: 0; + border-color: var(--color-accent); + border-width: 1px 0; + transition: background-color 0.1s; +} +.tsd-description .tsd-signatures .tsd-signature { + border-width: 1px; +} + +ul.tsd-parameter-list, +ul.tsd-type-parameter-list { + list-style: square; + margin: 0; + padding-left: 20px; +} +ul.tsd-parameter-list > li.tsd-parameter-signature, +ul.tsd-type-parameter-list > li.tsd-parameter-signature { + list-style: none; + margin-left: -20px; +} +ul.tsd-parameter-list h5, +ul.tsd-type-parameter-list h5 { + font-size: 16px; + margin: 1em 0 0.5em 0; +} +.tsd-sources { + margin-top: 1rem; + font-size: 0.875em; +} +.tsd-sources a { + color: var(--color-text-aside); + text-decoration: underline; +} +.tsd-sources ul { + list-style: none; + padding: 0; +} + +.tsd-page-toolbar { + position: sticky; + z-index: 1; + top: 0; + left: 0; + width: 100%; + color: var(--color-text); + background: var(--color-background-secondary); + border-bottom: 1px var(--color-accent) solid; + transition: transform 0.3s ease-in-out; +} +.tsd-page-toolbar a { + color: var(--color-text); + text-decoration: none; +} +.tsd-page-toolbar a.title { + font-weight: bold; +} +.tsd-page-toolbar a.title:hover { + text-decoration: underline; +} +.tsd-page-toolbar .tsd-toolbar-contents { + display: flex; + justify-content: space-between; + height: 2.5rem; + margin: 0 auto; +} +.tsd-page-toolbar .table-cell { + position: relative; + white-space: nowrap; + line-height: 40px; +} +.tsd-page-toolbar .table-cell:first-child { + width: 100%; +} +.tsd-page-toolbar .tsd-toolbar-icon { + box-sizing: border-box; + line-height: 0; + padding: 12px 0; +} + +.tsd-widget { + display: inline-block; + overflow: hidden; + opacity: 0.8; + height: 40px; + transition: opacity 0.1s, background-color 0.2s; + vertical-align: bottom; + cursor: pointer; +} +.tsd-widget:hover { + opacity: 0.9; +} +.tsd-widget.active { + opacity: 1; + background-color: var(--color-accent); +} +.tsd-widget.no-caption { + width: 40px; +} +.tsd-widget.no-caption:before { + margin: 0; +} + +.tsd-widget.options, +.tsd-widget.menu { + display: none; +} +input[type="checkbox"] + .tsd-widget:before { + background-position: -120px 0; +} +input[type="checkbox"]:checked + .tsd-widget:before { + background-position: -160px 0; +} + +img { + max-width: 100%; +} + +.tsd-anchor-icon { + display: inline-flex; + align-items: center; + margin-left: 0.5rem; + vertical-align: middle; + color: var(--color-text); +} + +.tsd-anchor-icon svg { + width: 1em; + height: 1em; + visibility: hidden; +} + +.tsd-anchor-link:hover > .tsd-anchor-icon svg { + visibility: visible; +} + +.deprecated { + text-decoration: line-through; +} + +.warning { + padding: 1rem; + color: var(--color-warning-text); + background: var(--color-background-warning); +} + +.tsd-kind-project { + color: var(--color-ts-project); +} +.tsd-kind-module { + color: var(--color-ts-module); +} +.tsd-kind-namespace { + color: var(--color-ts-namespace); +} +.tsd-kind-enum { + color: var(--color-ts-enum); +} +.tsd-kind-enum-member { + color: var(--color-ts-enum-member); +} +.tsd-kind-variable { + color: var(--color-ts-variable); +} +.tsd-kind-function { + color: var(--color-ts-function); +} +.tsd-kind-class { + color: var(--color-ts-class); +} +.tsd-kind-interface { + color: var(--color-ts-interface); +} +.tsd-kind-constructor { + color: var(--color-ts-constructor); +} +.tsd-kind-property { + color: var(--color-ts-property); +} +.tsd-kind-method { + color: var(--color-ts-method); +} +.tsd-kind-call-signature { + color: var(--color-ts-call-signature); +} +.tsd-kind-index-signature { + color: var(--color-ts-index-signature); +} +.tsd-kind-constructor-signature { + color: var(--color-ts-constructor-signature); +} +.tsd-kind-parameter { + color: var(--color-ts-parameter); +} +.tsd-kind-type-literal { + color: var(--color-ts-type-literal); +} +.tsd-kind-type-parameter { + color: var(--color-ts-type-parameter); +} +.tsd-kind-accessor { + color: var(--color-ts-accessor); +} +.tsd-kind-get-signature { + color: var(--color-ts-get-signature); +} +.tsd-kind-set-signature { + color: var(--color-ts-set-signature); +} +.tsd-kind-type-alias { + color: var(--color-ts-type-alias); +} + +/* if we have a kind icon, don't color the text by kind */ +.tsd-kind-icon ~ span { + color: var(--color-text); +} + +* { + scrollbar-width: thin; + scrollbar-color: var(--color-accent) var(--color-icon-background); +} + +*::-webkit-scrollbar { + width: 0.75rem; +} + +*::-webkit-scrollbar-track { + background: var(--color-icon-background); +} + +*::-webkit-scrollbar-thumb { + background-color: var(--color-accent); + border-radius: 999rem; + border: 0.25rem solid var(--color-icon-background); +} + +/* mobile */ +@media (max-width: 769px) { + .tsd-widget.options, + .tsd-widget.menu { + display: inline-block; + } + + .container-main { + display: flex; + } + html .col-content { + float: none; + max-width: 100%; + width: 100%; + } + html .col-sidebar { + position: fixed !important; + overflow-y: auto; + -webkit-overflow-scrolling: touch; + z-index: 1024; + top: 0 !important; + bottom: 0 !important; + left: auto !important; + right: 0 !important; + padding: 1.5rem 1.5rem 0 0; + width: 75vw; + visibility: hidden; + background-color: var(--color-background); + transform: translate(100%, 0); + } + html .col-sidebar > *:last-child { + padding-bottom: 20px; + } + html .overlay { + content: ""; + display: block; + position: fixed; + z-index: 1023; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(0, 0, 0, 0.75); + visibility: hidden; + } + + .to-has-menu .overlay { + animation: fade-in 0.4s; + } + + .to-has-menu .col-sidebar { + animation: pop-in-from-right 0.4s; + } + + .from-has-menu .overlay { + animation: fade-out 0.4s; + } + + .from-has-menu .col-sidebar { + animation: pop-out-to-right 0.4s; + } + + .has-menu body { + overflow: hidden; + } + .has-menu .overlay { + visibility: visible; + } + .has-menu .col-sidebar { + visibility: visible; + transform: translate(0, 0); + display: flex; + flex-direction: column; + gap: 1.5rem; + max-height: 100vh; + padding: 1rem 2rem; + } + .has-menu .tsd-navigation { + max-height: 100%; + } +} + +/* one sidebar */ +@media (min-width: 770px) { + .container-main { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); + grid-template-areas: "sidebar content"; + margin: 2rem auto; + } + + .col-sidebar { + grid-area: sidebar; + } + .col-content { + grid-area: content; + padding: 0 1rem; + } +} +@media (min-width: 770px) and (max-width: 1399px) { + .col-sidebar { + max-height: calc(100vh - 2rem - 42px); + overflow: auto; + position: sticky; + top: 42px; + padding-top: 1rem; + } + .site-menu { + margin-top: 1rem; + } +} + +/* two sidebars */ +@media (min-width: 1200px) { + .container-main { + grid-template-columns: minmax(0, 1fr) minmax(0, 2.5fr) minmax(0, 20rem); + grid-template-areas: "sidebar content toc"; + } + + .col-sidebar { + display: contents; + } + + .page-menu { + grid-area: toc; + padding-left: 1rem; + } + .site-menu { + grid-area: sidebar; + } + + .site-menu { + margin-top: 1rem 0; + } + + .page-menu, + .site-menu { + max-height: calc(100vh - 2rem - 42px); + overflow: auto; + position: sticky; + top: 42px; + } +} diff --git a/test/htmldocs/functions/_app.html b/test/htmldocs/functions/_app.html new file mode 100644 index 0000000..be5b5f2 --- /dev/null +++ b/test/htmldocs/functions/_app.html @@ -0,0 +1,52 @@ +$app | Documentation
+
+ +
+
+
+
+ +

Function $app

+
+
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/index.html b/test/htmldocs/index.html new file mode 100644 index 0000000..768b4ee --- /dev/null +++ b/test/htmldocs/index.html @@ -0,0 +1,91 @@ +Documentation
+
+ +
+
+
+
+

Documentation

+

(EXP) tygoja +GoDoc

tygoja is a small helper library for generating TypeScript declarations from Go code.

+

The generated typings are intended to be used as import helpers to provide ambient TypeScript declarations (aka. .d.ts) for goja bindings.

+
+

⚠️ Don't use it directly in production! It is not tagged and may change without notice.

+

It was created to semi-automate the documentation of the goja integration for PocketBase.

+

Use it only as a reference or as a non-critical step in your dev pipeline.

+
+

tygoja is a heavily modified fork of tygo and extends its scope with:

+
    +
  • custom field and method names formatters
  • +
  • types for interfaces (exported and unexported)
  • +
  • types for exported interface methods
  • +
  • types for exported struct methods
  • +
  • types for exported package level functions (must enable PackageConfig.WithPackageFunctions)
  • +
  • inheritance declarations for embeded structs (embedded pointers are treated as values)
  • +
  • autoloading all unmapped argument and return types (when possible)
  • +
  • applying the same goja's rules when resolving the return types of exported function and methods
  • +
  • combining multiple packages typings in a single output
  • +
  • generating all declarations in namespaces with the packages name (both unmapped and mapped)
  • +
  • preserving comment block new lines
  • +
  • converting Go comment code blocks to Markdown code blocks
  • +
  • and others...
  • +
+

Note that by default the generated typings are not generated with export since the intended usage is to map them to your custom goja bindings. +This mapping could be defined in the Config.Heading field usually with the declare keyword (eg. declare let someGojaProp: app.Cache).

+

Example

package main

import (
"log"
"os"

"github.com/pocketbase/tygoja"
)

func main() {
gen := tygoja.New(tygoja.Config{
Packages: map[string][]string{
"github.com/pocketbase/tygoja/test/a": {"*"},
"github.com/pocketbase/tygoja/test/b": {"*"},
"github.com/pocketbase/tygoja/test/c": {"Example2", "Handler"},
},
Heading: `declare var $app: c.Handler; // bind other fields `,
WithPackageFunctions: true,
})

result, err := gen.Generate()
if err != nil {
log.Fatal(err)
}

if err := os.WriteFile("./types.d.ts", []byte(result), 0644); err != nil {
log.Fatal(err)
}
} +
+

You can also combine it with typedoc to create HTML/JSON docs from the generated declaration(s).

+

See the package /test directory for example output.

+

For a more detailed example you can also explore the PocketBase's jsvm plugin.

+

Known issues and limitations

    +
  • Multiple versions of the same package may have unexpected declaration since all versions will be under the same namespace.
  • +
  • For easier generation, it relies on TypeScript declarations merging, meaning that the generated types may not be very compact.
  • +
  • Package level functions and constants, that are reserved JS identifier, are prefixed with underscore (eg. _in()).
  • +
+
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/a.Empty.html b/test/htmldocs/interfaces/a.Empty.html new file mode 100644 index 0000000..ff19714 --- /dev/null +++ b/test/htmldocs/interfaces/a.Empty.html @@ -0,0 +1,67 @@ +Empty | Documentation
+
+ +
+
+
+
+ +

Interface Empty

+
+

Hierarchy

+
    +
  • Empty
+
+

Indexable

+
[key: string]: any
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/a.Handler.html b/test/htmldocs/interfaces/a.Handler.html new file mode 100644 index 0000000..78556a7 --- /dev/null +++ b/test/htmldocs/interfaces/a.Handler.html @@ -0,0 +1,80 @@ +Handler | Documentation
+
+ +
+
+
+
+ +

Interface Handler<T>

+
+

multi +line +comment

+
+
+
+

Type Parameters

+
    +
  • +

    T

+
+

Hierarchy

+
    +
  • Handler
+
+
    + +
  • +

    Returns [T, number]

+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/a.InterfaceB.html b/test/htmldocs/interfaces/a.InterfaceB.html new file mode 100644 index 0000000..305e5e2 --- /dev/null +++ b/test/htmldocs/interfaces/a.InterfaceB.html @@ -0,0 +1,110 @@ +InterfaceB | Documentation
+
+ +
+
+
+
+ +

Interface InterfaceB

+
+

multi +line +comment

+
+
+
+

Hierarchy

+
    +
  • InterfaceB
+
+

Indexable

+
[key: string]: any
+
+
+
+ +
+
+

Methods

+
+
+

Methods

+
+ +
+
+ +
    + +
  • +

    "replace" Method0 from interfaceA

    +
    +

    Returns void

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/a.SliceAlias.html b/test/htmldocs/interfaces/a.SliceAlias.html new file mode 100644 index 0000000..788bdd0 --- /dev/null +++ b/test/htmldocs/interfaces/a.SliceAlias.html @@ -0,0 +1,1000 @@ +SliceAlias | Documentation
+
+ +
+
+
+
+ +

Interface SliceAlias<T>

+
+

type comment

+
+
+
+

Type Parameters

+
    +
  • +

    T

+
+

Hierarchy

+
    +
  • Array<T> +
      +
    • SliceAlias
+
+
+
+ +
+
+

Properties

+
+ +
length: number
+

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

+
+
+
+

Methods

+
+ +
    + +
  • +

    Combines two or more arrays. +This method returns a new array without modifying any existing arrays.

    +
    +
    +

    Parameters

    +
      +
    • +
      Rest ...items: ConcatArray<T>[]
      +

      Additional arrays and/or items to add to the end of the array.

      +
      +
    +

    Returns T[]

    +
  • + +
  • +

    Combines two or more arrays. +This method returns a new array without modifying any existing arrays.

    +
    +
    +

    Parameters

    +
      +
    • +
      Rest ...items: (T | ConcatArray<T>)[]
      +

      Additional arrays and/or items to add to the end of the array.

      +
      +
    +

    Returns T[]

    +
+
+ +
    + +
  • +

    Determines whether all the members of an array satisfy the specified test.

    +
    +
    +

    Type Parameters

    +
      +
    • +

      S

    +
    +

    Parameters

    +
      +
    • +
      predicate: ((value, index, array) => value is S)
      +

      A function that accepts up to three arguments. The every method calls +the predicate function for each element in the array until the predicate returns a value +which is coercible to the Boolean value false, or until the end of the array.

      +
      +
      +
        +
      • +
          +
        • (value, index, array): value is S
        • +
        • +
          +

          Parameters

          +
            +
          • +
            value: T
          • +
          • +
            index: number
          • +
          • +
            array: T[]
          +

          Returns value is S

    • +
    • +
      Optional thisArg: any
      +

      An object to which the this keyword can refer in the predicate function. +If thisArg is omitted, undefined is used as the this value.

      +
      +
    +

    Returns this is S[]

    +
  • + +
  • +

    Determines whether all the members of an array satisfy the specified test.

    +
    +
    +

    Parameters

    +
      +
    • +
      predicate: ((value, index, array) => unknown)
      +

      A function that accepts up to three arguments. The every method calls +the predicate function for each element in the array until the predicate returns a value +which is coercible to the Boolean value false, or until the end of the array.

      +
      +
      +
        +
      • +
          +
        • (value, index, array): unknown
        • +
        • +
          +

          Parameters

          +
            +
          • +
            value: T
          • +
          • +
            index: number
          • +
          • +
            array: T[]
          +

          Returns unknown

    • +
    • +
      Optional thisArg: any
      +

      An object to which the this keyword can refer in the predicate function. +If thisArg is omitted, undefined is used as the this value.

      +
      +
    +

    Returns boolean

    +
+
+ +
    + +
  • +

    Returns the elements of an array that meet the condition specified in a callback function.

    +
    +
    +

    Type Parameters

    +
      +
    • +

      S

    +
    +

    Parameters

    +
      +
    • +
      predicate: ((value, index, array) => value is S)
      +

      A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (value, index, array): value is S
        • +
        • +
          +

          Parameters

          +
            +
          • +
            value: T
          • +
          • +
            index: number
          • +
          • +
            array: T[]
          +

          Returns value is S

    • +
    • +
      Optional thisArg: any
      +

      An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.

      +
      +
    +

    Returns S[]

    +
  • + +
  • +

    Returns the elements of an array that meet the condition specified in a callback function.

    +
    +
    +

    Parameters

    +
      +
    • +
      predicate: ((value, index, array) => unknown)
      +

      A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (value, index, array): unknown
        • +
        • +
          +

          Parameters

          +
            +
          • +
            value: T
          • +
          • +
            index: number
          • +
          • +
            array: T[]
          +

          Returns unknown

    • +
    • +
      Optional thisArg: any
      +

      An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.

      +
      +
    +

    Returns T[]

    +
+
+ +
    + +
  • +

    Performs the specified action for each element in an array.

    +
    +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((value, index, array) => void)
      +

      A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (value, index, array): void
        • +
        • +
          +

          Parameters

          +
            +
          • +
            value: T
          • +
          • +
            index: number
          • +
          • +
            array: T[]
          +

          Returns void

    • +
    • +
      Optional thisArg: any
      +

      An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

      +
      +
    +

    Returns void

    +
+
+ +
    + +
  • +

    Returns the index of the first occurrence of a value in an array, or -1 if it is not present.

    +
    +
    +

    Parameters

    +
      +
    • +
      searchElement: T
      +

      The value to locate in the array.

      +
      +
    • +
    • +
      Optional fromIndex: number
      +

      The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.

      +
      +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Adds all the elements of an array into a string, separated by the specified separator string.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional separator: string
      +

      A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns the index of the last occurrence of a specified value in an array, or -1 if it is not present.

    +
    +
    +

    Parameters

    +
      +
    • +
      searchElement: T
      +

      The value to locate in the array.

      +
      +
    • +
    • +
      Optional fromIndex: number
      +

      The array index at which to begin searching backward. If fromIndex is omitted, the search starts at the last index in the array.

      +
      +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Calls a defined callback function on each element of an array, and returns an array that contains the results.

    +
    +
    +

    Type Parameters

    +
      +
    • +

      U

    +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((value, index, array) => U)
      +

      A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (value, index, array): U
        • +
        • +
          +

          Parameters

          +
            +
          • +
            value: T
          • +
          • +
            index: number
          • +
          • +
            array: T[]
          +

          Returns U

    • +
    • +
      Optional thisArg: any
      +

      An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

      +
      +
    +

    Returns U[]

    +
+
+ +
    + +
  • +

    Removes the last element from an array and returns it. +If the array is empty, undefined is returned and the array is not modified.

    +
    +

    Returns T

    +
+
+ +
    + +
  • +

    Appends new elements to the end of an array, and returns the new length of the array.

    +
    +
    +

    Parameters

    +
      +
    • +
      Rest ...items: T[]
      +

      New elements to add to the array.

      +
      +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    +
    +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((previousValue, currentValue, currentIndex, array) => T)
      +

      A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (previousValue, currentValue, currentIndex, array): T
        • +
        • +
          +

          Parameters

          +
            +
          • +
            previousValue: T
          • +
          • +
            currentValue: T
          • +
          • +
            currentIndex: number
          • +
          • +
            array: T[]
          +

          Returns T

    +

    Returns T

    +
  • + +
  • +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((previousValue, currentValue, currentIndex, array) => T)
      +
        +
      • +
          +
        • (previousValue, currentValue, currentIndex, array): T
        • +
        • +
          +

          Parameters

          +
            +
          • +
            previousValue: T
          • +
          • +
            currentValue: T
          • +
          • +
            currentIndex: number
          • +
          • +
            array: T[]
          +

          Returns T

    • +
    • +
      initialValue: T
    +

    Returns T

  • + +
  • +

    Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    +
    +
    +

    Type Parameters

    +
      +
    • +

      U

    +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((previousValue, currentValue, currentIndex, array) => U)
      +

      A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (previousValue, currentValue, currentIndex, array): U
        • +
        • +
          +

          Parameters

          +
            +
          • +
            previousValue: U
          • +
          • +
            currentValue: T
          • +
          • +
            currentIndex: number
          • +
          • +
            array: T[]
          +

          Returns U

    • +
    • +
      initialValue: U
      +

      If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.

      +
      +
    +

    Returns U

    +
+
+ +
    + +
  • +

    Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    +
    +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((previousValue, currentValue, currentIndex, array) => T)
      +

      A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (previousValue, currentValue, currentIndex, array): T
        • +
        • +
          +

          Parameters

          +
            +
          • +
            previousValue: T
          • +
          • +
            currentValue: T
          • +
          • +
            currentIndex: number
          • +
          • +
            array: T[]
          +

          Returns T

    +

    Returns T

    +
  • + +
  • +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((previousValue, currentValue, currentIndex, array) => T)
      +
        +
      • +
          +
        • (previousValue, currentValue, currentIndex, array): T
        • +
        • +
          +

          Parameters

          +
            +
          • +
            previousValue: T
          • +
          • +
            currentValue: T
          • +
          • +
            currentIndex: number
          • +
          • +
            array: T[]
          +

          Returns T

    • +
    • +
      initialValue: T
    +

    Returns T

  • + +
  • +

    Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    +
    +
    +

    Type Parameters

    +
      +
    • +

      U

    +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((previousValue, currentValue, currentIndex, array) => U)
      +

      A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (previousValue, currentValue, currentIndex, array): U
        • +
        • +
          +

          Parameters

          +
            +
          • +
            previousValue: U
          • +
          • +
            currentValue: T
          • +
          • +
            currentIndex: number
          • +
          • +
            array: T[]
          +

          Returns U

    • +
    • +
      initialValue: U
      +

      If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.

      +
      +
    +

    Returns U

    +
+
+ +
    + +
  • +

    Reverses the elements in an array in place. +This method mutates the array and returns a reference to the same array.

    +
    +

    Returns T[]

    +
+
+ +
    + +
  • +

    Removes the first element from an array and returns it. +If the array is empty, undefined is returned and the array is not modified.

    +
    +

    Returns T

    +
+
+ +
    + +
  • +

    Returns a copy of a section of an array. +For both start and end, a negative index can be used to indicate an offset from the end of the array. +For example, -2 refers to the second to last element of the array.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional start: number
      +

      The beginning index of the specified portion of the array. +If start is undefined, then the slice begins at index 0.

      +
      +
    • +
    • +
      Optional end: number
      +

      The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. +If end is undefined, then the slice extends to the end of the array.

      +
      +
    +

    Returns T[]

    +
+
+ +
    + +
  • +

    Determines whether the specified callback function returns true for any element of an array.

    +
    +
    +

    Parameters

    +
      +
    • +
      predicate: ((value, index, array) => unknown)
      +

      A function that accepts up to three arguments. The some method calls +the predicate function for each element in the array until the predicate returns a value +which is coercible to the Boolean value true, or until the end of the array.

      +
      +
      +
        +
      • +
          +
        • (value, index, array): unknown
        • +
        • +
          +

          Parameters

          +
            +
          • +
            value: T
          • +
          • +
            index: number
          • +
          • +
            array: T[]
          +

          Returns unknown

    • +
    • +
      Optional thisArg: any
      +

      An object to which the this keyword can refer in the predicate function. +If thisArg is omitted, undefined is used as the this value.

      +
      +
    +

    Returns boolean

    +
+
+ +
    + +
  • +

    Sorts an array in place. +This method mutates the array and returns a reference to the same array.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional compareFn: ((a, b) => number)
      +

      Function used to determine the order of the elements. It is expected to return +a negative value if the first argument is less than the second argument, zero if they're equal, and a positive +value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.

      +
      [11,2,22,1].sort((a, b) => a - b)
      +
      +
      +
      +
        +
      • +
          +
        • (a, b): number
        • +
        • +
          +

          Parameters

          +
            +
          • +
            a: T
          • +
          • +
            b: T
          +

          Returns number

    +

    Returns SliceAlias<T>

    +
+
+ +
    + +
  • +

    Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.

    +
    +
    +

    Parameters

    +
      +
    • +
      start: number
      +

      The zero-based location in the array from which to start removing elements.

      +
      +
    • +
    • +
      Optional deleteCount: number
      +

      The number of elements to remove.

      +
      +
    +

    Returns T[]

    An array containing the elements that were deleted.

    + +
  • + +
  • +

    Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.

    +
    +
    +

    Parameters

    +
      +
    • +
      start: number
      +

      The zero-based location in the array from which to start removing elements.

      +
      +
    • +
    • +
      deleteCount: number
      +

      The number of elements to remove.

      +
      +
    • +
    • +
      Rest ...items: T[]
      +

      Elements to insert into the array in place of the deleted elements.

      +
      +
    +

    Returns T[]

    An array containing the elements that were deleted.

    + +
+
+ +
    + +
  • +

    Returns a string representation of an array. The elements are converted to string using their toLocaleString methods.

    +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns a string representation of an array.

    +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Inserts new elements at the start of an array, and returns the new length of the array.

    +
    +
    +

    Parameters

    +
      +
    • +
      Rest ...items: T[]
      +

      Elements to insert at the start of the array.

      +
      +
    +

    Returns number

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/a.StructB.html b/test/htmldocs/interfaces/a.StructB.html new file mode 100644 index 0000000..7643882 --- /dev/null +++ b/test/htmldocs/interfaces/a.StructB.html @@ -0,0 +1,177 @@ +StructB | Documentation
+
+ +
+
+
+
+ +

Interface StructB<T>

+
+

structB comment

+
+
+
+

Type Parameters

+
    +
  • +

    T

+
+

Hierarchy

+
+
+
+
+ +
+
+

Properties

+
+
+

Methods

+
+
+

Properties

+
+ +
Field1: string
+
+ +
Field2: string | number[]
+

multi +line +comment +with union type

+
+
+
+ +
Field3: T
+
+

Methods

+
+ +
    + +
  • +

    method comment

    +
    +
    +

    Parameters

    +
      +
    • +
      arg1: number
    +

    Returns void

    +
+
+ +
    + +
  • +
    +

    Parameters

    +
      +
    • +
      arg1: number
    • +
    • +
      Rest ...arg2: string[]
    +

    Returns void

+
+ +
    + +
  • +
    +

    Parameters

    +
      +
    • +
      arg1: number
    +

    Returns [number, string]

+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/a.interfaceA.html b/test/htmldocs/interfaces/a.interfaceA.html new file mode 100644 index 0000000..cad940f --- /dev/null +++ b/test/htmldocs/interfaces/a.interfaceA.html @@ -0,0 +1,152 @@ +interfaceA | Documentation
+
+ +
+
+
+
+ +

Interface interfaceA<T>

+
+

unexported interface

+
+
+
+

Type Parameters

+
    +
  • +

    T

+
+

Hierarchy

+
    +
  • interfaceA
+
+

Indexable

+
[key: string]: any
+
+
+
+ +
+
+

Methods

+
+
+

Methods

+
+ +
    + +
  • +

    some comment above the function

    +
    +

    Returns void

    +
+
+ +
    + +
  • +

    Returns string

+
+ +
    + +
  • +

    multi +line +comment

    +
    +
    +

    Parameters

    +
      +
    • +
      argA: string
    • +
    • +
      argB: string
    +

    Returns [T, number]

    +
+
+ +
    + +
  • +
    +

    Parameters

    +
      +
    • +
      argA: number
    • +
    • +
      Rest ...argB: string[]
    +

    Returns [T, string[]]

+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/a.structA.html b/test/htmldocs/interfaces/a.structA.html new file mode 100644 index 0000000..6d40c82 --- /dev/null +++ b/test/htmldocs/interfaces/a.structA.html @@ -0,0 +1,144 @@ +structA | Documentation
+
+ +
+
+
+
+ +

Interface structA

+
+

structA comment

+
+
+
+

Hierarchy

+
    +
  • structA
+
+
+
+ +
+
+

Properties

+
+
+

Methods

+
+
+

Properties

+
+ +
Field1: string
+
+ +
Field2: string | number[]
+

multi +line +comment +with union type

+
+
+
+

Methods

+
+ +
    + +
  • +

    method comment

    +
    +
    +

    Parameters

    +
      +
    • +
      arg1: number
    +

    Returns void

    +
+
+ +
    + +
  • +
    +

    Parameters

    +
      +
    • +
      arg1: number
    • +
    • +
      Rest ...arg2: string[]
    +

    Returns void

+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/a.unexported.html b/test/htmldocs/interfaces/a.unexported.html new file mode 100644 index 0000000..b1b8ae4 --- /dev/null +++ b/test/htmldocs/interfaces/a.unexported.html @@ -0,0 +1,85 @@ +unexported | Documentation
+
+ +
+
+
+
+ +

Interface unexported

+
+

Hierarchy

+
    +
  • unexported
+
+
+
+ +
+
+

Properties

+
+
+

Properties

+
+ +
Field1: string
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/b.Func1.html b/test/htmldocs/interfaces/b.Func1.html new file mode 100644 index 0000000..6f4dce7 --- /dev/null +++ b/test/htmldocs/interfaces/b.Func1.html @@ -0,0 +1,72 @@ +Func1 | Documentation
+
+ +
+
+
+
+ +

Interface Func1

+
+

Hierarchy

+
    +
  • Func1
+
+
    + +
  • +

    single comment

    +
    +

    Returns void

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/b.Func2.html b/test/htmldocs/interfaces/b.Func2.html new file mode 100644 index 0000000..9e74e53 --- /dev/null +++ b/test/htmldocs/interfaces/b.Func2.html @@ -0,0 +1,84 @@ +Func2 | Documentation
+
+ +
+
+
+
+ +

Interface Func2<T>

+
+

Type Parameters

+
    +
  • +

    T

+
+

Hierarchy

+
    +
  • Func2
+
+
    + +
  • +

    multi +line +comment

    +
    +
    +

    Parameters

    +
      +
    • +
      arg1: number
    +

    Returns T

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/b.Func3.html b/test/htmldocs/interfaces/b.Func3.html new file mode 100644 index 0000000..86ea677 --- /dev/null +++ b/test/htmldocs/interfaces/b.Func3.html @@ -0,0 +1,86 @@ +Func3 | Documentation
+
+ +
+
+
+
+ +

Interface Func3

+
+

Hierarchy

+
    +
  • Func3
+
+
    + +
  • +

    function that returns a function

    +
    +
    +

    Parameters

    +
      +
    • +
      arg1: number
    +

    Returns (() => number)

    +
      +
    • +
        +
      • (): number
      • +
      • +

        function that returns a function

        +
        +

        Returns number

        +
    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/b.Func4.html b/test/htmldocs/interfaces/b.Func4.html new file mode 100644 index 0000000..771550d --- /dev/null +++ b/test/htmldocs/interfaces/b.Func4.html @@ -0,0 +1,81 @@ +Func4 | Documentation
+
+ +
+
+
+
+ +

Interface Func4

+
+

Hierarchy

+
    +
  • Func4
+
+
    + +
  • +

    function with ommited argument types

    +
    +
    +

    Parameters

    +
      +
    • +
      arg0: string
    • +
    • +
      arg1: number
    • +
    • +
      arg2: number
    +

    Returns void

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/b.Func5.html b/test/htmldocs/interfaces/b.Func5.html new file mode 100644 index 0000000..3a53227 --- /dev/null +++ b/test/htmldocs/interfaces/b.Func5.html @@ -0,0 +1,79 @@ +Func5 | Documentation
+
+ +
+
+
+
+ +

Interface Func5

+
+

Hierarchy

+
    +
  • Func5
+
+
    + +
  • +

    function with reserved argument name and variadic type

    +
    +
    +

    Parameters

    +
      +
    • +
      _arg00: string
    • +
    • +
      Rest ...optional: string[]
    +

    Returns void

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/b.Func6.html b/test/htmldocs/interfaces/b.Func6.html new file mode 100644 index 0000000..1a26ce4 --- /dev/null +++ b/test/htmldocs/interfaces/b.Func6.html @@ -0,0 +1,81 @@ +Func6 | Documentation
+
+ +
+
+
+
+ +

Interface Func6

+
+

Hierarchy

+
    +
  • Func6
+
+
    + +
  • +

    function with ommited argument names

    +
    +
    +

    Parameters

    +
      +
    • +
      _arg0: string
    • +
    • +
      _arg1: number
    • +
    • +
      Rest ..._arg2: boolean[]
    +

    Returns void

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/b.Func7.html b/test/htmldocs/interfaces/b.Func7.html new file mode 100644 index 0000000..0ad3a58 --- /dev/null +++ b/test/htmldocs/interfaces/b.Func7.html @@ -0,0 +1,72 @@ +Func7 | Documentation
+
+ +
+
+
+
+ +

Interface Func7

+
+

Hierarchy

+
    +
  • Func7
+
+
    + +
  • +

    function with named return values

    +
    +

    Returns [number, string]

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/b.Func8.html b/test/htmldocs/interfaces/b.Func8.html new file mode 100644 index 0000000..8f068ca --- /dev/null +++ b/test/htmldocs/interfaces/b.Func8.html @@ -0,0 +1,72 @@ +Func8 | Documentation
+
+ +
+
+
+
+ +

Interface Func8

+
+

Hierarchy

+
    +
  • Func8
+
+
    + +
  • +

    function with shortened return values

    +
    +

    Returns [string, string]

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/b.Func9.html b/test/htmldocs/interfaces/b.Func9.html new file mode 100644 index 0000000..87cd241 --- /dev/null +++ b/test/htmldocs/interfaces/b.Func9.html @@ -0,0 +1,72 @@ +Func9 | Documentation
+
+ +
+
+
+
+ +

Interface Func9

+
+

Hierarchy

+
    +
  • Func9
+
+
    + +
  • +

    function with named and shortened return values

    +
    +

    Returns [number, string, string]

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/c.Example1.html b/test/htmldocs/interfaces/c.Example1.html new file mode 100644 index 0000000..c406c92 --- /dev/null +++ b/test/htmldocs/interfaces/c.Example1.html @@ -0,0 +1,96 @@ +Example1 | Documentation
+
+ +
+
+
+
+ +

Interface Example1

+
+

Hierarchy

+
    +
  • Example1
+
+
+
+ +
+
+

Properties

+
+
+

Methods

+
+
+

Properties

+
+ +
Name: string
+
+

Methods

+
+ +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/c.Example2.html b/test/htmldocs/interfaces/c.Example2.html new file mode 100644 index 0000000..1e9daa7 --- /dev/null +++ b/test/htmldocs/interfaces/c.Example2.html @@ -0,0 +1,221 @@ +Example2 | Documentation
+
+ +
+
+
+
+ +

Interface Example2

+
+

Example:

+
    Some
code
sample +
+
+
+
+

Hierarchy

+
    +
  • Example2
+
+
+
+ +
+
+

Properties

+
+
+

Methods

+
+
+

Properties

+
+ +
Bytes: string | number[]
+
+ +
Json: Raw
+
+ +
Title: string
+
+

Methods

+
+ +
+
+ +
+
+ +
    + +
  • +

    ommited types

    +
    +
    +

    Parameters

    +
      +
    • +
      n1: string
    • +
    • +
      n2: string
    • +
    • +
      n3: string
    +

    Returns void

    +
+
+ +
    + +
  • +

    ommited names

    +
    +
    +

    Parameters

    +
      +
    • +
      _arg0: string
    • +
    • +
      _arg1: number
    +

    Returns void

    +
+
+ +
    + +
  • +

    named return values

    +
    +

    Returns [number, string]

    +
+
+ +
    + +
  • +

    shortened return values

    +
    +

    Returns [string, string]

    +
+
+ +
    + +
  • +

    named and shortened return values

    +
    +

    Returns [number, string, string]

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/c.Handler.html b/test/htmldocs/interfaces/c.Handler.html new file mode 100644 index 0000000..c264cbf --- /dev/null +++ b/test/htmldocs/interfaces/c.Handler.html @@ -0,0 +1,68 @@ +Handler | Documentation
+
+ +
+
+
+
+ +

Interface Handler

+
+

func type comment

+
+
+
+

Hierarchy

+
    +
  • Handler
+
+
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/c.Raw.html b/test/htmldocs/interfaces/c.Raw.html new file mode 100644 index 0000000..9f37c2c --- /dev/null +++ b/test/htmldocs/interfaces/c.Raw.html @@ -0,0 +1,986 @@ +Raw | Documentation
+
+ +
+
+
+
+ +

Interface Raw

+
+

Hierarchy

+
    +
  • Array<number> +
      +
    • Raw
+
+
+
+ +
+
+

Properties

+
+ +
length: number
+

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

+
+
+
+

Methods

+
+ +
    + +
  • +

    Combines two or more arrays. +This method returns a new array without modifying any existing arrays.

    +
    +
    +

    Parameters

    +
      +
    • +
      Rest ...items: ConcatArray<number>[]
      +

      Additional arrays and/or items to add to the end of the array.

      +
      +
    +

    Returns number[]

    +
  • + +
  • +

    Combines two or more arrays. +This method returns a new array without modifying any existing arrays.

    +
    +
    +

    Parameters

    +
      +
    • +
      Rest ...items: (number | ConcatArray<number>)[]
      +

      Additional arrays and/or items to add to the end of the array.

      +
      +
    +

    Returns number[]

    +
+
+ +
    + +
  • +

    Determines whether all the members of an array satisfy the specified test.

    +
    +
    +

    Type Parameters

    +
      +
    • +

      S extends number

    +
    +

    Parameters

    +
      +
    • +
      predicate: ((value, index, array) => value is S)
      +

      A function that accepts up to three arguments. The every method calls +the predicate function for each element in the array until the predicate returns a value +which is coercible to the Boolean value false, or until the end of the array.

      +
      +
      +
        +
      • +
          +
        • (value, index, array): value is S
        • +
        • +
          +

          Parameters

          +
            +
          • +
            value: number
          • +
          • +
            index: number
          • +
          • +
            array: number[]
          +

          Returns value is S

    • +
    • +
      Optional thisArg: any
      +

      An object to which the this keyword can refer in the predicate function. +If thisArg is omitted, undefined is used as the this value.

      +
      +
    +

    Returns this is S[]

    +
  • + +
  • +

    Determines whether all the members of an array satisfy the specified test.

    +
    +
    +

    Parameters

    +
      +
    • +
      predicate: ((value, index, array) => unknown)
      +

      A function that accepts up to three arguments. The every method calls +the predicate function for each element in the array until the predicate returns a value +which is coercible to the Boolean value false, or until the end of the array.

      +
      +
      +
        +
      • +
          +
        • (value, index, array): unknown
        • +
        • +
          +

          Parameters

          +
            +
          • +
            value: number
          • +
          • +
            index: number
          • +
          • +
            array: number[]
          +

          Returns unknown

    • +
    • +
      Optional thisArg: any
      +

      An object to which the this keyword can refer in the predicate function. +If thisArg is omitted, undefined is used as the this value.

      +
      +
    +

    Returns boolean

    +
+
+ +
    + +
  • +

    Returns the elements of an array that meet the condition specified in a callback function.

    +
    +
    +

    Type Parameters

    +
      +
    • +

      S extends number

    +
    +

    Parameters

    +
      +
    • +
      predicate: ((value, index, array) => value is S)
      +

      A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (value, index, array): value is S
        • +
        • +
          +

          Parameters

          +
            +
          • +
            value: number
          • +
          • +
            index: number
          • +
          • +
            array: number[]
          +

          Returns value is S

    • +
    • +
      Optional thisArg: any
      +

      An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.

      +
      +
    +

    Returns S[]

    +
  • + +
  • +

    Returns the elements of an array that meet the condition specified in a callback function.

    +
    +
    +

    Parameters

    +
      +
    • +
      predicate: ((value, index, array) => unknown)
      +

      A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (value, index, array): unknown
        • +
        • +
          +

          Parameters

          +
            +
          • +
            value: number
          • +
          • +
            index: number
          • +
          • +
            array: number[]
          +

          Returns unknown

    • +
    • +
      Optional thisArg: any
      +

      An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.

      +
      +
    +

    Returns number[]

    +
+
+ +
    + +
  • +

    Performs the specified action for each element in an array.

    +
    +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((value, index, array) => void)
      +

      A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (value, index, array): void
        • +
        • +
          +

          Parameters

          +
            +
          • +
            value: number
          • +
          • +
            index: number
          • +
          • +
            array: number[]
          +

          Returns void

    • +
    • +
      Optional thisArg: any
      +

      An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

      +
      +
    +

    Returns void

    +
+
+ +
    + +
  • +

    Returns the index of the first occurrence of a value in an array, or -1 if it is not present.

    +
    +
    +

    Parameters

    +
      +
    • +
      searchElement: number
      +

      The value to locate in the array.

      +
      +
    • +
    • +
      Optional fromIndex: number
      +

      The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.

      +
      +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Adds all the elements of an array into a string, separated by the specified separator string.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional separator: string
      +

      A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns the index of the last occurrence of a specified value in an array, or -1 if it is not present.

    +
    +
    +

    Parameters

    +
      +
    • +
      searchElement: number
      +

      The value to locate in the array.

      +
      +
    • +
    • +
      Optional fromIndex: number
      +

      The array index at which to begin searching backward. If fromIndex is omitted, the search starts at the last index in the array.

      +
      +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Calls a defined callback function on each element of an array, and returns an array that contains the results.

    +
    +
    +

    Type Parameters

    +
      +
    • +

      U

    +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((value, index, array) => U)
      +

      A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (value, index, array): U
        • +
        • +
          +

          Parameters

          +
            +
          • +
            value: number
          • +
          • +
            index: number
          • +
          • +
            array: number[]
          +

          Returns U

    • +
    • +
      Optional thisArg: any
      +

      An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

      +
      +
    +

    Returns U[]

    +
+
+ +
    + +
  • +

    Removes the last element from an array and returns it. +If the array is empty, undefined is returned and the array is not modified.

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Appends new elements to the end of an array, and returns the new length of the array.

    +
    +
    +

    Parameters

    +
      +
    • +
      Rest ...items: number[]
      +

      New elements to add to the array.

      +
      +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    +
    +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((previousValue, currentValue, currentIndex, array) => number)
      +

      A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (previousValue, currentValue, currentIndex, array): number
        • +
        • +
          +

          Parameters

          +
            +
          • +
            previousValue: number
          • +
          • +
            currentValue: number
          • +
          • +
            currentIndex: number
          • +
          • +
            array: number[]
          +

          Returns number

    +

    Returns number

    +
  • + +
  • +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((previousValue, currentValue, currentIndex, array) => number)
      +
        +
      • +
          +
        • (previousValue, currentValue, currentIndex, array): number
        • +
        • +
          +

          Parameters

          +
            +
          • +
            previousValue: number
          • +
          • +
            currentValue: number
          • +
          • +
            currentIndex: number
          • +
          • +
            array: number[]
          +

          Returns number

    • +
    • +
      initialValue: number
    +

    Returns number

  • + +
  • +

    Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    +
    +
    +

    Type Parameters

    +
      +
    • +

      U

    +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((previousValue, currentValue, currentIndex, array) => U)
      +

      A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (previousValue, currentValue, currentIndex, array): U
        • +
        • +
          +

          Parameters

          +
            +
          • +
            previousValue: U
          • +
          • +
            currentValue: number
          • +
          • +
            currentIndex: number
          • +
          • +
            array: number[]
          +

          Returns U

    • +
    • +
      initialValue: U
      +

      If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.

      +
      +
    +

    Returns U

    +
+
+ +
    + +
  • +

    Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    +
    +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((previousValue, currentValue, currentIndex, array) => number)
      +

      A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (previousValue, currentValue, currentIndex, array): number
        • +
        • +
          +

          Parameters

          +
            +
          • +
            previousValue: number
          • +
          • +
            currentValue: number
          • +
          • +
            currentIndex: number
          • +
          • +
            array: number[]
          +

          Returns number

    +

    Returns number

    +
  • + +
  • +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((previousValue, currentValue, currentIndex, array) => number)
      +
        +
      • +
          +
        • (previousValue, currentValue, currentIndex, array): number
        • +
        • +
          +

          Parameters

          +
            +
          • +
            previousValue: number
          • +
          • +
            currentValue: number
          • +
          • +
            currentIndex: number
          • +
          • +
            array: number[]
          +

          Returns number

    • +
    • +
      initialValue: number
    +

    Returns number

  • + +
  • +

    Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    +
    +
    +

    Type Parameters

    +
      +
    • +

      U

    +
    +

    Parameters

    +
      +
    • +
      callbackfn: ((previousValue, currentValue, currentIndex, array) => U)
      +

      A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.

      +
      +
      +
        +
      • +
          +
        • (previousValue, currentValue, currentIndex, array): U
        • +
        • +
          +

          Parameters

          +
            +
          • +
            previousValue: U
          • +
          • +
            currentValue: number
          • +
          • +
            currentIndex: number
          • +
          • +
            array: number[]
          +

          Returns U

    • +
    • +
      initialValue: U
      +

      If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.

      +
      +
    +

    Returns U

    +
+
+ +
    + +
  • +

    Reverses the elements in an array in place. +This method mutates the array and returns a reference to the same array.

    +
    +

    Returns number[]

    +
+
+ +
    + +
  • +

    Removes the first element from an array and returns it. +If the array is empty, undefined is returned and the array is not modified.

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Returns a copy of a section of an array. +For both start and end, a negative index can be used to indicate an offset from the end of the array. +For example, -2 refers to the second to last element of the array.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional start: number
      +

      The beginning index of the specified portion of the array. +If start is undefined, then the slice begins at index 0.

      +
      +
    • +
    • +
      Optional end: number
      +

      The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. +If end is undefined, then the slice extends to the end of the array.

      +
      +
    +

    Returns number[]

    +
+
+ +
    + +
  • +

    Determines whether the specified callback function returns true for any element of an array.

    +
    +
    +

    Parameters

    +
      +
    • +
      predicate: ((value, index, array) => unknown)
      +

      A function that accepts up to three arguments. The some method calls +the predicate function for each element in the array until the predicate returns a value +which is coercible to the Boolean value true, or until the end of the array.

      +
      +
      +
        +
      • +
          +
        • (value, index, array): unknown
        • +
        • +
          +

          Parameters

          +
            +
          • +
            value: number
          • +
          • +
            index: number
          • +
          • +
            array: number[]
          +

          Returns unknown

    • +
    • +
      Optional thisArg: any
      +

      An object to which the this keyword can refer in the predicate function. +If thisArg is omitted, undefined is used as the this value.

      +
      +
    +

    Returns boolean

    +
+
+ +
    + +
  • +

    Sorts an array in place. +This method mutates the array and returns a reference to the same array.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional compareFn: ((a, b) => number)
      +

      Function used to determine the order of the elements. It is expected to return +a negative value if the first argument is less than the second argument, zero if they're equal, and a positive +value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.

      +
      [11,2,22,1].sort((a, b) => a - b)
      +
      +
      +
      +
        +
      • +
          +
        • (a, b): number
        • +
        • +
          +

          Parameters

          +
            +
          • +
            a: number
          • +
          • +
            b: number
          +

          Returns number

    +

    Returns Raw

    +
+
+ +
    + +
  • +

    Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.

    +
    +
    +

    Parameters

    +
      +
    • +
      start: number
      +

      The zero-based location in the array from which to start removing elements.

      +
      +
    • +
    • +
      Optional deleteCount: number
      +

      The number of elements to remove.

      +
      +
    +

    Returns number[]

    An array containing the elements that were deleted.

    + +
  • + +
  • +

    Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.

    +
    +
    +

    Parameters

    +
      +
    • +
      start: number
      +

      The zero-based location in the array from which to start removing elements.

      +
      +
    • +
    • +
      deleteCount: number
      +

      The number of elements to remove.

      +
      +
    • +
    • +
      Rest ...items: number[]
      +

      Elements to insert into the array in place of the deleted elements.

      +
      +
    +

    Returns number[]

    An array containing the elements that were deleted.

    + +
+
+ +
    + +
  • +

    Returns a string representation of an array. The elements are converted to string using their toLocaleString methods.

    +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns a string representation of an array.

    +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Inserts new elements at the start of an array, and returns the new length of the array.

    +
    +
    +

    Parameters

    +
      +
    • +
      Rest ...items: number[]
      +

      Elements to insert at the start of the array.

      +
      +
    +

    Returns number

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/time.Duration.html b/test/htmldocs/interfaces/time.Duration.html new file mode 100644 index 0000000..d04636e --- /dev/null +++ b/test/htmldocs/interfaces/time.Duration.html @@ -0,0 +1,371 @@ +Duration | Documentation
+
+ +
+
+
+
+ +

Interface Duration

+
+

A Duration represents the elapsed time between two instants +as an int64 nanosecond count. The representation limits the +largest representable duration to approximately 290 years.

+
+
+
+

Hierarchy

+
    +
  • Number +
      +
    • Duration
+
+
+
+ +
+
+

Methods

+
+ +
    + +
  • +

    Abs returns the absolute value of d. +As a special case, [math.MinInt64] is converted to [math.MaxInt64].

    +
    +

    Returns Duration

    +
+
+ +
    + +
  • +

    Hours returns the duration as a floating point number of hours.

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Microseconds returns the duration as an integer microsecond count.

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Milliseconds returns the duration as an integer millisecond count.

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Minutes returns the duration as a floating point number of minutes.

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Nanoseconds returns the duration as an integer nanosecond count.

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Round returns the result of rounding d to the nearest multiple of m. +The rounding behavior for halfway values is to round away from zero. +If the result exceeds the maximum (or minimum) +value that can be stored in a [Duration], +Round returns the maximum (or minimum) duration. +If m <= 0, Round returns d unchanged.

    +
    +
    +

    Parameters

    +
    +

    Returns Duration

    +
+
+ +
    + +
  • +

    Seconds returns the duration as a floating point number of seconds.

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    String returns a string representing the duration in the form "72h3m0.5s". +Leading zero units are omitted. As a special case, durations less than one +second format use a smaller unit (milli-, micro-, or nanoseconds) to ensure +that the leading digit is non-zero. The zero duration formats as 0s.

    +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Truncate returns the result of rounding d toward zero to a multiple of m. +If m <= 0, Truncate returns d unchanged.

    +
    +
    +

    Parameters

    +
    +

    Returns Duration

    +
+
+ +
    + +
  • +

    Returns a string containing a number represented in exponential notation.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional fractionDigits: number
      +

      Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns a string representing a number in fixed-point notation.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional fractionDigits: number
      +

      Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Converts a number to a string by using the current or specified locale.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional locales: string | string[]
      +

      A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.

      +
      +
    • +
    • +
      Optional options: NumberFormatOptions
      +

      An object that contains one or more properties that specify comparison options.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional precision: number
      +

      Number of significant digits. Must be in the range 1 - 21, inclusive.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns a string representation of an object.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional radix: number
      +

      Specifies a radix for converting numeric values to strings. This value is only used for numbers.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns the primitive value of the specified object.

    +
    +

    Returns number

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/time.Location.html b/test/htmldocs/interfaces/time.Location.html new file mode 100644 index 0000000..7e62001 --- /dev/null +++ b/test/htmldocs/interfaces/time.Location.html @@ -0,0 +1,99 @@ +Location | Documentation
+
+ +
+
+
+
+ +

Interface Location

+
+

A Location maps time instants to the zone in use at that time. +Typically, the Location represents the collection of time offsets +in use in a geographical area. For many Locations the time offset varies +depending on whether daylight savings time is in use at the time instant.

+

Location is used to provide a time zone in a printed Time value and for +calculations involving intervals that may cross daylight savings time +boundaries.

+
+
+
+

Hierarchy

+
    +
  • Location
+
+
+
+ +
+
+

Methods

+
+
+

Methods

+
+ +
    + +
  • +

    String returns a descriptive name for the time zone information, +corresponding to the name argument to [LoadLocation] or [FixedZone].

    +
    +

    Returns string

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/time.Month.html b/test/htmldocs/interfaces/time.Month.html new file mode 100644 index 0000000..8bc8d72 --- /dev/null +++ b/test/htmldocs/interfaces/time.Month.html @@ -0,0 +1,223 @@ +Month | Documentation
+
+ +
+
+
+
+ +

Interface Month

+
+

A Month specifies a month of the year (January = 1, ...).

+
+
+
+

Hierarchy

+
    +
  • Number +
      +
    • Month
+
+
+
+ +
+
+

Methods

+
+ +
    + +
  • +

    String returns the English name of the month ("January", "February", ...).

    +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns a string containing a number represented in exponential notation.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional fractionDigits: number
      +

      Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns a string representing a number in fixed-point notation.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional fractionDigits: number
      +

      Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Converts a number to a string by using the current or specified locale.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional locales: string | string[]
      +

      A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.

      +
      +
    • +
    • +
      Optional options: NumberFormatOptions
      +

      An object that contains one or more properties that specify comparison options.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional precision: number
      +

      Number of significant digits. Must be in the range 1 - 21, inclusive.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns a string representation of an object.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional radix: number
      +

      Specifies a radix for converting numeric values to strings. This value is only used for numbers.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns the primitive value of the specified object.

    +
    +

    Returns number

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/time.Time.html b/test/htmldocs/interfaces/time.Time.html new file mode 100644 index 0000000..e47ea20 --- /dev/null +++ b/test/htmldocs/interfaces/time.Time.html @@ -0,0 +1,913 @@ +Time | Documentation
+
+ +
+
+
+
+ +

Interface Time

+
+

A Time represents an instant in time with nanosecond precision.

+

Programs using times should typically store and pass them as values, +not pointers. That is, time variables and struct fields should be of +type [time.Time], not *time.Time.

+

A Time value can be used by multiple goroutines simultaneously except +that the methods [Time.GobDecode], [Time.UnmarshalBinary], [Time.UnmarshalJSON] and +[Time.UnmarshalText] are not concurrency-safe.

+

Time instants can be compared using the [Time.Before], [Time.After], and [Time.Equal] methods. +The [Time.Sub] method subtracts two instants, producing a [Duration]. +The [Time.Add] method adds a Time and a Duration, producing a Time.

+

The zero value of type Time is January 1, year 1, 00:00:00.000000000 UTC. +As this time is unlikely to come up in practice, the [Time.IsZero] method gives +a simple way of detecting a time that has not been initialized explicitly.

+

Each time has an associated [Location]. The methods [Time.Local], [Time.UTC], and Time.In return a +Time with a specific Location. Changing the Location of a Time value with +these methods does not change the actual instant it represents, only the time +zone in which to interpret it.

+

Representations of a Time value saved by the [Time.GobEncode], [Time.MarshalBinary], +[Time.MarshalJSON], and [Time.MarshalText] methods store the [Time.Location]'s offset, but not +the location name. They therefore lose information about Daylight Saving Time.

+

In addition to the required “wall clock” reading, a Time may contain an optional +reading of the current process's monotonic clock, to provide additional precision +for comparison or subtraction. +See the “Monotonic Clocks” section in the package documentation for details.

+

Note that the Go == operator compares not just the time instant but also the +Location and the monotonic clock reading. Therefore, Time values should not +be used as map or database keys without first guaranteeing that the +identical Location has been set for all values, which can be achieved +through use of the UTC or Local method, and that the monotonic clock reading +has been stripped by setting t = t.Round(0). In general, prefer t.Equal(u) +to t == u, since t.Equal uses the most accurate comparison available and +correctly handles the case when only one of its arguments has a monotonic +clock reading.

+
+
+
+

Hierarchy

+
    +
  • Time
+
+
+
+ +
+
+

Methods

+
+ +
+
+ +
    + +
  • +

    AddDate returns the time corresponding to adding the +given number of years, months, and days to t. +For example, AddDate(-1, 2, 3) applied to January 1, 2011 +returns March 4, 2010.

    +

    Note that dates are fundamentally coupled to timezones, and calendrical +periods like days don't have fixed durations. AddDate uses the Location of +the Time value to determine these durations. That means that the same +AddDate arguments can produce a different shift in absolute time depending on +the base Time value and its Location. For example, AddDate(0, 0, 1) applied +to 12:00 on March 27 always returns 12:00 on March 28. At some locations and +in some years this is a 24 hour shift. In others it's a 23 hour shift due to +daylight savings time transitions.

    +

    AddDate normalizes its result in the same way that Date does, +so, for example, adding one month to October 31 yields +December 1, the normalized form for November 31.

    +
    +
    +

    Parameters

    +
      +
    • +
      years: number
    • +
    • +
      months: number
    • +
    • +
      days: number
    +

    Returns Time

    +
+
+ +
    + +
  • +

    After reports whether the time instant t is after u.

    +
    +
    +

    Parameters

    +
    +

    Returns boolean

    +
+
+ +
    + +
  • +

    AppendFormat is like [Time.Format] but appends the textual +representation to b and returns the extended buffer.

    +
    +
    +

    Parameters

    +
      +
    • +
      b: string | number[]
    • +
    • +
      layout: string
    +

    Returns string | number[]

    +
+
+ +
    + +
  • +

    Before reports whether the time instant t is before u.

    +
    +
    +

    Parameters

    +
    +

    Returns boolean

    +
+
+ +
    + +
  • +

    Clock returns the hour, minute, and second within the day specified by t.

    +
    +

    Returns [number, number, number]

    +
+
+ +
    + +
  • +

    Compare compares the time instant t with u. If t is before u, it returns -1; +if t is after u, it returns +1; if they're the same, it returns 0.

    +
    +
    +

    Parameters

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Date returns the year, month, and day in which t occurs.

    +
    +

    Returns [number, Month, number]

    +
+
+ +
    + +
  • +

    Day returns the day of the month specified by t.

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Equal reports whether t and u represent the same time instant. +Two times can be equal even if they are in different locations. +For example, 6:00 +0200 and 4:00 UTC are Equal. +See the documentation on the Time type for the pitfalls of using == with +Time values; most code should use Equal instead.

    +
    +
    +

    Parameters

    +
    +

    Returns boolean

    +
+
+ +
    + +
  • +

    Format returns a textual representation of the time value formatted according +to the layout defined by the argument. See the documentation for the +constant called [Layout] to see how to represent the layout format.

    +

    The executable example for [Time.Format] demonstrates the working +of the layout string in detail and is a good reference.

    +
    +
    +

    Parameters

    +
      +
    • +
      layout: string
    +

    Returns string

    +
+
+ +
    + +
  • +

    GoString implements [fmt.GoStringer] and formats t to be printed in Go source +code.

    +
    +

    Returns string

    +
+
+ +
    + +
  • +

    GobDecode implements the gob.GobDecoder interface.

    +
    +
    +

    Parameters

    +
      +
    • +
      data: string | number[]
    +

    Returns void

    +
+
+ +
    + +
  • +

    GobEncode implements the gob.GobEncoder interface.

    +
    +

    Returns string | number[]

    +
+
+ +
    + +
  • +

    Hour returns the hour within the day specified by t, in the range [0, 23].

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    ISOWeek returns the ISO 8601 year and week number in which t occurs. +Week ranges from 1 to 53. Jan 01 to Jan 03 of year n might belong to +week 52 or 53 of year n-1, and Dec 29 to Dec 31 might belong to week 1 +of year n+1.

    +
    +

    Returns [number, number]

    +
+
+ +
    + +
  • +

    In returns a copy of t representing the same time instant, but +with the copy's location information set to loc for display +purposes.

    +

    In panics if loc is nil.

    +
    +
    +

    Parameters

    +
    +

    Returns Time

    +
+
+ +
    + +
  • +

    IsDST reports whether the time in the configured location is in Daylight Savings Time.

    +
    +

    Returns boolean

    +
+
+ +
    + +
  • +

    IsZero reports whether t represents the zero time instant, +January 1, year 1, 00:00:00 UTC.

    +
    +

    Returns boolean

    +
+
+ +
    + +
  • +

    Local returns t with the location set to local time.

    +
    +

    Returns Time

    +
+
+ +
+
+ +
    + +
  • +

    MarshalBinary implements the encoding.BinaryMarshaler interface.

    +
    +

    Returns string | number[]

    +
+
+ +
    + +
  • +

    MarshalJSON implements the [json.Marshaler] interface. +The time is a quoted string in the RFC 3339 format with sub-second precision. +If the timestamp cannot be represented as valid RFC 3339 +(e.g., the year is out of range), then an error is reported.

    +
    +

    Returns string | number[]

    +
+
+ +
    + +
  • +

    MarshalText implements the [encoding.TextMarshaler] interface. +The time is formatted in RFC 3339 format with sub-second precision. +If the timestamp cannot be represented as valid RFC 3339 +(e.g., the year is out of range), then an error is reported.

    +
    +

    Returns string | number[]

    +
+
+ +
    + +
  • +

    Minute returns the minute offset within the hour specified by t, in the range [0, 59].

    +
    +

    Returns number

    +
+
+ +
+
+ +
    + +
  • +

    Nanosecond returns the nanosecond offset within the second specified by t, +in the range [0, 999999999].

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Round returns the result of rounding t to the nearest multiple of d (since the zero time). +The rounding behavior for halfway values is to round up. +If d <= 0, Round returns t stripped of any monotonic clock reading but otherwise unchanged.

    +

    Round operates on the time as an absolute duration since the +zero time; it does not operate on the presentation form of the +time. Thus, Round(Hour) may return a time with a non-zero +minute, depending on the time's Location.

    +
    +
    +

    Parameters

    +
    +

    Returns Time

    +
+
+ +
    + +
  • +

    Second returns the second offset within the minute specified by t, in the range [0, 59].

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    String returns the time formatted using the format string

    +
        "2006-01-02 15:04:05.999999999 -0700 MST"
    +
    +

    If the time has a monotonic clock reading, the returned string +includes a final field "m=±", where value is the monotonic +clock reading formatted as a decimal number of seconds.

    +

    The returned string is meant for debugging; for a stable serialized +representation, use t.MarshalText, t.MarshalBinary, or t.Format +with an explicit format string.

    +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Sub returns the duration t-u. If the result exceeds the maximum (or minimum) +value that can be stored in a [Duration], the maximum (or minimum) duration +will be returned. +To compute t-d for a duration d, use t.Add(-d).

    +
    +
    +

    Parameters

    +
    +

    Returns Duration

    +
+
+ +
    + +
  • +

    Truncate returns the result of rounding t down to a multiple of d (since the zero time). +If d <= 0, Truncate returns t stripped of any monotonic clock reading but otherwise unchanged.

    +

    Truncate operates on the time as an absolute duration since the +zero time; it does not operate on the presentation form of the +time. Thus, Truncate(Hour) may return a time with a non-zero +minute, depending on the time's Location.

    +
    +
    +

    Parameters

    +
    +

    Returns Time

    +
+
+ +
+
+ +
    + +
  • +

    Unix returns t as a Unix time, the number of seconds elapsed +since January 1, 1970 UTC. The result does not depend on the +location associated with t. +Unix-like operating systems often record time as a 32-bit +count of seconds, but since the method here returns a 64-bit +value it is valid for billions of years into the past or future.

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    UnixMicro returns t as a Unix time, the number of microseconds elapsed since +January 1, 1970 UTC. The result is undefined if the Unix time in +microseconds cannot be represented by an int64 (a date before year -290307 or +after year 294246). The result does not depend on the location associated +with t.

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    UnixMilli returns t as a Unix time, the number of milliseconds elapsed since +January 1, 1970 UTC. The result is undefined if the Unix time in +milliseconds cannot be represented by an int64 (a date more than 292 million +years before or after 1970). The result does not depend on the +location associated with t.

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    UnixNano returns t as a Unix time, the number of nanoseconds elapsed +since January 1, 1970 UTC. The result is undefined if the Unix time +in nanoseconds cannot be represented by an int64 (a date before the year +1678 or after 2262). Note that this means the result of calling UnixNano +on the zero Time is undefined. The result does not depend on the +location associated with t.

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

    +
    +
    +

    Parameters

    +
      +
    • +
      data: string | number[]
    +

    Returns void

    +
+
+ +
    + +
  • +

    UnmarshalJSON implements the [json.Unmarshaler] interface. +The time must be a quoted string in the RFC 3339 format.

    +
    +
    +

    Parameters

    +
      +
    • +
      data: string | number[]
    +

    Returns void

    +
+
+ +
    + +
  • +

    UnmarshalText implements the [encoding.TextUnmarshaler] interface. +The time must be in the RFC 3339 format.

    +
    +
    +

    Parameters

    +
      +
    • +
      data: string | number[]
    +

    Returns void

    +
+
+ +
+
+ +
    + +
  • +

    Year returns the year in which t occurs.

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    YearDay returns the day of the year specified by t, in the range [1,365] for non-leap years, +and [1,366] in leap years.

    +
    +

    Returns number

    +
+
+ +
    + +
  • +

    Zone computes the time zone in effect at time t, returning the abbreviated +name of the zone (such as "CET") and its offset in seconds east of UTC.

    +
    +

    Returns [string, number]

    +
+
+ +
    + +
  • +

    ZoneBounds returns the bounds of the time zone in effect at time t. +The zone begins at start and the next zone begins at end. +If the zone begins at the beginning of time, start will be returned as a zero Time. +If the zone goes on forever, end will be returned as a zero Time. +The Location of the returned times will be the same as t.

    +
    +

    Returns [Time, Time]

    +
+
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/interfaces/time.Weekday.html b/test/htmldocs/interfaces/time.Weekday.html new file mode 100644 index 0000000..dec30d3 --- /dev/null +++ b/test/htmldocs/interfaces/time.Weekday.html @@ -0,0 +1,223 @@ +Weekday | Documentation
+
+ +
+
+
+
+ +

Interface Weekday

+
+

A Weekday specifies a day of the week (Sunday = 0, ...).

+
+
+
+

Hierarchy

+
    +
  • Number +
      +
    • Weekday
+
+
+
+ +
+
+

Methods

+
+ +
    + +
  • +

    String returns the English name of the day ("Sunday", "Monday", ...).

    +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns a string containing a number represented in exponential notation.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional fractionDigits: number
      +

      Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns a string representing a number in fixed-point notation.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional fractionDigits: number
      +

      Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Converts a number to a string by using the current or specified locale.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional locales: string | string[]
      +

      A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.

      +
      +
    • +
    • +
      Optional options: NumberFormatOptions
      +

      An object that contains one or more properties that specify comparison options.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional precision: number
      +

      Number of significant digits. Must be in the range 1 - 21, inclusive.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns a string representation of an object.

    +
    +
    +

    Parameters

    +
      +
    • +
      Optional radix: number
      +

      Specifies a radix for converting numeric values to strings. This value is only used for numbers.

      +
      +
    +

    Returns string

    +
+
+ +
    + +
  • +

    Returns the primitive value of the specified object.

    +
    +

    Returns number

    +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/modules.html b/test/htmldocs/modules.html new file mode 100644 index 0000000..74939aa --- /dev/null +++ b/test/htmldocs/modules.html @@ -0,0 +1,61 @@ +Documentation
+
+ +
+
+
+
+

Documentation

+
+
+

Index

+
+

Namespaces

+
a +b +c +time +
+
+

Type Aliases

+
+
+

Functions

+
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/modules/a.html b/test/htmldocs/modules/a.html new file mode 100644 index 0000000..0c32cd0 --- /dev/null +++ b/test/htmldocs/modules/a.html @@ -0,0 +1,82 @@ +a | Documentation
+
+ +
+
+
+
+ +

Namespace a

+
+

package a docs +lorem ipsum dolor...

+
+
+
+
+

Index

+
+

Interfaces

+
+
+

Type Aliases

+
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/modules/b.html b/test/htmldocs/modules/b.html new file mode 100644 index 0000000..6711c91 --- /dev/null +++ b/test/htmldocs/modules/b.html @@ -0,0 +1,78 @@ +b | Documentation
+
+ +
+
+
+
+ +

Namespace b

+
+

package b

+
+
+
+
+

Index

+
+

Interfaces

+
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/modules/c.html b/test/htmldocs/modules/c.html new file mode 100644 index 0000000..52dca4a --- /dev/null +++ b/test/htmldocs/modules/c.html @@ -0,0 +1,65 @@ +c | Documentation
+
+ +
+
+
+
+ +

Namespace c

+
+
+

Index

+
+

Interfaces

+
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/modules/time.html b/test/htmldocs/modules/time.html new file mode 100644 index 0000000..5479935 --- /dev/null +++ b/test/htmldocs/modules/time.html @@ -0,0 +1,144 @@ +time | Documentation
+
+ +
+
+
+
+ +

Namespace time

+
+

Package time provides functionality for measuring and displaying time.

+

The calendrical calculations always assume a Gregorian calendar, with +no leap seconds.

+

Monotonic Clocks

Operating systems provide both a “wall clock,” which is subject to +changes for clock synchronization, and a “monotonic clock,” which is +not. The general rule is that the wall clock is for telling time and +the monotonic clock is for measuring time. Rather than split the API, +in this package the Time returned by [time.Now] contains both a wall +clock reading and a monotonic clock reading; later time-telling +operations use the wall clock reading, but later time-measuring +operations, specifically comparisons and subtractions, use the +monotonic clock reading.

+

For example, this code always computes a positive elapsed time of +approximately 20 milliseconds, even if the wall clock is changed during +the operation being timed:

+
    start := time.Now()
... operation that takes 20 milliseconds ...
t := time.Now()
elapsed := t.Sub(start) +
+

Other idioms, such as time.Since, time.Until, and +time.Now().Before(deadline), are similarly robust against wall clock +resets.

+

The rest of this section gives the precise details of how operations +use monotonic clocks, but understanding those details is not required +to use this package.

+

The Time returned by time.Now contains a monotonic clock reading. +If Time t has a monotonic clock reading, t.Add adds the same duration to +both the wall clock and monotonic clock readings to compute the result. +Because t.AddDate(y, m, d), t.Round(d), and t.Truncate(d) are wall time +computations, they always strip any monotonic clock reading from their results. +Because t.In, t.Local, and t.UTC are used for their effect on the interpretation +of the wall time, they also strip any monotonic clock reading from their results. +The canonical way to strip a monotonic clock reading is to use t = t.Round(0).

+

If Times t and u both contain monotonic clock readings, the operations +t.After(u), t.Before(u), t.Equal(u), t.Compare(u), and t.Sub(u) are carried out +using the monotonic clock readings alone, ignoring the wall clock +readings. If either t or u contains no monotonic clock reading, these +operations fall back to using the wall clock readings.

+

On some systems the monotonic clock will stop if the computer goes to sleep. +On such a system, t.Sub(u) may not accurately reflect the actual +time that passed between t and u. The same applies to other functions and +methods that subtract times, such as [Since], [Until], [Before], [After], +[Add], [Sub], [Equal] and [Compare]. In some cases, you may need to strip +the monotonic clock to get accurate results.

+

Because the monotonic clock reading has no meaning outside +the current process, the serialized forms generated by t.GobEncode, +t.MarshalBinary, t.MarshalJSON, and t.MarshalText omit the monotonic +clock reading, and t.Format provides no format for it. Similarly, the +constructors [time.Date], [time.Parse], [time.ParseInLocation], and [time.Unix], +as well as the unmarshalers t.GobDecode, t.UnmarshalBinary. +t.UnmarshalJSON, and t.UnmarshalText always create times with +no monotonic clock reading.

+

The monotonic clock reading exists only in [Time] values. It is not +a part of [Duration] values or the Unix times returned by t.Unix and +friends.

+

Note that the Go == operator compares not just the time instant but +also the [Location] and the monotonic clock reading. See the +documentation for the Time type for a discussion of equality +testing for Time values.

+

For debugging, the result of t.String does include the monotonic +clock reading if present. If t != u because of different monotonic clock readings, +that difference will be visible when printing t.String() and u.String().

+

Timer Resolution

[Timer] resolution varies depending on the Go runtime, the operating system +and the underlying hardware. +On Unix, the resolution is ~1ms. +On Windows version 1803 and newer, the resolution is ~0.5ms. +On older Windows versions, the default resolution is ~16ms, but +a higher resolution may be requested using [golang.org/x/sys/windows.TimeBeginPeriod].

+
+
+
+
+

Index

+
+

Interfaces

+
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/types/_TygojaAny.html b/test/htmldocs/types/_TygojaAny.html new file mode 100644 index 0000000..98b2b85 --- /dev/null +++ b/test/htmldocs/types/_TygojaAny.html @@ -0,0 +1,48 @@ +_TygojaAny | Documentation
+
+ +
+
+
+
+ +

Type alias _TygojaAny

+
_TygojaAny: any
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/types/_TygojaDict.html b/test/htmldocs/types/_TygojaDict.html new file mode 100644 index 0000000..b2817c9 --- /dev/null +++ b/test/htmldocs/types/_TygojaDict.html @@ -0,0 +1,53 @@ +_TygojaDict | Documentation
+
+ +
+
+
+
+ +

Type alias _TygojaDict

+
_TygojaDict: {
    [key: string | number | symbol]: any;
}
+
+

Type declaration

+
    +
  • +
    [key: string | number | symbol]: any
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/htmldocs/types/a._subOLPog.html b/test/htmldocs/types/a._subOLPog.html new file mode 100644 index 0000000..509e090 --- /dev/null +++ b/test/htmldocs/types/a._subOLPog.html @@ -0,0 +1,64 @@ +_subOLPog | Documentation
+
+ +
+
+
+
+ +

Type alias _subOLPog

+
_subOLPog: unexported & structA
+

structB comment

+
+
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/test/main.go b/test/main.go new file mode 100644 index 0000000..ff4b544 --- /dev/null +++ b/test/main.go @@ -0,0 +1,33 @@ +package main + +import ( + "log" + "os" + + "github.com/pocketbase/tygoja" +) + +func main() { + gen := tygoja.New(tygoja.Config{ + Packages: map[string][]string{ + "github.com/pocketbase/tygoja/test/a": {"*"}, + "github.com/pocketbase/tygoja/test/b": {"*"}, + "github.com/pocketbase/tygoja/test/c": {"Example2", "Handler"}, + }, + Heading: `declare var $app: c.Handler;`, + WithPackageFunctions: true, + // enable if you want to be able to import them + // StartModifier: "export", + }) + + result, err := gen.Generate() + if err != nil { + log.Fatal(err) + } + + if err := os.WriteFile("./types.d.ts", []byte(result), 0644); err != nil { + log.Fatal(err) + } + + // run `npx typedoc` to generate HTML docs from the above declarations +} diff --git a/test/package-lock.json b/test/package-lock.json new file mode 100644 index 0000000..77da1c8 --- /dev/null +++ b/test/package-lock.json @@ -0,0 +1,238 @@ +{ + "name": "test", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "devDependencies": { + "typedoc": "^0.24.8" + } + }, + "node_modules/ansi-sequence-parser": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.0.tgz", + "integrity": "sha512-lEm8mt52to2fT8GhciPCGeCXACSz2UwIN4X2e2LJSnZ5uAbn2/dsYdOmUXq0AtWS5cpAupysIneExOgH0Vd2TQ==", + "dev": true + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", + "dev": true + }, + "node_modules/lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", + "dev": true + }, + "node_modules/marked": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", + "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", + "dev": true, + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 12" + } + }, + "node_modules/minimatch": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.1.tgz", + "integrity": "sha512-0jWhJpD/MdhPXwPuiRkCbfYfSKp2qnn2eOc279qI7f+osl/l+prKSrvhg157zSYvx/1nmgn2NqdT6k2Z7zSH9w==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/shiki": { + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.2.tgz", + "integrity": "sha512-ltSZlSLOuSY0M0Y75KA+ieRaZ0Trf5Wl3gutE7jzLuIcWxLp5i/uEnLoQWNvgKXQ5OMpGkJnVMRLAuzjc0LJ2A==", + "dev": true, + "dependencies": { + "ansi-sequence-parser": "^1.1.0", + "jsonc-parser": "^3.2.0", + "vscode-oniguruma": "^1.7.0", + "vscode-textmate": "^8.0.0" + } + }, + "node_modules/typedoc": { + "version": "0.24.8", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.24.8.tgz", + "integrity": "sha512-ahJ6Cpcvxwaxfu4KtjA8qZNqS43wYt6JL27wYiIgl1vd38WW/KWX11YuAeZhuz9v+ttrutSsgK+XO1CjL1kA3w==", + "dev": true, + "dependencies": { + "lunr": "^2.3.9", + "marked": "^4.3.0", + "minimatch": "^9.0.0", + "shiki": "^0.14.1" + }, + "bin": { + "typedoc": "bin/typedoc" + }, + "engines": { + "node": ">= 14.14" + }, + "peerDependencies": { + "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x" + } + }, + "node_modules/typedoc-twilio-theme": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/typedoc-twilio-theme/-/typedoc-twilio-theme-1.0.1.tgz", + "integrity": "sha512-9cT7fli3+1x0CcQvavenemzjpEh9jOG93Dr9j8vqmI6BBjBA22cUsAVoYYSwu0E/nOJOKWxYqtfM4t2qHi8QMA==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/typescript": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.3.tgz", + "integrity": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==", + "dev": true, + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/vscode-oniguruma": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz", + "integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==", + "dev": true + }, + "node_modules/vscode-textmate": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz", + "integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==", + "dev": true + } + }, + "dependencies": { + "ansi-sequence-parser": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.0.tgz", + "integrity": "sha512-lEm8mt52to2fT8GhciPCGeCXACSz2UwIN4X2e2LJSnZ5uAbn2/dsYdOmUXq0AtWS5cpAupysIneExOgH0Vd2TQ==", + "dev": true + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", + "dev": true + }, + "lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", + "dev": true + }, + "marked": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", + "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", + "dev": true + }, + "minimatch": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.1.tgz", + "integrity": "sha512-0jWhJpD/MdhPXwPuiRkCbfYfSKp2qnn2eOc279qI7f+osl/l+prKSrvhg157zSYvx/1nmgn2NqdT6k2Z7zSH9w==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + }, + "shiki": { + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.2.tgz", + "integrity": "sha512-ltSZlSLOuSY0M0Y75KA+ieRaZ0Trf5Wl3gutE7jzLuIcWxLp5i/uEnLoQWNvgKXQ5OMpGkJnVMRLAuzjc0LJ2A==", + "dev": true, + "requires": { + "ansi-sequence-parser": "^1.1.0", + "jsonc-parser": "^3.2.0", + "vscode-oniguruma": "^1.7.0", + "vscode-textmate": "^8.0.0" + } + }, + "typedoc": { + "version": "0.24.8", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.24.8.tgz", + "integrity": "sha512-ahJ6Cpcvxwaxfu4KtjA8qZNqS43wYt6JL27wYiIgl1vd38WW/KWX11YuAeZhuz9v+ttrutSsgK+XO1CjL1kA3w==", + "dev": true, + "requires": { + "lunr": "^2.3.9", + "marked": "^4.3.0", + "minimatch": "^9.0.0", + "shiki": "^0.14.1" + } + }, + "typedoc-twilio-theme": { + "version": "https://registry.npmjs.org/typedoc-twilio-theme/-/typedoc-twilio-theme-1.0.1.tgz", + "integrity": "sha512-9cT7fli3+1x0CcQvavenemzjpEh9jOG93Dr9j8vqmI6BBjBA22cUsAVoYYSwu0E/nOJOKWxYqtfM4t2qHi8QMA==", + "dev": true + }, + "typescript": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.3.tgz", + "integrity": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==", + "dev": true, + "peer": true + }, + "vscode-oniguruma": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz", + "integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==", + "dev": true + }, + "vscode-textmate": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz", + "integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==", + "dev": true + } + } +} diff --git a/test/package.json b/test/package.json new file mode 100644 index 0000000..9058ccb --- /dev/null +++ b/test/package.json @@ -0,0 +1,8 @@ +{ + "scripts": { + "generate": "npx typedoc" + }, + "devDependencies": { + "typedoc": "^0.24.8" + } +} diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 0000000..82c2662 --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,7 @@ +{ + "typedocOptions": { + "entryPoints": ["types.d.ts"], + "skipErrorChecking": true, + "out": "htmldocs" + } +} diff --git a/test/types.d.ts b/test/types.d.ts new file mode 100644 index 0000000..fc082a4 --- /dev/null +++ b/test/types.d.ts @@ -0,0 +1,864 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +declare var $app: c.Handler;type _TygojaDict = { [key:string | number | symbol]: any; } +type _TygojaAny = any + +/** + * package a docs + * lorem ipsum dolor... + */ +namespace a { + interface Empty { + [key:string]: any; + } + /** + * unexported interface + */ + interface interfaceA { + [key:string]: any; + /** + * some comment + */ + /** + * some comment above the function + */ + Method0(): void + Method1(): string // inline comment + /** + * multi + * line + * comment + */ + Method2(argA: string, argB: string): [T, number] + Method3(argA: number, ...argB: string[]): [T, Array] + } + /** + * multi + * line + * comment + */ + interface InterfaceB { + [key:string]: any; + /** + * "replace" Method0 from interfaceA + */ + Method0(): void + CustomMethod(): time.Time + } + interface unexported { + Field1: string + } + /** + * structA comment + */ + interface structA { + Field1: string // after + /** + * multi + * line + * comment + * with union type + */ + Field2: string|Array + } + interface structA { + /** + * method comment + */ + Method1(arg1: number): void + } + interface structA { + Method2(arg1: number, ...arg2: string[]): void + } + /** + * structB comment + */ + type _sqJYikd = unexported&structA + interface StructB extends _sqJYikd { + Field3: T + } + /** + * structC with multiple mixed generic types + */ + interface StructC { + Field4: A + Field5: B + Field6: C + } + interface StructC { + /** + * StructC.Method4 comment + */ + Method4(arg1: A): [B, C] + } + /** + * type comment + */ + interface SliceAlias extends Array{} // after + /** + * multi + * line + * comment + */ + interface Handler {(): [T, number] } // after +} + +/** + * package b + */ +namespace b { + interface Func1 { + /** + * single comment + */ + (): void + } + interface Func2 { + /** + * multi + * line + * comment + */ + (arg1: number): T + } + interface Func3 { + /** + * function with multiple generic types + */ + (arg1: A, arg2: B, arg3: number): [A, C] + } + interface Func4 { + /** + * function that returns a function + */ + (arg1: number): () => number + } + interface Func5 { + /** + * function with ommited argument types + */ + (arg0: string, arg1: number, arg2: number): void + } + interface Func6 { + /** + * function with reserved argument name and variadic type + */ + (_arg00: string, ...optional: string[]): void + } + interface Func7 { + /** + * function with ommited argument names + */ + (_arg0: string, _arg1: number, ..._arg2: boolean[]): void + } + interface Func8 { + /** + * function with named return values + */ + (): [number, string] + } + interface Func9 { + /** + * function with shortened return values + */ + (): [string, string] + } + interface Func10 { + /** + * function with named and shortened return values + */ + (): [number, string, string] + } +} + +namespace c { + /** + * func type comment + */ + interface Handler {(): string } // after + /** + * Example: + * + * ``` + * Some + * code + * sample + * ``` + */ + interface Example2 { + Title: string + Json: Raw + Bytes: string|Array // should be union + } + interface Example2 { + DemoEx2(): time.Time + } + interface Example2 { + /** + * Pointer as argument vs return type + */ + DemoEx3(arg: Example1): (Example1) + } + interface Example2 { + /** + * ommited types + */ + DemoEx4(n1: string, n2: string, n3: string): void + } + interface Example2 { + /** + * ommited names + */ + DemoEx5(_arg0: string, _arg1: number): void + } + interface Example2 { + /** + * named return values + */ + DemoEx6(): [number, string] + } + interface Example2 { + /** + * shortened return values + */ + DemoEx7(): [string, string] + } + interface Example2 { + /** + * named and shortened return values + */ + DemoEx8(): [number, string, string] + } +} + +/** + * Package time provides functionality for measuring and displaying time. + * + * The calendrical calculations always assume a Gregorian calendar, with + * no leap seconds. + * + * # Monotonic Clocks + * + * Operating systems provide both a “wall clock,” which is subject to + * changes for clock synchronization, and a “monotonic clock,” which is + * not. The general rule is that the wall clock is for telling time and + * the monotonic clock is for measuring time. Rather than split the API, + * in this package the Time returned by [time.Now] contains both a wall + * clock reading and a monotonic clock reading; later time-telling + * operations use the wall clock reading, but later time-measuring + * operations, specifically comparisons and subtractions, use the + * monotonic clock reading. + * + * For example, this code always computes a positive elapsed time of + * approximately 20 milliseconds, even if the wall clock is changed during + * the operation being timed: + * + * ``` + * start := time.Now() + * ... operation that takes 20 milliseconds ... + * t := time.Now() + * elapsed := t.Sub(start) + * ``` + * + * Other idioms, such as [time.Since](start), [time.Until](deadline), and + * time.Now().Before(deadline), are similarly robust against wall clock + * resets. + * + * The rest of this section gives the precise details of how operations + * use monotonic clocks, but understanding those details is not required + * to use this package. + * + * The Time returned by time.Now contains a monotonic clock reading. + * If Time t has a monotonic clock reading, t.Add adds the same duration to + * both the wall clock and monotonic clock readings to compute the result. + * Because t.AddDate(y, m, d), t.Round(d), and t.Truncate(d) are wall time + * computations, they always strip any monotonic clock reading from their results. + * Because t.In, t.Local, and t.UTC are used for their effect on the interpretation + * of the wall time, they also strip any monotonic clock reading from their results. + * The canonical way to strip a monotonic clock reading is to use t = t.Round(0). + * + * If Times t and u both contain monotonic clock readings, the operations + * t.After(u), t.Before(u), t.Equal(u), t.Compare(u), and t.Sub(u) are carried out + * using the monotonic clock readings alone, ignoring the wall clock + * readings. If either t or u contains no monotonic clock reading, these + * operations fall back to using the wall clock readings. + * + * On some systems the monotonic clock will stop if the computer goes to sleep. + * On such a system, t.Sub(u) may not accurately reflect the actual + * time that passed between t and u. The same applies to other functions and + * methods that subtract times, such as [Since], [Until], [Before], [After], + * [Add], [Sub], [Equal] and [Compare]. In some cases, you may need to strip + * the monotonic clock to get accurate results. + * + * Because the monotonic clock reading has no meaning outside + * the current process, the serialized forms generated by t.GobEncode, + * t.MarshalBinary, t.MarshalJSON, and t.MarshalText omit the monotonic + * clock reading, and t.Format provides no format for it. Similarly, the + * constructors [time.Date], [time.Parse], [time.ParseInLocation], and [time.Unix], + * as well as the unmarshalers t.GobDecode, t.UnmarshalBinary. + * t.UnmarshalJSON, and t.UnmarshalText always create times with + * no monotonic clock reading. + * + * The monotonic clock reading exists only in [Time] values. It is not + * a part of [Duration] values or the Unix times returned by t.Unix and + * friends. + * + * Note that the Go == operator compares not just the time instant but + * also the [Location] and the monotonic clock reading. See the + * documentation for the Time type for a discussion of equality + * testing for Time values. + * + * For debugging, the result of t.String does include the monotonic + * clock reading if present. If t != u because of different monotonic clock readings, + * that difference will be visible when printing t.String() and u.String(). + * + * # Timer Resolution + * + * [Timer] resolution varies depending on the Go runtime, the operating system + * and the underlying hardware. + * On Unix, the resolution is ~1ms. + * On Windows version 1803 and newer, the resolution is ~0.5ms. + * On older Windows versions, the default resolution is ~16ms, but + * a higher resolution may be requested using [golang.org/x/sys/windows.TimeBeginPeriod]. + */ +namespace time { + interface Time { + /** + * String returns the time formatted using the format string + * + * ``` + * "2006-01-02 15:04:05.999999999 -0700 MST" + * ``` + * + * If the time has a monotonic clock reading, the returned string + * includes a final field "m=±", where value is the monotonic + * clock reading formatted as a decimal number of seconds. + * + * The returned string is meant for debugging; for a stable serialized + * representation, use t.MarshalText, t.MarshalBinary, or t.Format + * with an explicit format string. + */ + String(): string + } + interface Time { + /** + * GoString implements [fmt.GoStringer] and formats t to be printed in Go source + * code. + */ + GoString(): string + } + interface Time { + /** + * Format returns a textual representation of the time value formatted according + * to the layout defined by the argument. See the documentation for the + * constant called [Layout] to see how to represent the layout format. + * + * The executable example for [Time.Format] demonstrates the working + * of the layout string in detail and is a good reference. + */ + Format(layout: string): string + } + interface Time { + /** + * AppendFormat is like [Time.Format] but appends the textual + * representation to b and returns the extended buffer. + */ + AppendFormat(b: string|Array, layout: string): string|Array + } + /** + * A Time represents an instant in time with nanosecond precision. + * + * Programs using times should typically store and pass them as values, + * not pointers. That is, time variables and struct fields should be of + * type [time.Time], not *time.Time. + * + * A Time value can be used by multiple goroutines simultaneously except + * that the methods [Time.GobDecode], [Time.UnmarshalBinary], [Time.UnmarshalJSON] and + * [Time.UnmarshalText] are not concurrency-safe. + * + * Time instants can be compared using the [Time.Before], [Time.After], and [Time.Equal] methods. + * The [Time.Sub] method subtracts two instants, producing a [Duration]. + * The [Time.Add] method adds a Time and a Duration, producing a Time. + * + * The zero value of type Time is January 1, year 1, 00:00:00.000000000 UTC. + * As this time is unlikely to come up in practice, the [Time.IsZero] method gives + * a simple way of detecting a time that has not been initialized explicitly. + * + * Each time has an associated [Location]. The methods [Time.Local], [Time.UTC], and Time.In return a + * Time with a specific Location. Changing the Location of a Time value with + * these methods does not change the actual instant it represents, only the time + * zone in which to interpret it. + * + * Representations of a Time value saved by the [Time.GobEncode], [Time.MarshalBinary], + * [Time.MarshalJSON], and [Time.MarshalText] methods store the [Time.Location]'s offset, but not + * the location name. They therefore lose information about Daylight Saving Time. + * + * In addition to the required “wall clock” reading, a Time may contain an optional + * reading of the current process's monotonic clock, to provide additional precision + * for comparison or subtraction. + * See the “Monotonic Clocks” section in the package documentation for details. + * + * Note that the Go == operator compares not just the time instant but also the + * Location and the monotonic clock reading. Therefore, Time values should not + * be used as map or database keys without first guaranteeing that the + * identical Location has been set for all values, which can be achieved + * through use of the UTC or Local method, and that the monotonic clock reading + * has been stripped by setting t = t.Round(0). In general, prefer t.Equal(u) + * to t == u, since t.Equal uses the most accurate comparison available and + * correctly handles the case when only one of its arguments has a monotonic + * clock reading. + */ + interface Time { + } + interface Time { + /** + * After reports whether the time instant t is after u. + */ + After(u: Time): boolean + } + interface Time { + /** + * Before reports whether the time instant t is before u. + */ + Before(u: Time): boolean + } + interface Time { + /** + * Compare compares the time instant t with u. If t is before u, it returns -1; + * if t is after u, it returns +1; if they're the same, it returns 0. + */ + Compare(u: Time): number + } + interface Time { + /** + * Equal reports whether t and u represent the same time instant. + * Two times can be equal even if they are in different locations. + * For example, 6:00 +0200 and 4:00 UTC are Equal. + * See the documentation on the Time type for the pitfalls of using == with + * Time values; most code should use Equal instead. + */ + Equal(u: Time): boolean + } + interface Time { + /** + * IsZero reports whether t represents the zero time instant, + * January 1, year 1, 00:00:00 UTC. + */ + IsZero(): boolean + } + interface Time { + /** + * Date returns the year, month, and day in which t occurs. + */ + Date(): [number, Month, number] + } + interface Time { + /** + * Year returns the year in which t occurs. + */ + Year(): number + } + interface Time { + /** + * Month returns the month of the year specified by t. + */ + Month(): Month + } + interface Time { + /** + * Day returns the day of the month specified by t. + */ + Day(): number + } + interface Time { + /** + * Weekday returns the day of the week specified by t. + */ + Weekday(): Weekday + } + interface Time { + /** + * ISOWeek returns the ISO 8601 year and week number in which t occurs. + * Week ranges from 1 to 53. Jan 01 to Jan 03 of year n might belong to + * week 52 or 53 of year n-1, and Dec 29 to Dec 31 might belong to week 1 + * of year n+1. + */ + ISOWeek(): [number, number] + } + interface Time { + /** + * Clock returns the hour, minute, and second within the day specified by t. + */ + Clock(): [number, number, number] + } + interface Time { + /** + * Hour returns the hour within the day specified by t, in the range [0, 23]. + */ + Hour(): number + } + interface Time { + /** + * Minute returns the minute offset within the hour specified by t, in the range [0, 59]. + */ + Minute(): number + } + interface Time { + /** + * Second returns the second offset within the minute specified by t, in the range [0, 59]. + */ + Second(): number + } + interface Time { + /** + * Nanosecond returns the nanosecond offset within the second specified by t, + * in the range [0, 999999999]. + */ + Nanosecond(): number + } + interface Time { + /** + * YearDay returns the day of the year specified by t, in the range [1,365] for non-leap years, + * and [1,366] in leap years. + */ + YearDay(): number + } + interface Time { + /** + * Add returns the time t+d. + */ + Add(d: Duration): Time + } + interface Time { + /** + * Sub returns the duration t-u. If the result exceeds the maximum (or minimum) + * value that can be stored in a [Duration], the maximum (or minimum) duration + * will be returned. + * To compute t-d for a duration d, use t.Add(-d). + */ + Sub(u: Time): Duration + } + interface Time { + /** + * AddDate returns the time corresponding to adding the + * given number of years, months, and days to t. + * For example, AddDate(-1, 2, 3) applied to January 1, 2011 + * returns March 4, 2010. + * + * Note that dates are fundamentally coupled to timezones, and calendrical + * periods like days don't have fixed durations. AddDate uses the Location of + * the Time value to determine these durations. That means that the same + * AddDate arguments can produce a different shift in absolute time depending on + * the base Time value and its Location. For example, AddDate(0, 0, 1) applied + * to 12:00 on March 27 always returns 12:00 on March 28. At some locations and + * in some years this is a 24 hour shift. In others it's a 23 hour shift due to + * daylight savings time transitions. + * + * AddDate normalizes its result in the same way that Date does, + * so, for example, adding one month to October 31 yields + * December 1, the normalized form for November 31. + */ + AddDate(years: number, months: number, days: number): Time + } + interface Time { + /** + * UTC returns t with the location set to UTC. + */ + UTC(): Time + } + interface Time { + /** + * Local returns t with the location set to local time. + */ + Local(): Time + } + interface Time { + /** + * In returns a copy of t representing the same time instant, but + * with the copy's location information set to loc for display + * purposes. + * + * In panics if loc is nil. + */ + In(loc: Location): Time + } + interface Time { + /** + * Location returns the time zone information associated with t. + */ + Location(): (Location) + } + interface Time { + /** + * Zone computes the time zone in effect at time t, returning the abbreviated + * name of the zone (such as "CET") and its offset in seconds east of UTC. + */ + Zone(): [string, number] + } + interface Time { + /** + * ZoneBounds returns the bounds of the time zone in effect at time t. + * The zone begins at start and the next zone begins at end. + * If the zone begins at the beginning of time, start will be returned as a zero Time. + * If the zone goes on forever, end will be returned as a zero Time. + * The Location of the returned times will be the same as t. + */ + ZoneBounds(): [Time, Time] + } + interface Time { + /** + * Unix returns t as a Unix time, the number of seconds elapsed + * since January 1, 1970 UTC. The result does not depend on the + * location associated with t. + * Unix-like operating systems often record time as a 32-bit + * count of seconds, but since the method here returns a 64-bit + * value it is valid for billions of years into the past or future. + */ + Unix(): number + } + interface Time { + /** + * UnixMilli returns t as a Unix time, the number of milliseconds elapsed since + * January 1, 1970 UTC. The result is undefined if the Unix time in + * milliseconds cannot be represented by an int64 (a date more than 292 million + * years before or after 1970). The result does not depend on the + * location associated with t. + */ + UnixMilli(): number + } + interface Time { + /** + * UnixMicro returns t as a Unix time, the number of microseconds elapsed since + * January 1, 1970 UTC. The result is undefined if the Unix time in + * microseconds cannot be represented by an int64 (a date before year -290307 or + * after year 294246). The result does not depend on the location associated + * with t. + */ + UnixMicro(): number + } + interface Time { + /** + * UnixNano returns t as a Unix time, the number of nanoseconds elapsed + * since January 1, 1970 UTC. The result is undefined if the Unix time + * in nanoseconds cannot be represented by an int64 (a date before the year + * 1678 or after 2262). Note that this means the result of calling UnixNano + * on the zero Time is undefined. The result does not depend on the + * location associated with t. + */ + UnixNano(): number + } + interface Time { + /** + * MarshalBinary implements the encoding.BinaryMarshaler interface. + */ + MarshalBinary(): string|Array + } + interface Time { + /** + * UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. + */ + UnmarshalBinary(data: string|Array): void + } + interface Time { + /** + * GobEncode implements the gob.GobEncoder interface. + */ + GobEncode(): string|Array + } + interface Time { + /** + * GobDecode implements the gob.GobDecoder interface. + */ + GobDecode(data: string|Array): void + } + interface Time { + /** + * MarshalJSON implements the [json.Marshaler] interface. + * The time is a quoted string in the RFC 3339 format with sub-second precision. + * If the timestamp cannot be represented as valid RFC 3339 + * (e.g., the year is out of range), then an error is reported. + */ + MarshalJSON(): string|Array + } + interface Time { + /** + * UnmarshalJSON implements the [json.Unmarshaler] interface. + * The time must be a quoted string in the RFC 3339 format. + */ + UnmarshalJSON(data: string|Array): void + } + interface Time { + /** + * MarshalText implements the [encoding.TextMarshaler] interface. + * The time is formatted in RFC 3339 format with sub-second precision. + * If the timestamp cannot be represented as valid RFC 3339 + * (e.g., the year is out of range), then an error is reported. + */ + MarshalText(): string|Array + } + interface Time { + /** + * UnmarshalText implements the [encoding.TextUnmarshaler] interface. + * The time must be in the RFC 3339 format. + */ + UnmarshalText(data: string|Array): void + } + interface Time { + /** + * IsDST reports whether the time in the configured location is in Daylight Savings Time. + */ + IsDST(): boolean + } + interface Time { + /** + * Truncate returns the result of rounding t down to a multiple of d (since the zero time). + * If d <= 0, Truncate returns t stripped of any monotonic clock reading but otherwise unchanged. + * + * Truncate operates on the time as an absolute duration since the + * zero time; it does not operate on the presentation form of the + * time. Thus, Truncate(Hour) may return a time with a non-zero + * minute, depending on the time's Location. + */ + Truncate(d: Duration): Time + } + interface Time { + /** + * Round returns the result of rounding t to the nearest multiple of d (since the zero time). + * The rounding behavior for halfway values is to round up. + * If d <= 0, Round returns t stripped of any monotonic clock reading but otherwise unchanged. + * + * Round operates on the time as an absolute duration since the + * zero time; it does not operate on the presentation form of the + * time. Thus, Round(Hour) may return a time with a non-zero + * minute, depending on the time's Location. + */ + Round(d: Duration): Time + } +} + +namespace c { + interface Raw extends Array{} + interface Example1 { + Name: string + } + interface Example1 { + DemoEx1(): string + } +} + +namespace time { + /** + * A Month specifies a month of the year (January = 1, ...). + */ + interface Month extends Number{} + interface Month { + /** + * String returns the English name of the month ("January", "February", ...). + */ + String(): string + } + /** + * A Weekday specifies a day of the week (Sunday = 0, ...). + */ + interface Weekday extends Number{} + interface Weekday { + /** + * String returns the English name of the day ("Sunday", "Monday", ...). + */ + String(): string + } + /** + * A Duration represents the elapsed time between two instants + * as an int64 nanosecond count. The representation limits the + * largest representable duration to approximately 290 years. + */ + interface Duration extends Number{} + interface Duration { + /** + * String returns a string representing the duration in the form "72h3m0.5s". + * Leading zero units are omitted. As a special case, durations less than one + * second format use a smaller unit (milli-, micro-, or nanoseconds) to ensure + * that the leading digit is non-zero. The zero duration formats as 0s. + */ + String(): string + } + interface Duration { + /** + * Nanoseconds returns the duration as an integer nanosecond count. + */ + Nanoseconds(): number + } + interface Duration { + /** + * Microseconds returns the duration as an integer microsecond count. + */ + Microseconds(): number + } + interface Duration { + /** + * Milliseconds returns the duration as an integer millisecond count. + */ + Milliseconds(): number + } + interface Duration { + /** + * Seconds returns the duration as a floating point number of seconds. + */ + Seconds(): number + } + interface Duration { + /** + * Minutes returns the duration as a floating point number of minutes. + */ + Minutes(): number + } + interface Duration { + /** + * Hours returns the duration as a floating point number of hours. + */ + Hours(): number + } + interface Duration { + /** + * Truncate returns the result of rounding d toward zero to a multiple of m. + * If m <= 0, Truncate returns d unchanged. + */ + Truncate(m: Duration): Duration + } + interface Duration { + /** + * Round returns the result of rounding d to the nearest multiple of m. + * The rounding behavior for halfway values is to round away from zero. + * If the result exceeds the maximum (or minimum) + * value that can be stored in a [Duration], + * Round returns the maximum (or minimum) duration. + * If m <= 0, Round returns d unchanged. + */ + Round(m: Duration): Duration + } + interface Duration { + /** + * Abs returns the absolute value of d. + * As a special case, [math.MinInt64] is converted to [math.MaxInt64]. + */ + Abs(): Duration + } + /** + * A Location maps time instants to the zone in use at that time. + * Typically, the Location represents the collection of time offsets + * in use in a geographical area. For many Locations the time offset varies + * depending on whether daylight savings time is in use at the time instant. + * + * Location is used to provide a time zone in a printed Time value and for + * calculations involving intervals that may cross daylight savings time + * boundaries. + */ + interface Location { + } + interface Location { + /** + * String returns a descriptive name for the time zone information, + * corresponding to the name argument to [LoadLocation] or [FixedZone]. + */ + String(): string + } +} diff --git a/tygoja.go b/tygoja.go new file mode 100644 index 0000000..3fcd4d9 --- /dev/null +++ b/tygoja.go @@ -0,0 +1,264 @@ +package tygoja + +import ( + "fmt" + "path/filepath" + "regexp" + "strings" + + "golang.org/x/tools/go/packages" +) + +// Tygoja is a generator for one or more input packages, +// responsible for linking them together if necessary. +type Tygoja struct { + conf *Config + + parent *Tygoja + implicitPackages map[string][]string + generatedTypes map[string][]string + generatedPackageDocs map[string]struct{} +} + +// New initializes a new Tygoja generator from the specified config. +func New(config Config) *Tygoja { + config.InitDefaults() + + return &Tygoja{ + conf: &config, + implicitPackages: map[string][]string{}, + generatedTypes: map[string][]string{}, + generatedPackageDocs: map[string]struct{}{}, + } +} + +// Generate executes the generator and produces the related TS files. +func (g *Tygoja) Generate() (string, error) { + // extract config packages + configPackages := make([]string, 0, len(g.conf.Packages)) + for p, types := range g.conf.Packages { + if len(types) == 0 { + continue // no typings + } + configPackages = append(configPackages, p) + } + + // load packages info + pkgs, err := packages.Load(&packages.Config{ + Mode: packages.NeedSyntax | packages.NeedFiles | packages.NeedDeps | packages.NeedImports | packages.NeedTypes, + }, configPackages...) + if err != nil { + return "", err + } + + var s strings.Builder + + // Heading + if g.parent == nil { + s.WriteString("// GENERATED CODE - DO NOT MODIFY BY HAND\n") + + if g.conf.Heading != "" { + s.WriteString(g.conf.Heading) + } + + // write base types + // --- + s.WriteString("type ") + s.WriteString(BaseTypeDict) + s.WriteString(" = { [key:string | number | symbol]: any; }\n") + + s.WriteString("type ") + s.WriteString(BaseTypeAny) + s.WriteString(" = any\n") + // --- + } + + for i, pkg := range pkgs { + if len(pkg.Errors) > 0 { + return "", fmt.Errorf("%+v", pkg.Errors) + } + + if len(pkg.GoFiles) == 0 { + return "", fmt.Errorf("no input go files for package index %d", i) + } + + if len(g.conf.Packages[pkg.ID]) == 0 { + // ignore the package as it has no typings + continue + } + + pkgGen := &PackageGenerator{ + conf: g.conf, + pkg: pkg, + types: g.conf.Packages[pkg.ID], + withPkgDoc: !g.isPackageDocGenerated(pkg.ID), + generatedTypes: map[string]struct{}{}, + unknownTypes: map[string]struct{}{}, + imports: map[string][]string{}, + } + + code, err := pkgGen.Generate() + if err != nil { + return "", err + } + + g.generatedPackageDocs[pkg.ID] = struct{}{} + + for t := range pkgGen.generatedTypes { + g.generatedTypes[pkg.ID] = append(g.generatedTypes[pkg.ID], t) + } + + for t := range pkgGen.unknownTypes { + parts := strings.Split(t, ".") + var tPkg string + var tName string + + if len(parts) == 0 { + continue + } + + if len(parts) == 2 { + // type from external package + tPkg = parts[0] + tName = parts[1] + } else { + // unexported type from the current package + tName = parts[0] + + // already mapped for export + if pkgGen.isTypeAllowed(tName) { + continue + } + + tPkg = packageNameFromPath(pkg.ID) + + // add to self import later + pkgGen.imports[pkg.ID] = []string{tPkg} + } + + for p, aliases := range pkgGen.imports { + for _, alias := range aliases { + if tName != "" && alias == tPkg && !g.isTypeGenerated(p, tName) && !exists(g.implicitPackages[p], tName) { + if g.implicitPackages[p] == nil { + g.implicitPackages[p] = []string{} + } + g.implicitPackages[p] = append(g.implicitPackages[p], tName) + break + } + } + } + } + + s.WriteString(code) + } + + // recursively try to generate the found unknown types + if len(g.implicitPackages) > 0 { + subConfig := *g.conf + subConfig.Heading = "" + if (subConfig.TypeMappings) == nil { + subConfig.TypeMappings = map[string]string{} + } + + // extract the nonempty package definitions + subConfig.Packages = make(map[string][]string, len(g.implicitPackages)) + for p, types := range g.implicitPackages { + if len(types) == 0 { + continue + } + subConfig.Packages[p] = types + } + + subGenerator := New(subConfig) + subGenerator.parent = g + subResult, err := subGenerator.Generate() + if err != nil { + return "", err + } + + s.WriteString(subResult) + } + + return s.String(), nil +} + +func (g *Tygoja) isPackageDocGenerated(pkgId string) bool { + _, ok := g.generatedPackageDocs[pkgId] + if ok { + return true + } + + if g.parent != nil { + return g.parent.isPackageDocGenerated(pkgId) + } + + return false +} + +func (g *Tygoja) isTypeGenerated(pkg string, name string) bool { + if g.parent != nil && g.parent.isTypeGenerated(pkg, name) { + return true + } + + if len(g.generatedTypes[pkg]) == 0 { + return false + } + + for _, t := range g.generatedTypes[pkg] { + if t == name { + return true + } + } + + return false +} + +// isTypeAllowed checks whether the provided type name is allowed by the generator "types". +func (g *PackageGenerator) isTypeAllowed(name string) bool { + name = strings.TrimSpace(name) + + if name == "" { + return false + } + + for _, t := range g.types { + if t == name || t == "*" { + return true + } + } + + return false +} + +func (g *PackageGenerator) markTypeAsGenerated(t string) { + g.generatedTypes[t] = struct{}{} +} + +var versionRegex = regexp.MustCompile(`^v\d+$`) + +// packageNameFromPath extracts and normalizes the imported package identifier. +// +// For example: +// +// "github.com/labstack/echo/v5" -> "echo" +// "github.com/go-ozzo/ozzo-validation/v4" -> "ozzo_validation" +func packageNameFromPath(path string) string { + name := filepath.Base(strings.Trim(path, `"' `)) + + if versionRegex.MatchString(name) { + name = filepath.Base(filepath.Dir(path)) + } + + return strings.ReplaceAll(name, "-", "_") +} + +// exists checks if search exists in list. +func exists[T comparable](list []T, search T) bool { + for _, v := range list { + if v == search { + return true + } + } + + return false +} diff --git a/write_comment.go b/write_comment.go new file mode 100644 index 0000000..ad29985 --- /dev/null +++ b/write_comment.go @@ -0,0 +1,66 @@ +package tygoja + +import ( + "go/ast" + "strings" +) + +func (g *PackageGenerator) writeCommentGroup(s *strings.Builder, f *ast.CommentGroup, depth int) { + if f == nil { + return + } + + docLines := strings.Split(f.Text(), "\n") + + g.writeIndent(s, depth) + s.WriteString("/**\n") + + lastLineIdx := len(docLines) - 1 + + var isCodeBlock bool + + emptySB := new(strings.Builder) + + for i, c := range docLines { + isEndLine := i == lastLineIdx + isEmpty := len(strings.TrimSpace(c)) == 0 + isIndented := strings.HasPrefix(c, "\t") || strings.HasPrefix(c, " ") + + // end code block + if isCodeBlock && (isEndLine || (!isIndented && !isEmpty)) { + g.writeIndent(s, depth) + s.WriteString(" * ```\n") + isCodeBlock = false + } + + // accumulate empty comment lines + // (this is done to properly enclose code blocks with new lines) + if isEmpty { + g.writeIndent(emptySB, depth) + emptySB.WriteString(" * \n") + } else { + // write all empty lines + s.WriteString(emptySB.String()) + emptySB.Reset() + } + + // start code block + if isIndented && !isCodeBlock && !isEndLine { + g.writeIndent(s, depth) + s.WriteString(" * ```\n") + isCodeBlock = true + } + + // write comment line + if !isEmpty { + g.writeIndent(s, depth) + s.WriteString(" * ") + c = strings.ReplaceAll(c, "*/", "*\\/") // An edge case: a // comment can contain */ + s.WriteString(c) + s.WriteByte('\n') + } + } + + g.writeIndent(s, depth) + s.WriteString(" */\n") +} diff --git a/write_toplevel.go b/write_toplevel.go new file mode 100644 index 0000000..a9b461a --- /dev/null +++ b/write_toplevel.go @@ -0,0 +1,409 @@ +package tygoja + +import ( + "fmt" + "go/ast" + "strings" +) + +type groupContext struct { + isGroupedDeclaration bool + doc *ast.CommentGroup + groupValue string + groupType string + iotaValue int + iotaOffset int +} + +// Writing of function declarations, which are expressions like +// "func Count() int" +// or +// "func (s *Counter) total() int" +func (g *PackageGenerator) writeFuncDecl(s *strings.Builder, decl *ast.FuncDecl, depth int) { + if decl.Name == nil || len(decl.Name.Name) == 0 || decl.Name.Name[0] < 'A' || decl.Name.Name[0] > 'Z' { + return // unexported function/method + } + + originalMethodName := decl.Name.Name + methodName := originalMethodName + if g.conf.MethodNameFormatter != nil { + methodName = g.conf.MethodNameFormatter(methodName) + } + + if decl.Recv == nil { + if !g.conf.WithPackageFunctions { + return // skip package level functions + } + + if !g.isTypeAllowed(originalMethodName) { + return + } else { + g.markTypeAsGenerated(originalMethodName) + } + + g.writeStartModifier(s, depth) + s.WriteString("interface ") + + if isReservedIdentifier(methodName) { + s.WriteString("_" + methodName) + } else { + s.WriteString(methodName) + } + + if decl.Type.TypeParams != nil { + g.writeTypeParamsFields(s, decl.Type.TypeParams.List) + } + + s.WriteString(" {\n") + if decl.Doc != nil { + g.writeCommentGroup(s, decl.Doc, depth+1) + } + g.writeIndent(s, depth+1) + g.writeType(s, decl.Type, depth+1) + s.WriteString("\n") + g.writeIndent(s, depth) + s.WriteString("}\n") + } else if len(decl.Recv.List) == 1 { + // write struct method as new interface method + // (note that TS will "merge" the definitions of multiple interfaces with the same name) + + // treat pointer and value receivers the same + recvType := decl.Recv.List[0].Type + if p, isPointer := recvType.(*ast.StarExpr); isPointer { + recvType = p.X + } + + var recvName string + switch recv := recvType.(type) { + case *ast.Ident: + recvName = recv.Name + case *ast.IndexExpr: + case *ast.IndexListExpr: + if v, ok := recv.X.(*ast.Ident); ok { + recvName = v.Name + } + } + + if !g.isTypeAllowed(recvName) { + return + } else { + g.markTypeAsGenerated(recvName) + } + + g.writeStartModifier(s, depth) + s.WriteString("interface ") + + g.writeType(s, recvType, depth) + + s.WriteString(" {\n") + if decl.Doc != nil { + g.writeCommentGroup(s, decl.Doc, depth+1) + } + g.writeIndent(s, depth+1) + s.WriteString(methodName) + g.writeType(s, decl.Type, depth+1) + s.WriteString("\n") + g.writeIndent(s, depth) + s.WriteString("}\n") + } +} + +func (g *PackageGenerator) writeGroupDecl(s *strings.Builder, decl *ast.GenDecl, depth int) { + // We need a bit of state to handle syntax like + // const ( + // X SomeType = iota + // _ + // Y + // Foo string = "Foo" + // _ + // AlsoFoo + // ) + group := &groupContext{ + isGroupedDeclaration: len(decl.Specs) > 1, + doc: decl.Doc, + groupType: "", + groupValue: "", + iotaValue: -1, + } + + for _, spec := range decl.Specs { + g.writeSpec(s, spec, group, depth) + } +} + +func (g *PackageGenerator) writeSpec(s *strings.Builder, spec ast.Spec, group *groupContext, depth int) { + // e.g. "type Foo struct {}" or "type Bar = string" + ts, ok := spec.(*ast.TypeSpec) + if ok { + g.writeTypeSpec(s, ts, group, depth) + } + + // e.g. "const Foo = 123" + vs, ok := spec.(*ast.ValueSpec) + if ok && g.conf.WithConstants { + g.writeValueSpec(s, vs, group, depth) + } +} + +// Writing of type specs, which are expressions like +// "type X struct { ... }" +// or +// "type Bar = string" +func (g *PackageGenerator) writeTypeSpec(s *strings.Builder, ts *ast.TypeSpec, group *groupContext, depth int) { + var typeName string + if ts.Name != nil { + typeName = ts.Name.Name + } + + if !g.isTypeAllowed(typeName) { + return + } else { + g.markTypeAsGenerated(typeName) + } + + if ts.Doc != nil { + // the spec has its own comment, which overrules the grouped comment + g.writeCommentGroup(s, ts.Doc, depth) + } else { + g.writeCommentGroup(s, group.doc, depth) + } + + switch v := ts.Type.(type) { + case *ast.StructType: + // eg. "type X struct { ... }" + + var extendTypeName string + + // convert embeded structs to "extends SUB_TYPE" declaration + // + // note: we don't use "extends A, B, C" form but intersecion subtype + // with all embeded structs to avoid methods merge conflicts + // eg. bufio.ReadWriter has different Writer.Read() and Reader.Read() + if v.Fields != nil { + var embeds []*ast.Field + for _, f := range v.Fields.List { + if len(f.Names) == 0 || f.Names[0].Name == "" { + embeds = append(embeds, f) + } + } + + if len(embeds) > 0 { + extendTypeName = "_s" + PseudorandomString(6) + + genericArgs := map[string]struct{}{} + identSB := new(strings.Builder) + embedsSB := new(strings.Builder) + for i, f := range embeds { + if i > 0 { + embedsSB.WriteString("&") + } + + typ := f.Type + if p, isPointer := typ.(*ast.StarExpr); isPointer { + typ = p.X + } + + identSB.Reset() + g.writeType(identSB, typ, depth, optionParenthesis, optionExtends) + ident := identSB.String() + + if idx := strings.Index(ident, "<"); idx > 1 { // has at least 2 characters for <> + genericArgs[ident[idx+1:len(ident)-1]] = struct{}{} + } + + embedsSB.WriteString(ident) + } + + if len(genericArgs) > 0 { + args := make([]string, 0, len(genericArgs)) + for g := range genericArgs { + args = append(args, g) + } + extendTypeName = extendTypeName + "<" + strings.Join(args, ",") + ">" + } + + g.writeIndent(s, depth) + s.WriteString("type ") + s.WriteString(extendTypeName) + s.WriteString(" = ") + s.WriteString(embedsSB.String()) + s.WriteString("\n") + } + } + + g.writeStartModifier(s, depth) + s.WriteString("interface ") + s.WriteString(typeName) + + if ts.TypeParams != nil { + g.writeTypeParamsFields(s, ts.TypeParams.List) + } + + if extendTypeName != "" { + s.WriteString(" extends ") + s.WriteString(extendTypeName) + } + + s.WriteString(" {\n") + g.writeStructFields(s, v.Fields.List, depth) + g.writeIndent(s, depth) + s.WriteString("}") + case *ast.InterfaceType: + // eg. "type X interface { ... }" + + g.writeStartModifier(s, depth) + s.WriteString("interface ") + s.WriteString(typeName) + + if ts.TypeParams != nil { + g.writeTypeParamsFields(s, ts.TypeParams.List) + } + + s.WriteString(" {\n") + + // fallback so that it doesn't report an error when attempting + // to access a field or method from a struct that implements the interface + g.writeIndent(s, depth+1) + s.WriteString("[key:string]: any;\n") + + g.writeInterfaceFields(s, v.Methods.List, depth) + g.writeIndent(s, depth) + s.WriteString("}") + case *ast.FuncType: + // eg. "type Handler func() any" + + g.writeStartModifier(s, depth) + s.WriteString("interface ") + s.WriteString(typeName) + + if ts.TypeParams != nil { + g.writeTypeParamsFields(s, ts.TypeParams.List) + } + + s.WriteString(" {") + g.writeFuncType(s, v, depth, false) + g.writeIndent(s, depth) + s.WriteString("}") + default: + // other Go type declarations like "type JsonArray []any" + // (note: we don't use "type X = Y", but "interface X extends Y" syntax to allow later defining methods to the X type) + + var baseType string + subSB := new(strings.Builder) + g.writeType(subSB, ts.Type, depth, optionParenthesis, optionExtends) + switch baseType = subSB.String(); baseType { + // primitives can't be extended so we use their Object equivivalents + case "number", "string", "boolean": + baseType = strings.ToUpper(string(baseType[0])) + baseType[1:] + case "any": + baseType = BaseTypeAny + } + + g.writeStartModifier(s, depth) + s.WriteString("interface ") + s.WriteString(typeName) + + if ts.TypeParams != nil { + g.writeTypeParamsFields(s, ts.TypeParams.List) + } + + s.WriteString(" extends ") + + s.WriteString(baseType) + + s.WriteString("{}") + } + + if ts.Comment != nil { + s.WriteString(" // " + ts.Comment.Text()) + } else { + s.WriteString("\n") + } +} + +// Writing of value specs, which are exported const expressions like +// const SomeValue = 3 +func (g *PackageGenerator) writeValueSpec(s *strings.Builder, vs *ast.ValueSpec, group *groupContext, depth int) { + for i, name := range vs.Names { + group.iotaValue = group.iotaValue + 1 + if name.Name == "_" { + continue + } + + if !g.isTypeAllowed(name.Name) { + continue + } else { + g.markTypeAsGenerated(name.Name) + } + + constName := name.Name + if isReservedIdentifier(constName) { + constName = "_" + constName + } + + if vs.Doc != nil { // The spec has its own comment, which overrules the grouped comment. + g.writeCommentGroup(s, vs.Doc, depth) + } else if group.isGroupedDeclaration { + g.writeCommentGroup(s, group.doc, depth) + } + + hasExplicitValue := len(vs.Values) > i + if hasExplicitValue { + group.groupType = "" + } + + g.writeStartModifier(s, depth) + s.WriteString("const ") + s.WriteString(constName) + + if vs.Type != nil { + s.WriteString(": ") + + tempSB := &strings.Builder{} + g.writeType(tempSB, vs.Type, depth, optionParenthesis) + typeString := tempSB.String() + + s.WriteString(typeString) + group.groupType = typeString + } else if group.groupType != "" && !hasExplicitValue { + s.WriteString(": ") + s.WriteString(group.groupType) + } + + s.WriteString(" = ") + + if hasExplicitValue { + val := vs.Values[i] + tempSB := &strings.Builder{} + g.writeType(tempSB, val, depth, optionParenthesis) + + valueString := tempSB.String() + if isProbablyIotaType(valueString) { + iotaV, err := basicIotaOffsetValueParse(valueString) + if err != nil { + // fallback + group.groupValue = valueString + } else { + group.iotaOffset = iotaV + group.groupValue = "iota" + valueString = fmt.Sprint(group.iotaValue + group.iotaOffset) + } + } else { + group.groupValue = valueString + } + s.WriteString(valueString) + } else { // We must use the previous value or +1 in case of iota + valueString := group.groupValue + if group.groupValue == "iota" { + valueString = fmt.Sprint(group.iotaValue + group.iotaOffset) + } + s.WriteString(valueString) + } + + if vs.Comment != nil { + s.WriteString(" // " + vs.Comment.Text()) + } else { + s.WriteByte('\n') + } + } +} diff --git a/write_types.go b/write_types.go new file mode 100644 index 0000000..106b4d6 --- /dev/null +++ b/write_types.go @@ -0,0 +1,461 @@ +package tygoja + +import ( + "fmt" + "log" + "regexp" + "strings" + + "go/ast" + "go/token" +) + +// Options for the writeType() method that can be used for extra context +// to determine the format of the return type. +const ( + optionExtends = "extends" + optionParenthesis = "parenthesis" + optionFunctionReturn = "func_return" +) + +func (g *PackageGenerator) writeIndent(s *strings.Builder, depth int) { + for i := 0; i < depth; i++ { + s.WriteString(g.conf.Indent) + } +} + +func (g *PackageGenerator) writeStartModifier(s *strings.Builder, depth int) { + g.writeIndent(s, depth) + + if g.conf.StartModifier != "" { + s.WriteString(g.conf.StartModifier) + s.WriteString(" ") + } +} + +func (g *PackageGenerator) writeType(s *strings.Builder, t ast.Expr, depth int, options ...string) { + switch t := t.(type) { + case *ast.StarExpr: + if hasOption(optionParenthesis, options) { + s.WriteByte('(') + } + + g.writeType(s, t.X, depth) + + // allow undefined union only when not used in an "extends" expression or as return type + if !hasOption(optionExtends, options) && !hasOption(optionFunctionReturn, options) { + s.WriteString(" | undefined") + } + + if hasOption(optionParenthesis, options) { + s.WriteByte(')') + } + case *ast.Ellipsis: + if v, ok := t.Elt.(*ast.Ident); ok && v.String() == "byte" { + s.WriteString("string") + break + } + + // wrap variadic args with parenthesis to support function declarations + // (eg. "...callbacks: (() => number)[]") + _, isFunc := t.Elt.(*ast.FuncType) + if isFunc { + s.WriteString("(") + } + + g.writeType(s, t.Elt, depth, optionParenthesis) + + if isFunc { + s.WriteString(")") + } + + s.WriteString("[]") + case *ast.ArrayType: + if v, ok := t.Elt.(*ast.Ident); ok && v.String() == "byte" && !hasOption(optionExtends, options) { + // union type with string since depending where it is used + // goja auto converts string to []byte if the field expect that + s.WriteString("string|") + } + + s.WriteString("Array<") + g.writeType(s, t.Elt, depth, optionParenthesis) + s.WriteString(">") + case *ast.StructType: + s.WriteString("{\n") + g.writeStructFields(s, t.Fields.List, depth+1) + g.writeIndent(s, depth+1) + s.WriteByte('}') + case *ast.Ident: + v := t.String() + + mappedType, ok := g.conf.TypeMappings[v] + if ok { + // use the mapped type + v = mappedType + } else { + // try to find a matching js equivalent + switch v { + case "string": + v = "string" + case "bool": + v = "boolean" + case "int", "int8", "int16", "int32", "int64", + "uint", "uint8", "uint16", "uint32", "uint64", + "float32", "float64", + "complex64", "complex128", + "uintptr", "byte", "rune": + v = "number" + case "error": + v = "Error" + default: + g.unknownTypes[v] = struct{}{} + } + } + + s.WriteString(v) + case *ast.SelectorExpr: + // e.g. `unsafe.Pointer` or `unsafe.*` + fullType := fmt.Sprintf("%s.%s", t.X, t.Sel) + fullTypeWildcard := fmt.Sprintf("%s.*", t.X) + + if v, ok := g.conf.TypeMappings[fullType]; ok { + s.WriteString(v) + } else if v, ok := g.conf.TypeMappings[fullTypeWildcard]; ok { + s.WriteString(v) + } else { + g.unknownTypes[fullType] = struct{}{} + s.WriteString(fullType) + } + case *ast.MapType: + s.WriteString("_TygojaDict") + case *ast.BasicLit: + s.WriteString(t.Value) + case *ast.ParenExpr: + s.WriteByte('(') + g.writeType(s, t.X, depth) + s.WriteByte(')') + case *ast.BinaryExpr: + g.writeType(s, t.X, depth) + s.WriteByte(' ') + s.WriteString(t.Op.String()) + s.WriteByte(' ') + g.writeType(s, t.Y, depth) + case *ast.InterfaceType: + s.WriteString("{\n") + g.writeInterfaceFields(s, t.Methods.List, depth) + g.writeIndent(s, depth+1) + s.WriteByte('}') + case *ast.FuncType: + g.writeFuncType(s, t, depth, hasOption(optionParenthesis, options)) + case *ast.UnaryExpr: + if t.Op == token.TILDE { + // we just ignore the tilde token, in Typescript extended types are + // put into the generic typing itself, which we can't support yet. + g.writeType(s, t.X, depth) + } else { + // only log for now + log.Printf("unhandled unary expr: %v\n %T\n", t, t) + } + case *ast.IndexListExpr: + g.writeType(s, t.X, depth) + s.WriteByte('<') + for i, index := range t.Indices { + g.writeType(s, index, depth) + if i != len(t.Indices)-1 { + s.WriteString(", ") + } + } + s.WriteByte('>') + case *ast.IndexExpr: + g.writeType(s, t.X, depth) + s.WriteByte('<') + g.writeType(s, t.Index, depth) + s.WriteByte('>') + case *ast.CallExpr, *ast.ChanType, *ast.CompositeLit: + s.WriteString("undefined") + default: + s.WriteString("any") + } +} + +func (g *PackageGenerator) writeTypeParamsFields(s *strings.Builder, fields []*ast.Field) { + // extract params + names := []string{} + for _, f := range fields { + for _, ident := range f.Names { + names = append(names, ident.Name) + + // disable extends for now as it complicates the interfaces merge + // + // s.WriteString(" extends ") + // g.writeType(s, f.Type, 0, true) + // if i != len(fields)-1 || j != len(f.Names)-1 { + // s.WriteString(", ") + // } + } + } + + if len(names) == 0 { + return + } + + s.WriteByte('<') + + for i, name := range names { + if i > 0 { + s.WriteString(",") + } + s.WriteString(name) + } + + s.WriteByte('>') +} + +func (g *PackageGenerator) writeInterfaceFields(s *strings.Builder, fields []*ast.Field, depth int) { + for _, f := range fields { + g.writeCommentGroup(s, f.Doc, depth+1) + + var methodName string + if len(f.Names) != 0 && f.Names[0] != nil && len(f.Names[0].Name) != 0 { + methodName = f.Names[0].Name + } + if len(methodName) == 0 || 'A' > methodName[0] || methodName[0] > 'Z' { + continue + } + + if g.conf.MethodNameFormatter != nil { + methodName = g.conf.MethodNameFormatter(methodName) + } + + g.writeIndent(s, depth+1) + s.WriteString(methodName) + g.writeType(s, f.Type, depth) + + if f.Comment != nil { + s.WriteString(" // ") + s.WriteString(f.Comment.Text()) + } else { + s.WriteByte('\n') + } + } +} + +func (g *PackageGenerator) writeStructFields(s *strings.Builder, fields []*ast.Field, depth int) { + for _, f := range fields { + var fieldName string + if len(f.Names) != 0 && f.Names[0] != nil && len(f.Names[0].Name) != 0 { + fieldName = f.Names[0].Name + } + if len(fieldName) == 0 || 'A' > fieldName[0] || fieldName[0] > 'Z' { + continue + } + + if g.conf.FieldNameFormatter != nil { + fieldName = g.conf.FieldNameFormatter(fieldName) + } + + g.writeCommentGroup(s, f.Doc, depth+1) + + g.writeIndent(s, depth+1) + quoted := !isValidJSName(fieldName) + if quoted { + s.WriteByte('\'') + } + s.WriteString(fieldName) + if quoted { + s.WriteByte('\'') + } + + // check if it is nil-able, aka. optional + switch t := f.Type.(type) { + case *ast.StarExpr: + f.Type = t.X + s.WriteByte('?') + } + + s.WriteString(": ") + g.writeType(s, f.Type, depth, optionParenthesis) + + if f.Comment != nil { + // Line comment is present, that means a comment after the field. + s.WriteString(" // ") + s.WriteString(f.Comment.Text()) + } else { + s.WriteByte('\n') + } + } +} + +func (g *PackageGenerator) writeFuncType(s *strings.Builder, t *ast.FuncType, depth int, returnAsProp bool) { + s.WriteString("(") + + if t.Params != nil { + g.writeFuncParams(s, t.Params.List, depth) + } + + if returnAsProp { + s.WriteString(") => ") + } else { + s.WriteString("): ") + } + + // (from https://pkg.go.dev/github.com/dop251/goja) + // Functions with multiple return values return an Array. + // If the last return value is an `error` it is not returned but converted into a JS exception. + // If the error is *Exception, it is thrown as is, otherwise it's wrapped in a GoEerror. + // Note that if there are exactly two return values and the last is an `error`, + // the function returns the first value as is, not an Array. + if t.Results == nil || len(t.Results.List) == 0 { + s.WriteString("void") + } else { + // remove the last return error type + lastReturn, ok := t.Results.List[len(t.Results.List)-1].Type.(*ast.Ident) + if ok && lastReturn.Name == "error" { + t.Results.List = t.Results.List[:len(t.Results.List)-1] + } + + if len(t.Results.List) == 0 { + s.WriteString("void") + } else { + // multiple and shortened return type values must be wrapped in [] + // (combined/shortened return values from the same type are part of a single ast.Field but with different names) + hasMultipleReturnValues := len(t.Results.List) > 1 || len(t.Results.List[0].Names) > 1 + if hasMultipleReturnValues { + s.WriteRune('[') + } + + for i, f := range t.Results.List { + totalNames := max(len(f.Names), 1) + for j := range totalNames { + if i > 0 || j > 0 { + s.WriteString(", ") + } + + g.writeType(s, f.Type, 0, optionParenthesis, optionFunctionReturn) + } + } + + if hasMultipleReturnValues { + s.WriteRune(']') + } + } + } +} + +func (g *PackageGenerator) writeFuncParams(s *strings.Builder, params []*ast.Field, depth int) { + for i, f := range params { + // normalize params iteration + // (params with omitted types will be part of a single ast.Field but with different names) + names := make([]string, 0, len(f.Names)) + for j, ident := range f.Names { + name := ident.Name + if name == "" || isReservedIdentifier(name) { + name = fmt.Sprintf("_arg%d%d", i, j) + } + names = append(names, name) + } + if len(names) == 0 { + // ommitted param name (eg. func(string)) + names = append(names, fmt.Sprintf("_arg%d", i)) + } + + for j, fieldName := range names { + if i > 0 || j > 0 { + s.WriteString(", ") + } + + var isVariadic bool + + switch t := f.Type.(type) { + case *ast.StarExpr: + f.Type = t.X + case *ast.Ellipsis: + isVariadic = true + } + + g.writeCommentGroup(s, f.Doc, depth+2) + if isVariadic { + s.WriteString("...") + } + s.WriteString(fieldName) + + s.WriteString(": ") + + g.writeType(s, f.Type, depth, optionParenthesis) + + if f.Comment != nil { + // Line comment is present, that means a comment after the field. + s.WriteString(" /* ") + s.WriteString(f.Comment.Text()) + s.WriteString(" */ ") + } + } + } +} + +// see https://es5.github.io/#x7.6.1.1 +var reservedIdentifiers = map[string]struct{}{ + "break": {}, + "do": {}, + "instanceof": {}, + "typeof": {}, + "case": {}, + "else": {}, + "new": {}, + "var": {}, + "catch": {}, + "finally": {}, + "return": {}, + "void": {}, + "continue": {}, + "for": {}, + "switch": {}, + "while": {}, + "debugger": {}, + "function": {}, + "this": {}, + "with": {}, + "default": {}, + "if": {}, + "throw": {}, + "delete": {}, + "in": {}, + "try": {}, + "class": {}, + "enum": {}, + "extends": {}, + "super": {}, + "const": {}, + "export": {}, + "import": {}, + "implements": {}, + "let": {}, + "private": {}, + "public": {}, + "yield": {}, + "interface": {}, + "package": {}, + "protected": {}, + "static": {}, +} + +func isReservedIdentifier(name string) bool { + _, ok := reservedIdentifiers[name] + return ok +} + +var isValidJSNameRegexp = regexp.MustCompile(`(?m)^[\pL_][\pL\pN_]*$`) + +func isValidJSName(name string) bool { + return isReservedIdentifier(name) || isValidJSNameRegexp.MatchString(name) +} + +func hasOption(opt string, options []string) bool { + for _, o := range options { + if o == opt { + return true + } + } + + return false +}