Embed an inline test as documentation?

I would like to do something like this:

(** Validates the (string) user input and provides the entry point for later compute functions.

    The underlying list must have a minimum of 3 elements, otherwise an exception is thrown

let%test_unit _ =
  let open Base in
  [%test_eq: int list list]
  (from_input "1\n\n2\n3\n\n4") [ [ 1 ]; [ 2; 3 ]; [ 4 ] ]
let from_input input =
  |> Str.split @@ Str.regexp_string "\n\n"
  |> List.map (fun str ->
         str |> Str.split @@ Str.regexp_string "\n" |> List.map int_of_string)

And get this from my editor :

The closest I found was this project: GitHub - realworldocaml/mdx: Execute code blocks inside your documentation, which can process *.mli files.

However, it’s not quite what I’m looking for, plus I didn’t have much luck configuring this tool properly so I’m wondering if there’s an easier/better solution I haven’t found yet.