3

I have a.ml like this:

module type ASig = 
  sig 
    val do_something : unit -> int;;
  end ;;

module A:ASig = 
  struct 
    let do_something () = 1;;
    let do_secrectly () = 2;;
  end;;

So for my module A, the interface should be only do_something().


But if I use ocamldoc -html a.ml, although the module sig declares the interfact, the doc still exposes all functions in module A like:

module A: sig .. end
val do_something : unit -> int
val do_secrectly : unit -> int

How should I use ocamldoc so that all documents are based on module sig?

Thomash
  • 6,339
  • 1
  • 30
  • 50
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271

1 Answers1

5

This is, unfortunately, not possible with the current implementation of ocamldoc: it takes constraint into account but at a purely syntactical level, it can only use them when they are of the explicit form sig ... end instead of referring to an existing identifier (because the analysis is done by hand on the parsed syntax tree, and not on the typed tree).

You can either:

  • use a .mli and document there (if you only provide the .mli, only what's in it will be documented)

  • or use the markup (**/**) to tell ocamldoc to discard the rest of the module, module type, etc., before the functions you want to keep private.

gasche
  • 31,259
  • 3
  • 78
  • 100
  • `or use the markup (**/**) to tell ocamldoc to discard the rest of the module, module type, etc., before the functions you want to keep private.` is very helpful enough, thank you. If you could pls bold that part in your email, that would be nice as that part is actually answering this question. – Jackson Tale May 07 '13 at 12:38
  • It looks like there is some work in progress to address some of these issues with codoc: https://opam.ocaml.org/blog/codoc-0-2-0-released/ a newer ocamldoc generator. – Adam Gent Apr 19 '15 at 13:57