Files
a60d994e25 Improve Performance of the Type System (#824)
* export the checker and ensure no methods or fields are exported

* make Checker reusable

* add PatchAndCheck method to Checker, and reuse it in visitors

* avoid unnecessary map and consolidate structs

* make all Nature methods use pointer-receiver

* added cache for type and nature information

* optimize type and nature checks

* more aggressively cache some partial results and add cheap checks

* cache reused values

* reduce copying in Nature by breaking down optional fields

* enforce use of cache

* improve ergonomics of FromType and NatureOf

* improve struct method fetching

* make cache private to Nature

* first iteration improving struct reflect caching

* cleaned up struct fields data

* improve caching of functions data

* simplify checker code

* simplify and remove dead code

* add checker benchmarks

* address PR comments and minor improvements

* rename from SetCache to Bind

* make the benchmarks more fair

* fix benchmark option not being applied

* move Cache to be argument instead of field

* merge FuncData into Optional

* rename Optional to TypeData

* simplify struct logic

* cache builtin numeric types

---------

Co-authored-by: Anton Medvedev <[email protected]>
2025-09-18 14:38:27 +02:00
..
2024-06-04 00:08:01 +02:00
2020-03-27 15:25:51 +03:00
2023-12-03 21:53:01 +01:00

DocGen

This package provides documentation generator with JSON or Markdown output.

Usage

Create a file and put next code into it.

package main

import (
	"encoding/json"
	"fmt"
  
	"github.com/expr-lang/expr/docgen"
)

func main() {
	// TODO: Replace env with your own types.
	doc := docgen.CreateDoc(env)
  
	buf, err := json.MarshalIndent(doc, "", "  ")
	if err != nil {
		panic(err)
	}
	fmt.Println(string(buf))
}

Run go run your_file.go. Documentation will be printed in JSON format.

Markdown

To generate markdown documentation:

package main

import "github.com/expr-lang/expr/docgen"

func main() {
	// TODO: Replace env with your own types.
	doc := docgen.CreateDoc(env)

	print(doc.Markdown())
}