@@ -27,87 +27,87 @@ const (
2727
2828// injected as placeholder in the interpreter, it's then replaced at runtime
2929// by a closure that knows how to talk with Jupyter
30- func stubDisplay (DisplayData ) error {
31- return errors .New ("cannot display: connection with Jupiter not registered " )
30+ func stubDisplay (Data ) error {
31+ return errors .New ("cannot display: connection with Jupyter not available " )
3232}
3333
3434// TODO handle the metadata
3535
36- func MakeDisplayData (mimeType string , data interface {}) DisplayData {
37- return DisplayData {
36+ func MakeData (mimeType string , data interface {}) Data {
37+ return Data {
3838 Data : BundledMIMEData {
3939 "text/plain" : fmt .Sprint (data ),
4040 mimeType : data ,
4141 },
4242 }
4343}
4444
45- func MakeDisplayData3 (mimeType string , plaintext string , data interface {}) DisplayData {
46- return DisplayData {
45+ func MakeData3 (mimeType string , plaintext string , data interface {}) Data {
46+ return Data {
4747 Data : BundledMIMEData {
4848 "text/plain" : plaintext ,
4949 mimeType : data ,
5050 },
5151 }
5252}
5353
54- func Bytes (mimeType string , bytes []byte ) DisplayData {
55- return MakeDisplayData3 (mimeType , mimeType , bytes )
54+ func Bytes (mimeType string , bytes []byte ) Data {
55+ return MakeData3 (mimeType , mimeType , bytes )
5656}
5757
58- func HTML (html string ) DisplayData {
59- return MakeDisplayData (MIMETypeHTML , html )
58+ func HTML (html string ) Data {
59+ return MakeData (MIMETypeHTML , html )
6060}
6161
62- func JSON (json map [string ]interface {}) DisplayData {
63- return MakeDisplayData (MIMETypeJSON , json )
62+ func JSON (json map [string ]interface {}) Data {
63+ return MakeData (MIMETypeJSON , json )
6464}
6565
66- func JavaScript (javascript string ) DisplayData {
67- return MakeDisplayData (MIMETypeJavaScript , javascript )
66+ func JavaScript (javascript string ) Data {
67+ return MakeData (MIMETypeJavaScript , javascript )
6868}
6969
70- func JPEG (jpeg []byte ) DisplayData {
71- return MakeDisplayData3 (MIMETypeJPEG , "jpeg image" , jpeg ) // []byte are encoded as base64 by the marshaller
70+ func JPEG (jpeg []byte ) Data {
71+ return MakeData3 (MIMETypeJPEG , "jpeg image" , jpeg ) // []byte are encoded as base64 by the marshaller
7272}
7373
74- func Latex (latex string ) DisplayData {
75- return MakeDisplayData3 (MIMETypeLatex , latex , "$" + strings .Trim (latex , "$" )+ "$" )
74+ func Latex (latex string ) Data {
75+ return MakeData3 (MIMETypeLatex , latex , "$" + strings .Trim (latex , "$" )+ "$" )
7676}
7777
78- func Markdown (markdown string ) DisplayData {
79- return MakeDisplayData (MIMETypeMarkdown , markdown )
78+ func Markdown (markdown string ) Data {
79+ return MakeData (MIMETypeMarkdown , markdown )
8080}
8181
82- func Math (latex string ) DisplayData {
83- return MakeDisplayData3 (MIMETypeLatex , latex , "$$" + strings .Trim (latex , "$" )+ "$$" )
82+ func Math (latex string ) Data {
83+ return MakeData3 (MIMETypeLatex , latex , "$$" + strings .Trim (latex , "$" )+ "$$" )
8484}
8585
86- func PDF (pdf []byte ) DisplayData {
87- return MakeDisplayData3 (MIMETypePDF , "pdf document" , pdf ) // []byte are encoded as base64 by the marshaller
86+ func PDF (pdf []byte ) Data {
87+ return MakeData3 (MIMETypePDF , "pdf document" , pdf ) // []byte are encoded as base64 by the marshaller
8888}
8989
90- func PNG (png []byte ) DisplayData {
91- return MakeDisplayData3 (MIMETypePNG , "png image" , png ) // []byte are encoded as base64 by the marshaller
90+ func PNG (png []byte ) Data {
91+ return MakeData3 (MIMETypePNG , "png image" , png ) // []byte are encoded as base64 by the marshaller
9292}
9393
94- func String (mimeType string , s string ) DisplayData {
95- return MakeDisplayData (mimeType , s )
94+ func String (mimeType string , s string ) Data {
95+ return MakeData (mimeType , s )
9696}
9797
98- func SVG (svg string ) DisplayData {
99- return MakeDisplayData (MIMETypeSVG , svg )
98+ func SVG (svg string ) Data {
99+ return MakeData (MIMETypeSVG , svg )
100100}
101101
102- // MIME encapsulates the data and metadata into a DisplayData .
102+ // MIME encapsulates the data and metadata into a Data .
103103// The 'data' map is expected to contain at least one {key,value} pair,
104104// with value being a string, []byte or some other JSON serializable representation,
105105// and key equal to the MIME type of such value.
106106// The exact structure of value is determined by what the frontend expects.
107107// Some easier-to-use functions for common formats supported by the Jupyter frontend
108108// are provided by the various functions above.
109- func MIME (data , metadata map [string ]interface {}) DisplayData {
110- return DisplayData {data , metadata , nil }
109+ func MIME (data , metadata map [string ]interface {}) Data {
110+ return Data {data , metadata , nil }
111111}
112112
113113// prepare imports.Package for interpreted code
@@ -120,8 +120,8 @@ var display = imports.Package{
120120 "JSON" : r .ValueOf (JSON ),
121121 "JavaScript" : r .ValueOf (JavaScript ),
122122 "Latex" : r .ValueOf (Latex ),
123- "MakeDisplayData " : r .ValueOf (MakeDisplayData ),
124- "MakeDisplayData3 " : r .ValueOf (MakeDisplayData3 ),
123+ "MakeData " : r .ValueOf (MakeData ),
124+ "MakeData3 " : r .ValueOf (MakeData3 ),
125125 "Markdown" : r .ValueOf (Markdown ),
126126 "Math" : r .ValueOf (Math ),
127127 "MIME" : r .ValueOf (MIME ),
@@ -141,7 +141,7 @@ var display = imports.Package{
141141 },
142142 Types : map [string ]r.Type {
143143 "BundledMIMEData" : r .TypeOf ((* BundledMIMEData )(nil )).Elem (),
144- "DisplayData " : r .TypeOf ((* DisplayData )(nil )).Elem (),
144+ "Data " : r .TypeOf ((* Data )(nil )).Elem (),
145145 },
146146}
147147
0 commit comments