MCPcopy Index your code
hub / github.com/expr-lang/expr / CreateDoc

Function CreateDoc

docgen/docgen.go:81–108  ·  view source on GitHub ↗
(i any)

Source from the content-addressed store, hash-verified

79)
80
81func CreateDoc(i any) *Context {
82 c := &Context{
83 Variables: make(map[Identifier]*Type),
84 Types: make(map[TypeName]*Type),
85 PkgPath: deref.Type(reflect.TypeOf(i)).PkgPath(),
86 }
87
88 cache := new(nature.Cache)
89 env := conf.EnvWithCache(cache, i)
90 for name, t := range env.All(cache) {
91 if _, ok := c.Variables[Identifier(name)]; ok {
92 continue
93 }
94 c.Variables[Identifier(name)] = c.use(t.Type, fromMethod(t.Method))
95 }
96
97 for _, op := range Operators {
98 c.Variables[Identifier(op)] = &Type{
99 Kind: "operator",
100 }
101 }
102
103 for builtin, t := range Builtins {
104 c.Variables[builtin] = t
105 }
106
107 return c
108}
109
110type config struct {
111 method bool

Callers 4

TestCreateDocFunction · 0.85
TestCreateDoc_AmbiguousFunction · 0.85
TestCreateDoc_FromMapFunction · 0.85
TestContext_MarkdownFunction · 0.85

Calls 6

useMethod · 0.95
TypeFunction · 0.92
EnvWithCacheFunction · 0.92
IdentifierTypeAlias · 0.85
fromMethodFunction · 0.85
AllMethod · 0.80

Tested by 4

TestCreateDocFunction · 0.68
TestCreateDoc_AmbiguousFunction · 0.68
TestCreateDoc_FromMapFunction · 0.68
TestContext_MarkdownFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…