package mdx

  1. Overview
  2. Docs

Module Mdx.BlockSource

Code blocks headers.

Sourcemodule Header : sig ... end

Code blocks.

Sourcetype cram_value = {
  1. language : [ `Bash | `Sh ];
  2. non_det : Label.non_det option;
}
Sourcetype ocaml_value = {
  1. env : Ocaml_env.t;
    (*

    env is the name given to the environment where tests are run.

    *)
  2. non_det : Label.non_det option;
  3. errors : Output.t list;
    (*

    header defines whether a header was specified for the block.

    *)
  4. header : Header.t option;
}
Sourcetype toplevel_value = {
  1. env : Ocaml_env.t;
    (*

    env is the name given to the environment where tests are run.

    *)
  2. non_det : Label.non_det option;
}
Sourcetype include_ocaml_file = {
  1. part_included : string option;
    (*

    part_included is the part of the file to synchronize with. If lines is not specified synchronize the whole file.

    *)
}
Sourcetype include_other_file = {
  1. header : Header.t option;
}
Sourcetype include_file_kind =
  1. | Fk_ocaml of include_ocaml_file
  2. | Fk_other of include_other_file
Sourcetype include_value = {
  1. file_included : string;
    (*

    file_included is the name of the file to synchronize with.

    *)
  2. file_kind : include_file_kind;
}
Sourcetype raw_value = {
  1. header : Header.t option;
}
Sourcetype value =
  1. | Raw of raw_value
  2. | OCaml of ocaml_value
  3. | Cram of cram_value
  4. | Toplevel of toplevel_value
  5. | Include of include_value

The type for block values.

Sourcetype section = int * string

The type for sections.

Sourcemodule Raw : sig ... end
Sourcetype t = {
  1. loc : Location.t;
  2. section : section option;
  3. dir : string option;
  4. labels : Label.t list;
  5. legacy_labels : bool;
  6. contents : string list;
  7. skip : bool;
  8. version_enabled : bool;
    (*

    Whether the current OCaml version complies with the block's version.

    *)
  9. set_variables : (string * string) list;
  10. unset_variables : string list;
  11. value : value;
}

The type for supported code blocks.

Sourceval mk : loc:Location.t -> section:section option -> labels:Label.t list -> legacy_labels:bool -> header:Header.t option -> contents:string list -> errors:Output.t list -> (t, [ `Msg of string ]) result
Sourceval mk_include : loc:Location.t -> section:section option -> labels:Label.t list -> (t, [ `Msg of string ]) result

mk_include builds an include block from a comment <!-- $MDX ... --> that is not followed by a code block ``` ... ```.

Sourceval from_raw : Raw.t -> (t, [ `Msg of string ] list) Result.result

Printers

Sourceval dump : t Fmt.t

dump is the printer for dumping code blocks. Useful for debugging.

Sourceval pp_header : ?syntax:Syntax.t -> t Fmt.t

pp_header pretty-prints full block headers with the labels.

Sourceval pp_contents : ?syntax:Syntax.t -> t Fmt.t

pp_contents pretty-prints block contents.

pp_footer pretty-prints block footer.

Sourceval pp : ?syntax:Syntax.t -> t Fmt.t

pp pretty-prints blocks.

Accessors

Sourceval non_det : t -> Label.non_det option

Whether a block's command or output is non-deterministic.

Sourceval directory : t -> string option

directory t is the directory where t tests should be run.

Sourceval file : t -> string option

file t is the name of the file to synchronize t with.

Sourceval set_variables : t -> (string * string) list

set_variable t is the list of environment variable to set and their values

Sourceval unset_variables : t -> string list

unset_variable t is the list of environment variable to unset

Sourceval skip : t -> bool

skip t is true iff skip is in the labels of t.

Sourceval value : t -> value

value t is t's value.

Sourceval section : t -> section option

section t is t's section.

Sourceval is_active : ?section:string -> t -> bool

Helpers

Sourceval ends_by_semi_semi : string list -> bool
OCaml

Innovation. Community. Security.