Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Automatic generation of mli files
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-06-06 (11:53)
From: Maxence Guesdon <maxence.guesdon@i...>
Subject: Re: [Caml-list] Automatic generation of mli files
On Fri, 6 Jun 2003 11:57:23 +0200
Stefan Heimann <> wrote:

> Hi,
> I searching for a way for generating the .mli file for a given source .ml
> file automatically. My basic idea is like that:
> (1) Specify in the .ml file which values and types should be exported
>     and if a type should be exported abstract or not. This could be
>     done with a special comment at the top of the file.
> (2) Filter the output of `ocamlc -i' to exclude the values and types
>     that should not be exported and to make the types abstract if
>     needed.
> Of course, the tool should check of there is an existing .mli
> file. If the .mli file was not generated by the tool it is not
> overwritten. If the list of exported values and types has not changed
> the .mli file is not updated too.
> I experimented a little bit with parsing the output of `ocamlc -i'
> and printing the modified parse tree. I took must code from the ocaml
> distribution. However, I don't think that this is a good way.
> Any ideas of how to implement such a tool? Are there any existing
> tools with this functionality?

You could develop a custom generator for ocamldoc, outputting an mli
file instead of html, latex, ... files. For example, only commented
elements would be printed to the generated .mli file, and custom tags
could be used to give additional information (abstract types, ...).

See the ocamldoc manual for more information about developing custom
generators, and feel free to ask me if you encounter difficulties.

Maxence Guesdon

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: