notebook

package module
v0.0.0-...-112b2f1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2025 License: BSD-2-Clause Imports: 9 Imported by: 0

README

notebook

A Notebook is a simple Go package to easily generate HTML file that look likes a 'notebook'.

The generated notebook has some level of configuration but it is mainly opinionated, and comes with sensible defaults. The objective is to allow the user to focus on the simulation code, and to generate a notebook to visualize the results fairly easily.

Like markdown, or static site generator, the focus in on the balance between content (here simulation code) and good enough rendering.

third party packages (not linked to avoid dependencies) can add specialized Cells to the notebook based on simulation primitives.

  • gonum extension to display any gonum chart
  • markdown extension to easily insert markdown and math in a cell.
  • table extension to ease the rendering of an html table.
  • timeserie extension to display timeseries in tables
  • vector extension to render vector of floats, or numbers in a table
  • ...

Documentation

Index

Constants

View Source
const HeaderCellStyle = "cell-style" // ID to set a style header to style cells. A default value is provided.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notebook

type Notebook struct {
	Title  string // The notebook title.
	Output string // A filename to save the Notebook to.
	// contains filtered or unexported fields
}

Notebook is a struct to receive all the contents of a notebook in memory.

func New

func New() *Notebook

New creates a new Notebook.

Output filename is initialized to be the os.Arg[0] +'.html'.

func (*Notebook) AddContent

func (nb *Notebook) AddContent(title string, content string)

AddContent appends html content into a new Cell.

func (*Notebook) AddHeader

func (nb *Notebook) AddHeader(id string, content string)

AddHeader appends a header statement, once per ID. Calling AddHeader with the same ID will overwrite the existing value.

func (*Notebook) Close

func (nb *Notebook) Close() error

Close generates the notebook as HTML into the output file.

func (*Notebook) Print

func (nb *Notebook) Print(a ...any) (n int, err error)

Print behave like fmt.Print but on the notebook console.

func (*Notebook) Printf

func (nb *Notebook) Printf(format string, a ...any) (n int, err error)

Printf behave like fmt.Printf but on the notebook console.

func (*Notebook) Println

func (nb *Notebook) Println(a ...any) (n int, err error)

Println behave like fmt.Println but on the notebook console.

func (*Notebook) Render

func (nb *Notebook) Render(w io.Writer) error

Render the notebook into a writer.

Jump to

Keyboard shortcuts

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