Documentation
¶
Overview ¶
Package notebook reads the code cells of a Jupyter notebook (nbformat 4), so a model written in a notebook can be loaded where a model file can.
Index ¶
Constants ¶
const Ext = ".ipynb"
Ext is the file extension a notebook is named with.
const Language = "sysml"
Language is the kernelspec language a notebook must record to be loaded as a SysML model; a notebook recording none is taken to be one.
const SkipTag = "skip-load"
SkipTag marks a code cell a load passes over: scratch work, a demonstration, anything the notebook runs that another should not inherit.
Variables ¶
This section is empty.
Functions ¶
func IsNotebook ¶
IsNotebook reports whether path names a notebook, by its extension.
Types ¶
type Cell ¶
type Cell struct {
// Index is the cell's 1-based position among the notebook's code cells,
// which is how a selection names it and how a diagnostic locates it.
Index int
Source string
Tags []string
}
Cell is one code cell of a notebook.
type FormatError ¶
FormatError is a file that is not a notebook a load can read, and why.
func (*FormatError) Error ¶
func (e *FormatError) Error() string
type LanguageError ¶
LanguageError is a notebook written for another kernel's language, which a load refuses rather than reading its cells as SysML.
func (*LanguageError) Error ¶
func (e *LanguageError) Error() string
type Notebook ¶
type Notebook struct {
Name string
Language string // kernelspec.language, else language_info.name; "" when neither is recorded
Cells []Cell
}
Notebook is what a load reads of a notebook: its code cells in notebook order, markdown and raw cells left out, and the language its kernel records.
type Selection ¶
type Selection struct {
// contains filtered or unexported fields
}
Selection picks the code cells of a notebook a load reads: by position among the code cells, 1-based, as `1,3-5`, or by a tag they carry, as `tag:model`. The zero Selection picks every cell.
func ParseSelection ¶
ParseSelection reads a selection as it is written after `--cells`.
func (Selection) Apply ¶
Apply picks the notebook's cells the selection names, in notebook order. A position past the notebook's code cells is an error naming how many there are; a tag no cell carries is an error naming the tag.