Current section

Files

Jump to
livebook lib livebook notebook section.ex
Raw

lib/livebook/notebook/section.ex

defmodule Livebook.Notebook.Section do
# Data structure representing a single section in a notebook.
#
# Section can contains a number of cells and serves as a way of
# grouping related cells.
#
# A section may optionally have a parent, in which case it is a
# **branching section**. Such section logically follows its parent
# section and has no impact on any further sections.
defstruct [:id, :name, :cells, :parent_id]
alias Livebook.Notebook.Cell
alias Livebook.Utils
@type id :: Utils.id()
@type t :: %__MODULE__{
id: id(),
name: String.t(),
cells: list(Cell.t()),
parent_id: id() | nil
}
@doc """
Returns a blank section.
"""
@spec new() :: t()
def new() do
%__MODULE__{
id: Utils.random_id(),
name: "Section",
cells: [],
parent_id: nil
}
end
end