v4

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package v4 provides a decoder for Jupyter Notebooks v4.0 and later minor versions.

It implements the IPython Notebook v4.0 JSON Schema. Other minor versions can be decoded using the same, as the differences do not affect how the notebook is rendered.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachments added in v0.2.0

type Attachments map[string]MimeBundle

Attachments store mime-bundles keyed by filename.

func (Attachments) MimeBundle added in v0.2.0

func (att Attachments) MimeBundle(filename string) schema.MimeBundle

type Code

type Code struct {
	Source        common.MultilineString `json:"source"`
	TimesExecuted int                    `json:"execution_count"`
	Out           []Output               `json:"outputs"`
	Lang          string                 `json:"-"`
}

Code defines the schema for a "code" cell.

func (*Code) ExecutionCount

func (code *Code) ExecutionCount() int

func (*Code) Language

func (code *Code) Language() string

func (*Code) MimeType

func (code *Code) MimeType() string

FIXME: return correct mime type (add a function to common)

func (*Code) Outputs

func (code *Code) Outputs() (cells []schema.Cell)

func (*Code) Text

func (code *Code) Text() []byte

func (*Code) Type

func (code *Code) Type() schema.CellType

type DisplayDataOutput

type DisplayDataOutput struct {
	MimeBundle `json:"data"`
	Metadata   map[string]interface{} `json:"metadata"`
}

DisplayDataOutput are rich-format outputs generated by running the code in the parent cell.

func (*DisplayDataOutput) Type added in v0.2.0

func (dd *DisplayDataOutput) Type() schema.CellType

type ErrorOutput

type ErrorOutput struct {
	ExceptionName  string   `json:"ename"`
	ExceptionValue string   `json:"evalue"`
	Traceback      []string `json:"traceback"`
}

ErrorOutput stores the output of a failed code execution.

func (*ErrorOutput) MimeType

func (err *ErrorOutput) MimeType() string

func (*ErrorOutput) Text

func (err *ErrorOutput) Text() (txt []byte)

func (*ErrorOutput) Type

func (err *ErrorOutput) Type() schema.CellType

type ExecuteResultOutput

type ExecuteResultOutput struct {
	DisplayDataOutput
	TimesExecuted int `json:"execution_count"`
}

ExecuteResultOutput is the result of executing the code in the cell. Its contents are identical to those of DisplayDataOutput with the addition of the execution count.

func (*ExecuteResultOutput) ExecutionCount

func (ex *ExecuteResultOutput) ExecutionCount() int

func (*ExecuteResultOutput) Type added in v0.2.0

func (ex *ExecuteResultOutput) Type() schema.CellType

type Markdown

type Markdown struct {
	common.Markdown
	Att Attachments `json:"attachments,omitempty"`
}

Markdown defines the schema for a "markdown" cell.

func (*Markdown) Attachments added in v0.2.0

func (md *Markdown) Attachments() schema.Attachments

type MimeBundle

type MimeBundle map[string]interface{}

MimeBundle contains rich output data keyed by mime-type.

func (MimeBundle) Data

func (mb MimeBundle) Data(mime string) []byte

Data returns mime-type-specific content if present and a nil slice otherwise.

func (MimeBundle) MimeType

func (mb MimeBundle) MimeType() string

MimeType returns the richer of the mime-types present in the bundle, and falls back to "text/plain" otherwise.

func (MimeBundle) PlainText

func (mb MimeBundle) PlainText() []byte

PlainText returns data for "text/plain" mime-type and a nil slice otherwise.

func (MimeBundle) Text

func (mb MimeBundle) Text() []byte

Text returns data with the richer mime-type.

type NotebookMetadata

type NotebookMetadata struct {
	Lang struct {
		Name    string `json:"name"`
		Version string `json:"version"`
	} `json:"language_info"`
}

func (*NotebookMetadata) Language

func (nm *NotebookMetadata) Language() string

type Output

type Output struct {
	// contains filtered or unexported fields
}

Outputs unmarshals cell outputs into schema.Cell based on their type.

func (*Output) UnmarshalJSON

func (out *Output) UnmarshalJSON(data []byte) error

type Raw

type Raw struct {
	common.Raw
	Att Attachments `json:"attachments,omitempty"`
}

Raw defines the schema for a "raw" cell.

func (*Raw) Attachments added in v0.2.0

func (raw *Raw) Attachments() schema.Attachments

type StreamOutput

type StreamOutput struct {
	// Target can be stdout or stderr.
	Target string                 `json:"name"`
	Source common.MultilineString `json:"text"`
}

StreamOutput is a plain, text-based output of the executed code. Depending on the stream "target", Type() can report "text/plain" (stdout) or "error" (stderr). The output is often decorated with ANSI-color sequences, which should be handled separately.

func (*StreamOutput) MimeType

func (stream *StreamOutput) MimeType() string

func (*StreamOutput) Text

func (stream *StreamOutput) Text() []byte

func (*StreamOutput) Type

func (stream *StreamOutput) Type() schema.CellType

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL