I am trying to write my own odoc generator, in a project that is using packages from opam, and dune. I’m kinda new to dune, so I’m not sure how to set it up.
Here is an explaination how to include a costum generator in ocamldoc
OCaml - The documentation generator (ocamldoc)
According to this, the (documentation)
stanza has only 2 fields package
and mld_fiels
. Nothing for custom generators. Stanza Reference — Dune documentation
Can I somehow tell dune to use this custom generator for dune build @doc
?
Here is my example setup:
# tree
.
├── a.ml # the executable
├── dune
├── dune-project
├── lib
│ ├── dune
│ ├── my_lib.ml
│ ├── something.ml
│ ├── something.mli # here is the documentation
└── my_doc_generator.ml
a.ml
let () =
Dream.run ~interface:"0.0.0.0"
@@ Dream.logger
@@ Dream.router [
Dream.get "/echo/:word"
(fun request ->
Dream.html (My_lib.Something.append_bla (Dream.param request "word")));
]
dune
(name a)
(public_name a)
(libraries my_lib))
(documentation
(package docdoc))
dune-project
(lang dune 3.14)
(package (name docdoc))
my_doc_generator.ml
module type My_generator =
sig
class html :
object
method generate : Odoc_info.Module.t_module list -> unit
end
end
module Generator =
struct
class my_generator =
object (self)
method generate module_list =
print_endline "Hallo Welt!";
List.map (fun _ -> print_endline "bla") (Odoc_info.Search.values module_list);
end
end
lib/dune
(library (name my_lib)
(public_name docdoc)
(libraries dream))
lib/my_lib.ml
module Something = Something.Something
lib/something.ml
(** The irgnored module comment *)
module Something = struct
let bla = " something"
(** Some ignored comment *)
let echo s = s
let append_bla s = s ^ bla
end
lib/something.mli
(** The module comment *)
module Something : sig
val bla : string
(** Some bla comment *)
val echo : string -> string
val append_bla : string -> string
end
9 posts - 4 participants