mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-11-10 22:23:32 +08:00
39 lines
892 B
Elixir
39 lines
892 B
Elixir
defmodule Livebook.Notebook.Section do
|
|
@moduledoc false
|
|
|
|
# Data structure representing a single section in a notebook.
|
|
#
|
|
# Each section 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's
|
|
# 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
|