ExOKF.Index (ex_okf v0.1.0)

Copy Markdown View Source

An OKF index.md reserved document (OKF §6).

Index files enumerate a directory's contents for progressive disclosure. Bundle-root indexes may carry frontmatter solely to declare okf_version. Nested indexes must not have frontmatter.

Fields

FieldTypeDescription
pathString.t()Bundle-relative path. Example: "tables/index.md".
directoryString.t()Parent directory within the bundle ("" for root). Example: "tables".
okf_versionString.t() | nilDeclared OKF version from root frontmatter, e.g. "0.1".
frontmattermap() | nilParsed YAML map when present (root only); otherwise nil.
bodyString.t()Markdown listing body.
entries[t:entry/0]Parsed bullet entries (* [Title](url) - description).
links[ExOKF.Link.t()]All markdown links found in body.
raw_frontmatterString.t() | nilOriginal YAML text when the root index declared a version.

Example

%ExOKF.Index{
  path: "index.md",
  directory: "",
  okf_version: "0.1",
  frontmatter: %{"okf_version" => "0.1"},
  body: "# Tables\n\n* [Orders](tables/orders.md) - One row per order.\n",
  entries: [
    %{text: "Orders", target: "tables/orders.md", description: "One row per order."}
  ],
  links: [],
  raw_frontmatter: "okf_version: \"0.1\""
}

Summary

Types

A single bullet entry from an index listing.

t()

An OKF index document.

Functions

Returns true when this is the bundle-root index.md.

Types

entry()

@type entry() :: %{
  text: String.t(),
  target: String.t(),
  description: String.t() | nil
}

A single bullet entry from an index listing.

  • :text (String.t()) — link label, e.g. "Orders"
  • :target (String.t()) — href as written, e.g. "orders.md" or "datasets/"
  • :description (String.t() \| nil) — optional trailing summary after -

t()

@type t() :: %ExOKF.Index{
  body: String.t(),
  directory: String.t(),
  entries: [entry()],
  frontmatter: map() | nil,
  links: [ExOKF.Link.t()],
  okf_version: String.t() | nil,
  path: String.t(),
  raw_frontmatter: String.t() | nil
}

An OKF index document.

See the module documentation for field meanings and a full example.

Functions

root?(index)

@spec root?(t()) :: boolean()

Returns true when this is the bundle-root index.md.

Root indexes are those whose directory is "", ".", or "./".

Parameters

  • index (t/0) — index to inspect

Examples

iex> ExOKF.Index.root?(%ExOKF.Index{path: "index.md", directory: ""})
true

iex> ExOKF.Index.root?(%ExOKF.Index{path: "tables/index.md", directory: "tables"})
false