MCPcopy Index your code
hub / github.com/gopherdata/gophernotes / canAutoRender

Method canAutoRender

display.go:137–156  ·  view source on GitHub ↗

return true if data type should be auto-rendered graphically

(data interface{}, typ xreflect.Type)

Source from the content-addressed store, hash-verified

135
136// return true if data type should be auto-rendered graphically
137func (kernel *Kernel) canAutoRender(data interface{}, typ xreflect.Type) bool {
138 switch data.(type) {
139 case Data, Renderer, SimpleRenderer, HTMLer, JavaScripter, JPEGer, JSONer,
140 Latexer, Markdowner, PNGer, PDFer, SVGer, image.Image:
141 return true
142 }
143 if kernel == nil || typ == nil {
144 return false
145 }
146 // in gomacro, methods of interpreted types are emulated,
147 // thus type-asserting them to interface types as done above cannot succeed.
148 // Manually check if emulated type "pretends" to implement
149 // at least one of the interfaces above
150 for _, xtyp := range kernel.render {
151 if typ.Implements(xtyp) {
152 return true
153 }
154 }
155 return false
156}
157
158var autoRenderers = map[string]func(Data, interface{}) Data{
159 "Renderer": func(d Data, i interface{}) Data {

Callers 2

autoRenderResultsMethod · 0.95
renderFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected