···1-(* Walks the directory tree rooted at the current directory,
2- displaying all directory names (skipping hidden directories and `_build`). *)
0034-open Eio.Std
56-let ( / ) = Eio.Path.( / )
0000000078-let rec scan t =
09 match Eio.Path.kind ~follow:false t with
10 | `Directory ->
11- traceln "Visiting %a" Eio.Path.pp t;
12 Eio.Path.read_dir t |> List.iter (function
13- | "_build" -> ()
14- | item when String.starts_with ~prefix:"." item -> ()
15- | item -> scan (t / item)
16- )
017 | _ -> ()
1819let () =
20 Eio_main.run @@ fun env ->
21- scan (Eio.Stdenv.cwd env)
···1+(* Walk the directory tree rooted at the current directory,
2+ showing a summary for any .mli files. *)
3+4+let ( / ) = Eio.Path.( / )
56+let is_doc_comment = String.starts_with ~prefix:"(** "
78+(* Print the first line of [t]'s doc-comment, if any *)
9+let scan_mli t f =
10+ Eio.Path.with_lines t (fun lines ->
11+ Seq.find is_doc_comment lines
12+ |> Option.iter (fun line ->
13+ let stop = String.index_from_opt line 4 '*' |> Option.value ~default:(String.length line) in
14+ Format.fprintf f "%a: %s@." Eio.Path.pp t (String.sub line 4 (stop - 4))
15+ )
16+ )
1718+(* Walk the tree rooted at [t] and scan any .mli files found. *)
19+let rec scan t f =
20 match Eio.Path.kind ~follow:false t with
21 | `Directory ->
022 Eio.Path.read_dir t |> List.iter (function
23+ | "_build" | "_opam" -> () (* Don't examine these directories *)
24+ | item when String.starts_with ~prefix:"." item -> () (* Skip hidden items *)
25+ | item -> scan (t / item) f
26+ )
27+ | `Regular_file when Filename.check_suffix (snd t) ".mli" -> scan_mli t f
28 | _ -> ()
2930let () =
31 Eio_main.run @@ fun env ->
32+ scan (Eio.Stdenv.cwd env) Format.std_formatter