Documentation ¶
Index ¶
- Constants
- Variables
- func LoadFixture(t *testing.T, relPath ...string) []byte
- func PassesNBConvert(nbPath, jupyterConvertPath string) (string, bool)
- func PathRelativeToTest(t *testing.T, relPath ...string) string
- func ProduceNotebookPaths(ctx context.Context, rootDir string, bufSize int) <-chan string
- func TempDir(t *testing.T) (string, func())
- type Author
- type Base64Figure
- type Cell
- type CellMetadata
- type CodeCell
- type CodeMirrorMode
- type DisplayData
- type ErrorOutput
- type ExecuteResult
- type Falsifiable
- type JupyterMetaData
- type KernelSpec
- type LanguageInfo
- type MarkdownCell
- func (c MarkdownCell) GetInput() []string
- func (c MarkdownCell) GetMetadata() CellMetadata
- func (c MarkdownCell) GetOutputs() []Output
- func (c MarkdownCell) GetRaw() []byte
- func (c MarkdownCell) GetType() string
- func (c MarkdownCell) RenderInput(r Renderer) error
- func (c MarkdownCell) RenderOutput(r Renderer) error
- type MetaData
- type MimeBundle
- type Notebook
- type Opt
- type Output
- type OutputFigureMetadata
- type OutputMetadata
- type ParseError
- type Parser
- func (p *Parser) Parse(data []byte) (*Notebook, error)
- func (p *Parser) ParseAuthor(authorIdx int, data []byte) (Author, error)
- func (p *Parser) ParseAuthors(data []byte, offset int) ([]Author, error)
- func (p *Parser) ParseCell(cellIdx int, data []byte, offset int) (Cell, error)
- func (p *Parser) ParseCellMetadata(cellIdx int, data []byte, offset int) (CellMetadata, error)
- func (p *Parser) ParseCells(data []byte, offset int) ([]Cell, error)
- func (p *Parser) ParseCodeMirrorMode(data []byte, offset int) (CodeMirrorMode, error)
- func (p *Parser) ParseFalsifiable(data []byte, offset int) (Falsifiable, error)
- func (p *Parser) ParseJupyterMetadata(cellIdx int, data []byte, offset int) (JupyterMetaData, error)
- func (p *Parser) ParseKernelSpec(data []byte, offset int) (KernelSpec, error)
- func (p *Parser) ParseLanguageInfo(data []byte, offset int) (LanguageInfo, error)
- func (p *Parser) ParseMetadata(data []byte, offset int) (MetaData, error)
- func (p *Parser) ParseOutput(cellIdx, outputIdx int, data []byte, offset int) (Output, error)
- func (p *Parser) ParseOutputFigureMetadata(cellIdx, outputIdx int, data []byte, contentType string) (OutputFigureMetadata, error)
- func (p *Parser) ParseOutputMetadata(cellIdx, outputIdx int, data []byte, offset int) (OutputMetadata, error)
- func (p *Parser) ParseOutputs(cellIdx int, data []byte, offset int) ([]Output, error)
- func (p *Parser) Read(filePath string) (*Notebook, error)
- type RawCell
- type Renderer
- type Resource
- type StreamOutput
- type UnrecognizedCell
- func (c UnrecognizedCell) GetInput() []string
- func (c UnrecognizedCell) GetMetadata() CellMetadata
- func (c UnrecognizedCell) GetOutputs() []Output
- func (c UnrecognizedCell) GetRaw() []byte
- func (c UnrecognizedCell) GetType() string
- func (c UnrecognizedCell) RenderInput(r Renderer) error
- func (c UnrecognizedCell) RenderOutput(r Renderer) error
Constants ¶
View Source
const ( CellTypeMarkdown = "markdown" CellTypeRaw = "raw" CellTypeCode = "code" CellTypeUnrecognized = "unrecognized" )
View Source
const ( OutputTypeStream = "stream" OutputTypeExecuteResult = "execute_result" OutputTypeDisplayData = "display_data" OutputTypeError = "error" )
View Source
const SVGMime = "image/svg+xml"
Variables ¶
View Source
var ErrNullBoolNotAllowed = errors.New("null bool not allowed")
View Source
var ErrNullIntNotAllowed = errors.New("null integer not allowed")
View Source
var ErrNullStringListNotAllowed = errors.New("null string list not allowed")
View Source
var ErrNullStringNotAllowed = errors.New("null string not allowed")
Functions ¶
func PassesNBConvert ¶
func ProduceNotebookPaths ¶
I wrote this to analyze a large collection of Jupyter notebooks cloned from github as repositories.
Types ¶
type Author ¶
func (Author) MarshalJSON ¶
type Base64Figure ¶ added in v0.0.6
type Base64Figure struct { Id string ContentType string Url string Data []byte Alt string Caption string IsPrimary bool FullSize bool Href string Resource *Resource }
func NewBase64Figure ¶ added in v0.0.6
func NewBase64Figure(contentType string, data []byte) (*Base64Figure, error)
func NewSVG ¶ added in v0.0.6
func NewSVG(contentType string, data []byte) *Base64Figure
type CellMetadata ¶
type CellMetadata struct { Name string `json:"name,omitempty"` Tags []string `json:"tags,omitempty"` Collapsed bool `json:"collapsed,omitempty"` Editable bool `json:"editable,omitempty"` Deletable bool `json:"deletable,omitempty"` Format string `json:"format,omitempty"` Jupyter JupyterMetaData `json:"jupyter,omitempty"` }
See: https://nbformat.readthedocs.io/en/latest/format_description.html#cell-metadata
type CodeCell ¶
type CodeCell struct { CellType string `json:"cell_type"` Metadata CellMetadata `json:"metadata"` Source []string `json:"source"` Outputs []Output `json:"outputs"` Raw []byte `json:"-"` }
func (CodeCell) GetMetadata ¶
func (c CodeCell) GetMetadata() CellMetadata
func (CodeCell) GetOutputs ¶
func (CodeCell) RenderInput ¶
func (CodeCell) RenderOutput ¶
type CodeMirrorMode ¶
type DisplayData ¶
type DisplayData struct { OutputType string `json:"output_type"` Data MimeBundle `json:"data"` Metadata OutputMetadata `json:"metadata"` }
func (DisplayData) Render ¶
func (s DisplayData) Render(r Renderer) error
func (DisplayData) Type ¶
func (s DisplayData) Type() string
type ErrorOutput ¶
type ErrorOutput struct { OutputType string `json:"output_type"` EName string `json:"ename"` EValue string `json:"evalue"` Traceback []string `json:"traceback"` }
func (ErrorOutput) Render ¶
func (s ErrorOutput) Render(r Renderer) error
func (ErrorOutput) Type ¶
func (s ErrorOutput) Type() string
type ExecuteResult ¶
type ExecuteResult struct { OutputType string `json:"output_type"` ExecuteCount int `json:"execution_count"` Data MimeBundle `json:"data"` Metadata OutputMetadata `json:"metadata"` }
func (ExecuteResult) Render ¶
func (s ExecuteResult) Render(r Renderer) error
func (ExecuteResult) Type ¶
func (s ExecuteResult) Type() string
type Falsifiable ¶
type Falsifiable struct { Title string `json:"title,omitempty"` Subtitle string `json:"subtitle,omitempty"` CreatedAt string `json:"created_at,omitempty"` UpdatedAt string `json:"updated_at,omitempty"` Authors []string `json:"authors,omitempty"` User string `json:"user,omitempty"` Slug string `json:"slug,omitempty"` Repo string `json:"repo,omitempty"` PrimaryImageCH string `json:"-"` }
type JupyterMetaData ¶
type KernelSpec ¶
type LanguageInfo ¶
type LanguageInfo struct { CodeMirrorMode CodeMirrorMode `json:"codemirror_mode,omitempty"` FileExtension string `json:"file_extension,omitempty"` MimeType string `json:"mimetype,omitempty"` Name string `json:"name,omitempty"` NBConvertExporter string `json:"nbconvert_exporter,omitempty"` PygmentsLexer string `json:"pygments_lexer,omitempty"` Version string `json:"version,omitempty"` }
type MarkdownCell ¶
type MarkdownCell struct { CellType string `json:"cell_type"` Metadata CellMetadata `json:"metadata"` Source []string `json:"source"` Raw []byte `json:"-"` }
func (MarkdownCell) GetInput ¶
func (c MarkdownCell) GetInput() []string
func (MarkdownCell) GetMetadata ¶
func (c MarkdownCell) GetMetadata() CellMetadata
func (MarkdownCell) GetOutputs ¶
func (c MarkdownCell) GetOutputs() []Output
func (MarkdownCell) GetRaw ¶
func (c MarkdownCell) GetRaw() []byte
func (MarkdownCell) GetType ¶
func (c MarkdownCell) GetType() string
func (MarkdownCell) RenderInput ¶
func (c MarkdownCell) RenderInput(r Renderer) error
func (MarkdownCell) RenderOutput ¶
func (c MarkdownCell) RenderOutput(r Renderer) error
type MetaData ¶
type MetaData struct { LanguageInfo LanguageInfo `json:"language_info"` KernelSpec KernelSpec `json:"kernelspec"` Falsifiable Falsifiable `json:"falsifiable"` OrigFmt int `json:"orig_nbformat,omitempty"` // TODO Title string `json:"title,omitempty"` // TODO Authors []Author `json:"authors,omitempty"` // TODO: SPDX license keys Raw []byte `json:"-"` }
type MimeBundle ¶
type Notebook ¶
type OutputFigureMetadata ¶ added in v0.0.6
type OutputMetadata ¶
type OutputMetadata struct { NeedsBackground string `json:"needs_background,omitempty"` FigureMeta map[string]OutputFigureMetadata }
type ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
func NewParseError ¶
func NewParseError(offset int, path string, msg string, args ...interface{}) *ParseError
func (*ParseError) Error ¶
func (p *ParseError) Error() string
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) ParseAuthor ¶
func (*Parser) ParseAuthors ¶
func (*Parser) ParseCellMetadata ¶
func (*Parser) ParseCodeMirrorMode ¶
func (p *Parser) ParseCodeMirrorMode(data []byte, offset int) (CodeMirrorMode, error)
func (*Parser) ParseFalsifiable ¶
func (p *Parser) ParseFalsifiable(data []byte, offset int) (Falsifiable, error)
func (*Parser) ParseJupyterMetadata ¶
func (*Parser) ParseKernelSpec ¶
func (p *Parser) ParseKernelSpec(data []byte, offset int) (KernelSpec, error)
func (*Parser) ParseLanguageInfo ¶
func (p *Parser) ParseLanguageInfo(data []byte, offset int) (LanguageInfo, error)
func (*Parser) ParseMetadata ¶
func (*Parser) ParseOutput ¶
func (*Parser) ParseOutputFigureMetadata ¶ added in v0.0.6
func (*Parser) ParseOutputMetadata ¶
func (*Parser) ParseOutputs ¶
type RawCell ¶
type RawCell struct { CellType string `json:"cell_type"` Metadata CellMetadata `json:"metadata"` Source []string `json:"source"` Raw []byte `json:"-"` }
func (RawCell) GetMetadata ¶
func (c RawCell) GetMetadata() CellMetadata
func (RawCell) GetOutputs ¶
func (RawCell) RenderInput ¶
func (RawCell) RenderOutput ¶
type Renderer ¶
type Renderer interface { SetMetadata(metadata MetaData) GetDefaultLang() string WriteOutputs(outputs []Output) error WriteHTMLUnsafely(lines []string) error GetResources() map[string]*Resource WriteB64Image(fig *Base64Figure) (string, error) WriteHTMLEscapedLines(lines []string) error WriteMarkdownLines(lines []string) error WriteMarkdownCodeFenced(lang string, lines []string) error GetResource(contentHash string) *Resource WritePlainText(class string, lines []string, clean bool) error }
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
func NewResource ¶
func (*Resource) ContentHash ¶
Lazily computes the Base58(SHA256(data))
func (*Resource) ContentType ¶
func (*Resource) Md5 ¶ added in v0.0.4
todo: http://marcio.io/2015/07/calculating-multiple-file-hashes-in-a-single-pass/
type StreamOutput ¶
type StreamOutput struct { Name string `json:"name"` OutputType string `json:"output_type"` Text []string `json:"text"` }
func (StreamOutput) Render ¶
func (s StreamOutput) Render(r Renderer) error
func (StreamOutput) Type ¶
func (s StreamOutput) Type() string
type UnrecognizedCell ¶
type UnrecognizedCell struct { CellType string `json:"cell_type"` Metadata CellMetadata `json:"metadata"` Raw []byte `json:"-"` }
func (UnrecognizedCell) GetInput ¶
func (c UnrecognizedCell) GetInput() []string
func (UnrecognizedCell) GetMetadata ¶
func (c UnrecognizedCell) GetMetadata() CellMetadata
func (UnrecognizedCell) GetOutputs ¶
func (c UnrecognizedCell) GetOutputs() []Output
func (UnrecognizedCell) GetRaw ¶
func (c UnrecognizedCell) GetRaw() []byte
func (UnrecognizedCell) GetType ¶
func (c UnrecognizedCell) GetType() string
func (UnrecognizedCell) RenderInput ¶
func (c UnrecognizedCell) RenderInput(r Renderer) error
func (UnrecognizedCell) RenderOutput ¶
func (c UnrecognizedCell) RenderOutput(r Renderer) error
Source Files ¶
- authors.go
- base64_figure.go
- cell.go
- cell_code.go
- cell_markdown.go
- cell_raw.go
- cell_unrecognized.go
- code_mirror_mode.go
- display_data.go
- error_output.go
- execute_result.go
- falsifiable.go
- json_helpers.go
- kernel_spec.go
- language_info.go
- mime_bundle.go
- notebook.go
- notebook_metadata.go
- output_metadata.go
- outputs.go
- parser.go
- renderer.go
- resource.go
- stream_output.go
- test_helpers.go
Click to show internal directories.
Click to hide internal directories.