ExOKF.Diagnostic (ex_okf v0.1.0)

Copy Markdown View Source

A single validation or parse diagnostic.

Severities follow OKF's permissive consumption model: warnings never invalidate a bundle; only :error diagnostics make a bundle non-conformant.

Fields

FieldTypeDescription
severityseverity/0:error, :warning, or :info.
codeatom()Machine-readable code, e.g. :broken_internal_link, :missing_type.
messageString.t()Human-readable explanation.
pathString.t() | nilBundle-relative file path when applicable, e.g. "tables/customers.md".
metamap()Extra structured context (target id, field name, underlying reason, …).

Examples

%ExOKF.Diagnostic{
  severity: :warning,
  code: :broken_internal_link,
  message: "broken internal link to tables/legacy",
  path: "tables/customers.md",
  meta: %{concept_id: "tables/legacy", target: "/tables/legacy.md"}
}

%ExOKF.Diagnostic{
  severity: :error,
  code: :missing_type,
  message: "missing required type field",
  path: "metrics/revenue.md",
  meta: %{}
}

Summary

Types

Diagnostic severity.

t()

A single diagnostic entry.

Functions

Formats a diagnostic as a human-readable line.

Types

severity()

@type severity() :: :error | :warning | :info

Diagnostic severity.

  • :error — conformance failure (missing type, unparseable frontmatter, …)
  • :warning — soft guidance (broken links, missing recommended fields, …)
  • :info — informational notes that never affect conformance

t()

@type t() :: %ExOKF.Diagnostic{
  code: atom(),
  message: String.t(),
  meta: map(),
  path: String.t() | nil,
  severity: severity()
}

A single diagnostic entry.

See the module documentation for field meanings and examples.

Functions

format(d)

@spec format(t()) :: String.t()

Formats a diagnostic as a human-readable line.

Parameters

  • diagnostic (t/0) — entry to format

Examples

iex> ExOKF.Diagnostic.format(%ExOKF.Diagnostic{
...>   severity: :warning,
...>   code: :broken_internal_link,
...>   message: "broken internal link",
...>   path: "a.md"
...> })
"warning: broken internal link (a.md)"