-module(metamon@annotate). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/metamon/annotate.gleam"). -export([annotate/1, annotate_value/2, current_annotations/0, footnote/1, reset/0, current_footnotes/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC( " Add per-property context that is only displayed when the property\n" " fails. Successful runs discard all annotations so the cost is zero\n" " in the happy path.\n" "\n" " The runner clears state at the start of every run and reads any\n" " remaining state on failure.\n" ). -file("src/metamon/annotate.gleam", 62). -spec read(binary()) -> list(binary()). read(Key) -> case metamon_ffi:state_get(Key) of {error, _} -> []; {ok, Raw} -> _pipe = metamon_ffi:identity(Raw), lists:reverse(_pipe) end. -file("src/metamon/annotate.gleam", 56). -spec push(binary(), binary()) -> nil. push(Key, Message) -> Updated = [Message | read(Key)], metamon_ffi:state_put(Key, Updated), nil. -file("src/metamon/annotate.gleam", 19). ?DOC( " Add a free-form message to the current property's annotation buffer.\n" " Successful runs discard the buffer, so this is cheap.\n" ). -spec annotate(binary()) -> nil. annotate(Message) -> push(<<"annotations"/utf8>>, Message). -file("src/metamon/annotate.gleam", 26). ?DOC( " Pretty-print `value` and add it to the annotation buffer with a\n" " human-readable label. The output uses Gleam's `string.inspect` so it\n" " works on any type.\n" ). -spec annotate_value(binary(), any()) -> nil. annotate_value(Label, Value) -> Rendered = <<<