caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Maxence Guesdon <maxence.guesdon@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Documenting submodules ?
Date: Mon, 5 May 2008 11:48:16 +0200	[thread overview]
Message-ID: <20080505114816.6638fd36@alcazar.inria.fr> (raw)
In-Reply-To: <1209978725.6431.18.camel@Blefuscu>

[-- Attachment #1: Type: text/plain, Size: 1947 bytes --]

On Mon, 05 May 2008 11:12:05 +0200
David Teller <David.Teller@univ-orleans.fr> wrote:

> On Mon, 2008-05-05 at 10:35 +0200, Maxence Guesdon wrote:
> > Indeed, ocamldoc does not use the comment of sub.ml in the page generated
> > for main.ml. This is normal behaviour. 
> 
> I'm aware that it's the normal behaviour of ocamldoc. I'm just looking
> for a work-around or a plug-in.
> 
> > You could comment the creation of the
> > Sub module (i.e. Main.Sub) by putting a comment around
> >   module Sub = Sub
> 
> I wrote that in my first post :)
> More seriously, it's ok if I have only one or two modules. But if I want
> to comment both the creation of Sub and the actual contents of Sub, it's
> not really a good method. Even more so since I have 70+ modules
> developed separately, which I attempt to present with a consistent
> Java-style package hierarchy. That would mean copying and pasting about
> 9000+ lines of code for the moment, with more coming, and nasty bugs
> lurking whenever the source packages are updated.

Sorry, I did not re-read your original post before replying. Here is
attached a custom generator that, for each module defined by the form
 module A = B
replace the comment information of A by the comment information of B, then
call the regular HTML generator. Of course, you can adapt it to do this only
for some module of your choice.

Compilation:
  ocamlc -c -I +ocamldoc odoc_example.ml

Usage:
  ocamldoc [options] -g odoc_example.cmo <your .ml{,i} files>


> > This is normal behaviour too. You're redefining a module here, and the
> > way it is defined is reflected by the html code generated by ocamldoc, with
> > a link on the Sub.SubSub page.
> 
> I have a link to an empty Sub.SubSub page. Is that normal behaviour ?

This works well for me. The page contains:
                                                    Module Sub.SubSub

module SubSub: sig .. end
  

type t

   This is SubSub.t

Regards,

Maxence

[-- Attachment #2: odoc_example.ml --]
[-- Type: text/x-ocaml, Size: 927 bytes --]

open Odoc_info;;
open Module;;

class my_generator =
  object(self)
    inherit Odoc_html.html as html

    method generate modules =
      let all_modules = Odoc_info.Search.modules modules in
      let f m =
        match m.m_kind with
          Module_alias a ->
            begin
              match a.ma_module with
                None -> () (* module not resolved in cross-reference stage *)
              | Some aliased ->
                  (* replace the info on module by info on the aliased *)
                  let info = match aliased with
                      Mod m -> m.m_info
                    | Modtype mt -> mt.mt_info
                  in
                  m.m_info <- info
            end
        | _  -> ()
      in
      List.iter f all_modules;
      html#generate modules
  end;;

let doc_generator = ((new my_generator) :> Args.doc_generator);;
let _ = Args.set_doc_generator (Some doc_generator);;

      reply	other threads:[~2008-05-05  9:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-30 22:17 David Teller
2008-05-01 19:51 ` [Caml-list] " Arnaud Spiwack
2008-05-05  8:11 ` Julien Signoles
2008-05-05  8:22   ` David Teller
2008-05-05  8:35     ` Maxence Guesdon
2008-05-05  9:12       ` David Teller
2008-05-05  9:48         ` Maxence Guesdon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080505114816.6638fd36@alcazar.inria.fr \
    --to=maxence.guesdon@inria.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).