44 lines
1.3 KiB
Elixir
Generated
44 lines
1.3 KiB
Elixir
Generated
# This file is auto-generated by alef — DO NOT EDIT.
|
|
# alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
|
|
# To regenerate: alef generate
|
|
# To verify freshness: alef verify --exit-code
|
|
# Issues & docs: https://github.com/kreuzberg-dev/alef
|
|
defmodule Kreuzberg.DocumentStructure do
|
|
@moduledoc """
|
|
Top-level structured document representation.
|
|
|
|
A flat array of nodes with index-based parent/child references forming a tree.
|
|
Root-level nodes have `parent: None`. Use `body_roots()` and `furniture_roots()`
|
|
to iterate over top-level content by layer.
|
|
|
|
# Validation
|
|
|
|
Call `validate()` after construction to verify all node indices are in bounds
|
|
and parent-child relationships are bidirectionally consistent.
|
|
"""
|
|
|
|
@typedoc "Top-level structured document representation."
|
|
@type t :: %__MODULE__{
|
|
nodes: [map()],
|
|
source_format: String.t() | nil,
|
|
relationships: [map()],
|
|
node_types: [String.t()]
|
|
}
|
|
|
|
defstruct nodes: [],
|
|
source_format: nil,
|
|
relationships: [],
|
|
node_types: []
|
|
|
|
defimpl Jason.Encoder do
|
|
@doc false
|
|
def encode(value, opts) do
|
|
value
|
|
|> Map.from_struct()
|
|
|> Enum.reject(fn {_k, v} -> v == nil end)
|
|
|> Enum.into(%{})
|
|
|> Jason.Encoder.encode(opts)
|
|
end
|
|
end
|
|
end
|