ExOKF.Parser (ex_okf v0.1.0)

Copy Markdown View Source

Concurrent filesystem parser for OKF bundles.

Walks a directory tree, parses markdown files with Task.async_stream, classifies reserved documents (index.md, log.md), extracts relative links, and builds an ExOKF.Bundle.

Individual file failures become diagnostics rather than aborting the load, matching OKF's permissive consumption model.

Summary

Types

Options accepted by load/2.

Functions

Loads an OKF bundle from the directory at root.

Types

option()

@type option() ::
  {:max_concurrency, pos_integer()}
  | {:timeout, timeout()}
  | {:build_graph, boolean()}

Options accepted by load/2.

  • {:max_concurrency, pos_integer()} — max parallel parse tasks (default System.schedulers_online())
  • {:timeout, timeout()} — per-task timeout (default :infinity)
  • {:build_graph, boolean()} — index the link graph after load (default true)

Functions

load(root, opts \\ [])

@spec load(String.t(), [option()]) :: {:ok, ExOKF.Bundle.t()} | {:error, term()}

Loads an OKF bundle from the directory at root.

Returns {:ok, bundle} even when warnings or per-file parse errors are present. Only a non-directory root yields {:error, reason}.

Parameters

  • root (String.t()) — path to the bundle directory
  • opts ([t:option/0]) — load options (see option/0)

Returns

  • {:ok, ExOKF.Bundle.t()} — loaded bundle (may contain diagnostics)
  • {:error, {:not_a_directory, String.t()}}root is not a directory

Examples

iex> {:ok, bundle} = ExOKF.Parser.load(ExOKF.TestSupport.minimal_fixture_path())
iex> ExOKF.Bundle.has_concept?(bundle, "hello")
true

iex> {:ok, bundle} = ExOKF.Parser.load(ExOKF.TestSupport.sample_fixture_path(), build_graph: false)
iex> bundle.graph
nil