Documentation
¶
Overview ¶
Package engine runs a Go notebook in an interpreter: the playground's core, the same in the browser (compiled to WebAssembly) and in tests.
A notebook is a Markdown document whose ```go blocks are cells, as github.com/go-notebook/notebook/format reads it. The cells run in document order, in one yaegi interpreter, so that what a cell defines is visible to the cells after it. The packages a cell may import are those of github.com/go-notebook/playground/symbols; their code is compiled, not interpreted, so a call into go-statistics or go-plot runs at native (or WebAssembly) speed and only the notebook's own code is interpreted.
The conventions are go-notebook's: a cell's final expression is shown; a final call returning (value, error) shows the value, or fails the cell with the error; a value that draws itself as SVG — a go-plot figure — is shown as a figure.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cell ¶
type Cell struct {
// Kind is "prose" (Markdown) or "code" (Go).
Kind string `json:"kind"`
// Source is the cell's text, without the fences of a code cell.
Source string `json:"source"`
}
Cell is a cell of a notebook, as the page shows it.
type Result ¶
type Result struct {
// Cell is the cell's index among the notebook's code cells.
Cell int `json:"cell"`
// Line is the line of the document where the cell's code starts.
Line int `json:"line"`
// Output is what the cell printed.
Output string `json:"output,omitempty"`
// Display holds what the cell showed, each value as a MIME bundle:
// "text/plain", and "image/svg+xml" or "text/html" when the value has
// that representation ("image/png" is base64).
Display []map[string]string `json:"display,omitempty"`
// Error is why the cell failed, with the line in the cell.
Error string `json:"error,omitempty"`
// Skipped reports a cell that did not run because one before it
// failed.
Skipped bool `json:"skipped,omitempty"`
// Millis is how long the cell ran.
Millis float64 `json:"ms"`
}
Result is what one code cell did.