Skip to content

Commit

Permalink
Merge pull request #151 from janpfeifer/comments
Browse files Browse the repository at this point in the history
Include function comments in the generated code
  • Loading branch information
janpfeifer authored Jan 20, 2025
2 parents 7169983 + 44917eb commit 2255c95
Show file tree
Hide file tree
Showing 22 changed files with 128 additions and 62 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Added `%version`, and environment variables `GONB_VERSION`, `GONB_GIT_COMMIT`.
* Added `%help` info on missing environment variables.
* Added stack traces to protocol parsing errors.
* Include function comments in the generated code. This makes tags like `//go:noinline` work. See #150

## v0.10.6, 2024/10/16, Improved Docker, added `%capture`

Expand Down
6 changes: 3 additions & 3 deletions examples/tests/bash_script.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"/tmp/gonb_b9edd581\n"
"/tmp/gonb_d300f5a2\n"
]
}
],
Expand All @@ -59,7 +59,7 @@
"output_type": "stream",
"text": [
"/home/janpf/Projects/gonb/examples/tests\n",
"/tmp/gonb_b9edd581\n",
"/tmp/gonb_d300f5a2\n",
"/home/janpf/Projects/gonb\n",
"/home/janpf/Projects/gonb\n"
]
Expand All @@ -86,7 +86,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/capture.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/comms.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions examples/tests/dom.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
{
"data": {
"text/html": [
"<div id=\"dom.transient_div_32726297\"></div>"
"<div id=\"dom.transient_div_25f4f259\"></div>"
]
},
"metadata": {},
Expand Down Expand Up @@ -152,7 +152,7 @@
{
"data": {
"text/html": [
"<div id=\"dom.transient_div_5b814837\"></div>"
"<div id=\"dom.transient_div_759e5c9b\"></div>"
]
},
"metadata": {},
Expand Down Expand Up @@ -197,7 +197,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
10 changes: 5 additions & 5 deletions examples/tests/goflags.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"gonb_0cdc700f/main.go:8:\tA\t\t100.0%\n",
"gonb_0cdc700f/main.go:12:\tB\t\t0.0%\n",
"gonb_0cdc700f/main.go:17:\tmain\t\t100.0%\n",
"gonb_ae2bcb52/main.go:8:\tA\t\t100.0%\n",
"gonb_ae2bcb52/main.go:12:\tB\t\t0.0%\n",
"gonb_ae2bcb52/main.go:17:\tmain\t\t100.0%\n",
"total\t\t\t\t(statements)\t75.0%\n"
]
}
Expand Down Expand Up @@ -238,7 +238,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"# gonb_0cdc700f\n",
"# gonb_ae2bcb52\n",
"./main.go:10:6: can inline (*Point).ManhattanLen\n",
"./main.go:16:12: inlining call to flag.Parse\n",
"./main.go:18:27: inlining call to (*Point).ManhattanLen\n",
Expand Down Expand Up @@ -267,7 +267,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/tests/gonbui.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"output_type": "stream",
"text": [
"%goflags=[\"--cover\" \"--covermode=set\"]\n",
"GOCOVERDIR=/tmp/gonb_test_coverage.fmW2jDEhWf\n"
"GOCOVERDIR=/tmp/gonb_nbtests_gocoverdir_4129479306\n"
]
}
],
Expand Down Expand Up @@ -133,7 +133,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
14 changes: 7 additions & 7 deletions examples/tests/gotest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,12 @@
"text": [
"goos: linux\n",
"goarch: amd64\n",
"pkg: gonb_a1453c14\n",
"pkg: gonb_74e427f6\n",
"cpu: 12th Gen Intel(R) Core(TM) i9-12900K\n",
"BenchmarkFibonacciA32\n",
"BenchmarkFibonacciA32-24 \t 169\t 7058908 ns/op\n",
"BenchmarkFibonacciA32-24 \t 178\t 6602828 ns/op\n",
"BenchmarkFibonacciB32\n",
"BenchmarkFibonacciB32-24 \t285643864\t 3.680 ns/op\n",
"BenchmarkFibonacciB32-24 \t298555876\t 4.021 ns/op\n",
"PASS\n",
"coverage: [no statements]\n"
]
Expand Down Expand Up @@ -334,10 +334,10 @@
"text": [
"goos: linux\n",
"goarch: amd64\n",
"pkg: gonb_a1453c14\n",
"pkg: gonb_74e427f6\n",
"cpu: 12th Gen Intel(R) Core(TM) i9-12900K\n",
"BenchmarkFibonacciA32-24 \t 168\t 7082427 ns/op\n",
"BenchmarkFibonacciB32-24 \t308541147\t 3.901 ns/op\n",
"BenchmarkFibonacciA32-24 \t 180\t 6574007 ns/op\n",
"BenchmarkFibonacciB32-24 \t308328156\t 3.930 ns/op\n",
"PASS\n",
"coverage: [no statements]\n"
]
Expand All @@ -361,7 +361,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
18 changes: 9 additions & 9 deletions examples/tests/gowork.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"/tmp/gonb_tests_gowork_IBSuBo7n"
"/tmp/gonb_tests_gowork_173uIYjd"
]
}
],
Expand Down Expand Up @@ -64,7 +64,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Temporary test package: /tmp/gonb_tests_gowork_IBSuBo7n\n"
"Temporary test package: /tmp/gonb_tests_gowork_173uIYjd\n"
]
}
],
Expand Down Expand Up @@ -136,7 +136,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"\t- Added replace rule for module \"a.com/a/pkg\" to local directory \"/tmp/gonb_tests_gowork_IBSuBo7n\".\n"
"\t- Added replace rule for module \"a.com/a/pkg\" to local directory \"/tmp/gonb_tests_gowork_173uIYjd\".\n"
]
}
],
Expand All @@ -155,9 +155,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"module gonb_05a80086\n",
"module gonb_b978d03f\n",
"\n",
"go 1.23.2\n",
"go 1.23.5\n",
"\n",
"replace a.com/a/pkg => TMP_PKG\n"
]
Expand Down Expand Up @@ -186,7 +186,7 @@
"text/html": [
"<b>List of files/directories being tracked:</b>\n",
"<ul>\n",
"<li>/tmp/gonb_tests_gowork_IBSuBo7n</li>\n",
"<li>/tmp/gonb_tests_gowork_173uIYjd</li>\n",
"</ul>\n"
]
},
Expand All @@ -208,9 +208,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"module gonb_05a80086\n",
"module gonb_b978d03f\n",
"\n",
"go 1.23.2\n"
"go 1.23.5\n"
]
}
],
Expand Down Expand Up @@ -280,7 +280,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/hello.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/init.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/tests/input_boxes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"output_type": "stream",
"text": [
"%goflags=[\"--cover\" \"--covermode=set\"]\n",
"GOCOVERDIR=/tmp/gonb_test_coverage.fmW2jDEhWf\n"
"GOCOVERDIR=/tmp/gonb_nbtests_gocoverdir_4129479306\n"
]
}
],
Expand Down Expand Up @@ -196,7 +196,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/script.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/tests/vartuple.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"text/html": [
"<h4>Variables</h4>\n",
"<ul>\n",
"<li><pre>_~653277</pre></li>\n",
"<li><pre>_~085390</pre></li>\n",
"<li><pre>a</pre></li>\n",
"<li><pre>c</pre></li>\n",
"</ul>"
Expand Down Expand Up @@ -125,7 +125,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
8 changes: 4 additions & 4 deletions examples/tests/widgets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
{
"data": {
"text/html": [
"<div id=\"dom.transient_div_7742ea2e\"></div>"
"<div id=\"dom.transient_div_540e2e0c\"></div>"
]
},
"metadata": {},
Expand Down Expand Up @@ -189,7 +189,7 @@
{
"data": {
"text/html": [
"<div id=\"dom.transient_div_b5a11420\"></div>"
"<div id=\"dom.transient_div_ddd43a51\"></div>"
]
},
"metadata": {},
Expand Down Expand Up @@ -304,7 +304,7 @@
{
"data": {
"text/html": [
"<div id=\"dom.transient_div_07bc0111\"></div>"
"<div id=\"dom.transient_div_a322648e\"></div>"
]
},
"metadata": {},
Expand Down Expand Up @@ -416,7 +416,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions examples/tests/writefile.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Cell contents written to \"/tmp/gonb_nbtests_writefile_4201179243/poetry.txt\".\n"
"Cell contents written to \"/tmp/gonb_nbtests_writefile_2206415683/poetry.txt\".\n"
]
}
],
Expand All @@ -32,7 +32,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Cell contents appended to \"/tmp/gonb_nbtests_writefile_4201179243/poetry.txt\".\n"
"Cell contents appended to \"/tmp/gonb_nbtests_writefile_2206415683/poetry.txt\".\n"
]
}
],
Expand All @@ -55,7 +55,7 @@
"name": "go",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "go1.23.2"
"version": "go1.23.5"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 2255c95

Please sign in to comment.