checkmark
Types
Configuration for checking a markdown file.
pub opaque type CheckConfig
Indicates a check on an individual snippet failed
pub type CheckError {
RunFailed(String)
CheckFailed(String)
}
Constructors
-
RunFailed(String)
Running the check failed before we could get the result from
gleam
. The string value might currently be a bit cryptic, it should be improved. -
CheckFailed(String)
We were able to run the
gleam
operation, but it failed with the given output.
Type alias for a result of checking a single snippet.
pub type CheckResult =
Result(Nil, CheckError)
Functions
pub fn check_in_current_package(
config: CheckConfig,
as_file filename: String,
) -> Result(List(Result(Nil, CheckError)), String)
Runs checks in the current package,
writing into temporary file at src/{filename}
.
The result will be Error
if the whole operation failed (e.g. couldn’t read snippets)
or Ok
with a list of results for each snippet found in the file.
pub fn check_in_tmp_package(
config: CheckConfig,
dependencies: List(String),
) -> Result(List(Result(Nil, CheckError)), String)
Runs checks in a temporarily set up package,
installing the given dependencies using gleam add
.
The result will be Error
if the whole operation failed (e.g. couldn’t read snippets)
or Ok
with a list of results for each snippet found in the file.
pub fn filtering(
config: CheckConfig,
filter: fn(String) -> Bool,
) -> CheckConfig
Filters snippets by their content. E.g. string.starts_with(_, "import")
pub fn new() -> CheckConfig
Constructs a new check configuration with the defaults of
running gleam check
on all snippets in the README.md file.
pub fn print_failures(
result: Result(List(Result(Nil, CheckError)), String),
panic_if_failed panic_if_failed: Bool,
) -> Nil
Prints errors to stderr, as using panic
or let assert
doesn’t usually print nicely on erlang
(the data is shown as binary,
as the compiler output contains lost non-ASCII characters).
Optionally panic, if panic_if_failed
is True
.
pub fn snippets_in(
config: CheckConfig,
filename: String,
) -> CheckConfig
Specifies the markdown file to check (default is README.md)