Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cell ¶
type Cell interface {
CellType() CellType
MimeType() string
Text() []byte
// Type will be superseded with CellType in the following commits.
Type() CellTypeMixed
}
Cell encapsulates the raw content of each notebook cell and its designated mime-type.
type CellType ¶
type CellType int
CellType reports the intended cell type to the components that work with notebook cells through the Cell interface.
"markdown", "raw", "code", and "unrecognized" are official cell types, as defined in the nbformat JSON schema. Only "true" cells should use these to report their type.
"execute_result", "display_data", "stream", and "error" are, on the other hand, output types and only appear within the code cells. Although they aren't "true" cells with respect to the Jupyter's schema, functionally they are quite similar (output structs will, in fact, implement the Cell interface). They should use the predefined values to report their .CellType().
type CellTypeMixed ¶
type CellTypeMixed string
const ( PlainTextCellType CellTypeMixed = "text/plain" MarkdownCellType CellTypeMixed = "text/markdown" HTML CellTypeMixed = "text/html" PNG CellTypeMixed = "image/png" JPEG CellTypeMixed = "image/jpeg" JSON CellTypeMixed = "application/json" CodeCellType CellTypeMixed = "code" StdoutCellType CellTypeMixed = "stdout" StderrCellType CellTypeMixed = "stderr" )
type CodeCell ¶
type CodeCell interface {
Cell
Outputter
ExecutionCounter
Language() string
}
CodeCell contains the source code in the language of the document's associated kernel, and a list of outputs associated with executing that code.
type ExecutionCounter ¶
type ExecutionCounter interface {
ExecutionCount() int
}
type MimeBundle ¶
type MimeBundle interface {
MimeType() string
Text() []byte
// PlainText returns the value associated with "text/plain" mime-type if present and a nil slice otherwise.
// A renderer may want to fallback to this option if it is not able to render the richer mime-type.
PlainText() []byte
}
MimeBundle holds rich display outputs, such as images, JSON, HTML, etc. A single output will often have 2 representations:
- raw data, e.g. a base64-encoded image or JSON string/bytes, and
- plain text representation of the original object (in Python it's the output of the __repr__() method).
MimeBundle partially implements Cell interface, hiding the above complexity from the caller. When reporting MimeType implementations should prefer "text/html", "image/png", and any other type to "text/plain", and only return the latter if it is the only available option.
Similarly, Text returns the value associated with the richer of the available mime-types.
type NotebookMetadata ¶
type NotebookMetadata interface {
// Language reports the language of the document's associated kernel.
Language() string
}