(i any)
| 79 | ) |
| 80 | |
| 81 | func 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 | |
| 110 | type config struct { |
| 111 | method bool |
searching dependent graphs…