package
0.10.6
Repository: https://github.com/janpfeifer/gonb.git
Documentation: pkg.go.dev

# README

Package goexec

The package goexec is responsible for executing the notebook cells using Go, as well as keeping the state of all current declarations (functions, variables, types, constants, imports) that once declared, stay alive for subsequent cell executions.

The code is organized in the following files:

  • goexec.go: definition of the main State object and the various Go structs for the various declarations (functions, variables, types, constants, imports), including the concept of cursor.
  • execcode.go: implements State.ExecuteCell(), the main functionality offered by the package.
  • composer.go: generate dynamically a main.go file from pre-parsed declarations. It includes some the code that renders teh various types of declarations, and a writer that keep tabs on the cursor position.
  • parser.go: methods and objects used to parse the Go code from the cell, and again after goimports is run.

# Packages

Package goplsclient runs `gopls` (1) in the background uses it to retrieve definitions of symbols and auto-complete.

# Functions

CurrentWorkingDirectoryForPid returns the "cwd" or an error.
DeclareStringConst creates a const definition in `decls` for a string value.
DeclareVariable creates a variable definition in `decls`.
No description provided by the author
IsEmptyLines returns true is all lines are marked to skip, or if all lines not marked as skip are empty.
JupyterErrorSplit takes an error and formats it into the components Jupyter protocol uses for it.
JupyterRootDirectory returns Jupyter's root directory.
MakeFileToCellIdAndLine converts a cellId and a slice of cell line numbers for a file to a slice of CellIdAndLine.
New returns an empty State object, that can be used to execute Cells.
No description provided by the author
NewImport from the importPath and it's alias.
NewWriterWithCursor that keeps tabs of current line/col of the file (presumably) being written.
TrimGonbCommentPrefix removes a prefixing "//gonb:" (GonbCommentPrefix) from line, if there is such a prefix.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
GoGetWorkspaceIssue is an err output by `go get` due to it not interpreting correctly `go.work`.
GoGetWorkspaceNote is the note that explains the issue with `go get` and `go work`.
GonbCommentPrefix allows one to enter the special commands (`%%`, `!`) prefixed as a Go comment, so it doesn't conflict with Go IDEs.
GonbTempDirEnvName is the name of the environment variable that is set with the temporary directory used to compile user's Go code.
No description provided by the author
InitFunctionPrefix -- functions named with this prefix will be rendered as a separate `func init()`.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
LinesForErrorContext indicates how many lines to display in the error context, before and after the offending line.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

CellIdAndLine points to a line within a cell.
CellLines identifies a cell (by its execution id) and the Lines corresponding to a declaration.
Constant represents the declaration of a constant.
Cursor represents a cursor position in a cell or file.
Declarations is a collection of declarations that we carry over from one cell to another.
Function definition, parsed from a notebook cell.
GonbError is a special type of error that wraps a collection of errors returned by the Go compiler or `go get` or `go imports`.
Import represents an import to be included -- if not used it's automatically removed by `goimports`.
State holds information about Go code execution for this kernel.
TypeDecl definition, parsed from a notebook cell.
Variable definition, parsed from a notebook cell.
WriterWithCursor keep tabs of the current line/col of the file (presumably) being written.

# Type aliases

No description provided by the author