forked from runtimed/kernel-testbed
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnippets.json
More file actions
243 lines (243 loc) · 13.3 KB
/
Copy pathsnippets.json
File metadata and controls
243 lines (243 loc) · 13.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
{
"$schema": "./snippets.schema.json",
"languages": {
"python": {
"print_hello": "print('hello')",
"print_stderr": "import sys; print('error', file=sys.stderr)",
"simple_expr": "1 + 1",
"simple_expr_result": "2",
"incomplete_code": "def foo(",
"complete_code": "x = 1",
"syntax_error": "def class",
"input_prompt": "input('Enter: ')",
"sleep_code": "import time; time.sleep(2)",
"completion_var": "test_variable_for_completion",
"completion_setup": "test_variable_for_completion = 42",
"completion_prefix": "test_variable_for_",
"display_data_code": "from IPython.display import display, HTML; display(HTML('<b>bold</b>'))",
"update_display_data_code": "from IPython.display import display, HTML, update_display; dh = display(HTML('<b>initial</b>'), display_id=True); update_display(HTML('<b>✨ updated ✨</b>'), display_id=dh.display_id)",
"rich_execute_result_code": "from IPython.display import HTML; HTML('<b>bold</b>')"
},
"r": {
"print_hello": "cat('hello\\n')",
"print_stderr": "cat('error\\n', file=stderr())",
"simple_expr": "1 + 1",
"simple_expr_result": "[1] 2",
"incomplete_code": "function(",
"complete_code": "x <- 1",
"syntax_error": "function function",
"input_prompt": "readline('Enter: ')",
"sleep_code": "Sys.sleep(2)",
"completion_var": "test_variable_for_completion",
"completion_setup": "test_variable_for_completion <- 42",
"completion_prefix": "test_variable_for_",
"display_data_code": "plot(1:10)",
"update_display_data_code": "plot(1:5); Sys.sleep(0.1); plot(6:10)",
"rich_execute_result_code": "data.frame(x = 1:3, y = c('a', 'b', 'c'))"
},
"rust": {
"print_hello": "println!(\"hello\");",
"print_stderr": "eprintln!(\"error\");",
"simple_expr": "1 + 1",
"simple_expr_result": "2",
"incomplete_code": "fn foo(",
"complete_code": "let x = 1;",
"syntax_error": "fn fn",
"input_prompt": "// Rust kernel doesn't support stdin",
"sleep_code": "std::thread::sleep(std::time::Duration::from_secs(2));",
"completion_var": "test_variable_for_completion",
"completion_setup": "let test_variable_for_completion = 42;",
"completion_prefix": "test_variable_for_",
"display_data_code": "// evcxr uses execute_result for rich output, not display_data",
"update_display_data_code": "// evcxr doesn't support update_display_data (no display_id)",
"rich_execute_result_code": "pub struct Html(pub &'static str);\nimpl Html {\n pub fn evcxr_display(&self) {\n println!(\"EVCXR_BEGIN_CONTENT text/html\\n{}\\nEVCXR_END_CONTENT\", self.0);\n }\n}\nHtml(\"<b>bold</b>\")"
},
"julia": {
"print_hello": "println(\"hello\")",
"print_stderr": "println(stderr, \"error\")",
"simple_expr": "1 + 1",
"simple_expr_result": "2",
"incomplete_code": "function foo(",
"complete_code": "x = 1",
"syntax_error": "function function",
"input_prompt": "readline()",
"sleep_code": "sleep(2)",
"completion_var": "test_variable_for_completion",
"completion_setup": "test_variable_for_completion = 42",
"completion_prefix": "test_variable_for_",
"display_data_code": "display(\"text/html\", \"<b>bold</b>\")",
"update_display_data_code": "# Julia update_display varies by environment",
"rich_execute_result_code": "HTML(\"<b>bold</b>\")"
},
"typescript": {
"print_hello": "console.log('hello')",
"print_stderr": "console.error('error')",
"simple_expr": "1 + 1",
"simple_expr_result": "2",
"incomplete_code": "const x = {",
"complete_code": "const x = 1",
"syntax_error": "function function",
"input_prompt": "prompt('Enter: ')",
"sleep_code": "await new Promise(r => setTimeout(r, 2000))",
"completion_var": "testVariableForCompletion",
"completion_setup": "const testVariableForCompletion = 42",
"completion_prefix": "testVariableFor",
"display_data_code": "await Deno.jupyter.broadcast(\"display_data\", { data: { \"text/html\": \"<b>bold</b>\" }, metadata: {}, transient: {} })",
"update_display_data_code": "await Deno.jupyter.broadcast(\"display_data\", { data: { \"text/html\": \"<b>initial</b>\" }, metadata: {}, transient: { display_id: \"test_update\" } }); await Deno.jupyter.broadcast(\"update_display_data\", { data: { \"text/html\": \"<b>updated</b>\" }, metadata: {}, transient: { display_id: \"test_update\" } })",
"rich_execute_result_code": "[{letter: \"A\", frequency: 0.08167}, {letter: \"B\", frequency: 0.01492}]"
},
"go": {
"print_hello": "fmt.Println(\"hello\")",
"print_stderr": "fmt.Fprintln(os.Stderr, \"error\")",
"simple_expr": "1 + 1",
"simple_expr_result": "2",
"incomplete_code": "func foo(",
"complete_code": "x := 1",
"syntax_error": "func func",
"input_prompt": "import \"github.com/janpfeifer/gonb/gonbui\"\ngonbui.RequestInput(\"Enter: \", false)",
"sleep_code": "time.Sleep(2 * time.Second)",
"completion_var": "testVariableForCompletion",
"completion_setup": "testVariableForCompletion := 42",
"completion_prefix": "testVariableFor",
"display_data_code": "import \"github.com/janpfeifer/gonb/gonbui\"\ngonbui.DisplayHtml(\"<b>bold</b>\")",
"update_display_data_code": "import \"github.com/janpfeifer/gonb/gonbui\"\nid := gonbui.UniqueId()\ngonbui.UpdateHtml(id, \"<b>initial</b>\")\ngonbui.UpdateHtml(id, \"<b>updated</b>\")",
"rich_execute_result_code": "// Go uses display_data for rich output"
},
"scala": {
"print_hello": "println(\"hello\")",
"print_stderr": "System.err.println(\"error\")",
"simple_expr": "1 + 1",
"simple_expr_result": "2",
"incomplete_code": "def foo(",
"complete_code": "val x = 1",
"syntax_error": "def def",
"input_prompt": "scala.io.StdIn.readLine()",
"sleep_code": "Thread.sleep(2000)",
"completion_var": "testVariableForCompletion",
"completion_setup": "val testVariableForCompletion = 42",
"completion_prefix": "testVariableFor",
"display_data_code": "kernel.publish.html(\"<b>bold</b>\")",
"update_display_data_code": "val id = java.util.UUID.randomUUID().toString; kernel.publish.html(\"<b>initial</b>\", id); kernel.publish.updateHtml(\"<b>updated</b>\", id)",
"rich_execute_result_code": "Html(\"<b>bold</b>\")"
},
"cpp": {
"print_hello": "#include <iostream>\nstd::cout << \"hello\" << std::endl;",
"print_stderr": "#include <iostream>\nstd::cerr << \"error\" << std::endl;",
"simple_expr": "1 + 1",
"simple_expr_result": "2",
"incomplete_code": "int foo(",
"complete_code": "int x = 1;",
"syntax_error": "int int;",
"input_prompt": "#include <iostream>\n#include <string>\nstd::string name;\nstd::cin >> name;",
"sleep_code": "#include <thread>\n#include <chrono>\nstd::this_thread::sleep_for(std::chrono::seconds(2));",
"completion_var": "test_variable_for_completion",
"completion_setup": "int test_variable_for_completion = 42;",
"completion_prefix": "test_variable_for_",
"display_data_code": "#include <string>\n#include \"xcpp/xdisplay.hpp\"\n\nstruct html_content {\n std::string content;\n};\n\n#include \"nlohmann/json.hpp\"\nnlohmann::json mime_bundle_repr(const html_content& h) {\n auto bundle = nlohmann::json::object();\n bundle[\"text/html\"] = h.content;\n return bundle;\n}\n\nhtml_content h{\"<b>bold</b>\"};\nxcpp::display(h);",
"update_display_data_code": "#include <string>\n#include \"xcpp/xdisplay.hpp\"\n#include \"nlohmann/json.hpp\"\nnamespace nl = nlohmann;\nnamespace ht\n{\nstruct html\n{\ninline html(const std::string& content)\n{\nm_content = content;\n}\nstd::string m_content;\n};\nnl::json mime_bundle_repr(const html& a)\n{\nauto bundle = nl::json::object();\nbundle[\"text/html\"] = a.m_content;\nreturn bundle;\n}\n}\nht::html rect(R\"(\n<div style='\n width: 90px;\n height: 50px;\n line-height: 50px;\n background-color: blue;\n color: white;\n text-align: center;'>\nOriginal\n</div>)\");\nxcpp::display(rect, \"some_display_id\");\nrect.m_content = R\"(\n<div style='\n width: 90px;\n height: 50px;\n line-height: 50px;\n background-color: red;\n color: white;\n text-align: center;'>\nUpdated\n</div>)\";xcpp::display(rect, \"some_display_id\", true);",
"rich_execute_result_code": "// C++ uses display_data for rich output"
},
"sql": {
"print_hello": "SELECT 'hello' AS message;",
"print_stderr": "-- SQL doesn't have stderr; errors come from invalid queries",
"simple_expr": "SELECT 1 + 1 AS result;",
"simple_expr_result": "2",
"incomplete_code": "SELECT * FROM",
"complete_code": "SELECT 1;",
"syntax_error": "SELEC * FORM table;",
"input_prompt": "-- SQL kernel doesn't support stdin",
"sleep_code": "-- SQL sleep varies by database backend",
"completion_var": "test_table",
"completion_setup": "CREATE TABLE IF NOT EXISTS test_table (id INTEGER);",
"completion_prefix": "test_",
"display_data_code": "SELECT 1 AS col1, 2 AS col2, 3 AS col3;",
"update_display_data_code": "-- SQL doesn't support update_display_data",
"rich_execute_result_code": "SELECT 1 AS col1, 2 AS col2, 3 AS col3;"
},
"lua": {
"print_hello": "print('hello')",
"print_stderr": "io.stderr:write('error\\n')",
"simple_expr": "1 + 1",
"simple_expr_result": "2",
"incomplete_code": "function foo(",
"complete_code": "x = 1",
"syntax_error": "function function",
"input_prompt": "io.read()",
"sleep_code": "function sleep(t)local start = os.time();repeat until os.time() > start + t end;sleep(1)",
"completion_var": "test_variable_for_completion",
"completion_setup": "test_variable_for_completion = 42",
"completion_prefix": "test_variable_for_",
"display_data_code": "ilua.display.display_data(ilua.display.html('<b>bold</b>'))",
"update_display_data_code": "ilua.display.display_data(ilua.display.html('<b>hello</b>'), {}, {display_id = 'id1'} )\nilua.display.update_display_data(ilua.display.html('<b>world</b>'), {}, {display_id = 'id1'} )",
"rich_execute_result_code": "ilua.display.html('<b>world</b>')"
},
"haskell": {
"print_hello": "putStrLn \"hello\"",
"print_stderr": "import System.IO; hPutStrLn stderr \"error\"",
"simple_expr": "1 + 1",
"simple_expr_result": "2",
"incomplete_code": "let x =",
"complete_code": "let x = 1",
"syntax_error": "let let",
"input_prompt": "-- Haskell stdin varies by kernel",
"sleep_code": "import Control.Concurrent; threadDelay 2000000",
"completion_var": "testVariableForCompletion",
"completion_setup": "let testVariableForCompletion = 42",
"completion_prefix": "testVariableFor",
"display_data_code": "putStrLn \"no rich display\"",
"update_display_data_code": "-- Haskell doesn't support update_display_data",
"rich_execute_result_code": "// Haskell doesn't support rich execute_result"
},
"octave": {
"print_hello": "disp('hello')",
"print_stderr": "fprintf(2, 'error\\n')",
"simple_expr": "1 + 1",
"simple_expr_result": "ans = 2",
"incomplete_code": "if true",
"complete_code": "x = 1;",
"syntax_error": "1 +",
"input_prompt": "name = input(\"Enter: \")",
"sleep_code": "pause(2)",
"completion_var": "test_variable_for_completion",
"completion_setup": "test_variable_for_completion = 42;",
"completion_prefix": "test_variable_for_",
"display_data_code": "% Octave plot() requires display - skip in headless CI",
"update_display_data_code": "% Octave update_display varies by environment",
"rich_execute_result_code": "// Octave uses display_data for rich output"
},
"ocaml": {
"print_hello": "print_endline \"hello\"",
"print_stderr": "prerr_endline \"error\"",
"simple_expr": "1 + 1",
"simple_expr_result": "2",
"incomplete_code": "let foo (",
"complete_code": "let x = 1",
"syntax_error": "let let",
"input_prompt": "read_line ()",
"sleep_code": "Unix.sleep 2",
"completion_var": "test_variable_for_completion",
"completion_setup": "let test_variable_for_completion = 42",
"completion_prefix": "test_variable_for_",
"display_data_code": "#require \"jupyter.notebook\";; Jupyter_notebook.display \"text/html\" \"<b>bold</b>\"",
"update_display_data_code": "(* OCaml jupyter doesn't support update_display_data *)",
"rich_execute_result_code": "(* OCaml uses display_data for rich output *)"
},
"generic": {
"print_hello": "print('hello')",
"print_stderr": "print('error')",
"simple_expr": "1 + 1",
"simple_expr_result": "2",
"incomplete_code": "(",
"complete_code": "1",
"syntax_error": "!@#$%",
"input_prompt": "input()",
"sleep_code": "// sleep not available",
"completion_var": "x",
"completion_setup": "x = 1",
"completion_prefix": "x",
"display_data_code": "1",
"update_display_data_code": "// update_display not available",
"rich_execute_result_code": "// rich execute_result not available"
}
}
}