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)

Specifies the gleam CLI operation to run on each snippet

pub type Operation {
  Check
  Build
  Run
}

Constructors

  • Check

    Will run gleam check on the code

  • Build

    Will run gleam build on the code

  • Run

    Will run gleam run on the code

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 snippets_in(
  config: CheckConfig,
  filename: String,
) -> CheckConfig

Specifies the markdown file to check (default is README.md)

pub fn using(
  config: CheckConfig,
  operation: Operation,
) -> CheckConfig

Uses the given operation, default is Check

Search Document