caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Till Varoquaux <till@pps.jussieu.fr>
To: Caml-list List <caml-list@inria.fr>
Subject: [Caml-list] Re: Using a custom ocamldoc html with ocamlbuild
Date: Fri, 10 Jun 2011 16:58:22 -0400	[thread overview]
Message-ID: <BANLkTi=ZDwDuR7h0mMpiZC6ihON0DgLxuw@mail.gmail.com> (raw)
In-Reply-To: <BANLkTi=nyaRvpoy-vJJDuKy4n-Ka--M9Xg@mail.gmail.com>

On Fri, Jun 10, 2011 at 12:00 PM, Till Varoquaux <till@pps.jussieu.fr> wrote:
> Hello everyone.
>
> I am currently trying to cajole ocamlbuild into using a custom
> generator. Adding the extra command line arguments to load the
> generator isn't hard:
>
> flag ["doc";"ocaml"] & S[A"-i";A "+custom";A "my_gen.cmo"]
>
> The tricky part is removing the -html flag that is passed to ocamldoc.
> As far as I can tell there's no easy to do so (Flags.remove does not
> actually allow you to do that). Maybe there's a way I could remove the
> "extension:html" tag and therefore avoid triggering the rule that adds
> -html?
>
> All best,
> Till
>

As suggested by Christophe Troestler the solution seemed indeed to
write my own rule. The hack is to dynamically remove the
"extension:html" tag from the list...

    open Ocamlbuild_pack

    let ocdoc_plus =
       let base = My_unix.run_and_read "ocamlfind query ocamldoc_htmlplus" in
       (* TODO: check that we are indeed stripping the trailling nl. *)
       String.sub base 0 (String.length base -1)

    (* calls out to Ocaml_tools.ocamldoc_l_dir but filters out the
"extension:html"
       flag which causes  -html to be added to the ocamldoc command line.*)
    let my_ocamldoc tags deps docout docdir =
      let tags = tags -- "extension:html" in
      Ocaml_tools.ocamldoc_l_dir tags deps docout docdir

    (* copy of the normal ocamldoc rule that uses our custom generator. *)
    let () = Rule.rule
     "ocamldoc: document ocaml project odocl & *odoc -> docdir (html+)"
     ~insert:`top
     ~prod:"%.docdir/index.html"
     ~stamp:"%.docdir/html.stamp"
     ~dep:"%.odocl"
     (Ocaml_tools.document_ocaml_project
         ~ocamldoc:my_ocamldoc
         "%.odocl" "%.docdir/index.html" "%.docdir");

     dep  ["doc";"ocaml";"intro"] ["lib/intro.txt"];
     flag ["doc";"ocaml"] & S[A"-i";A
ocdoc_plus;A"-g";A"ocamldoc_htmlplus.cma"];
     flag ["doc";"ocaml";"intro"] & S[A"-intro";A"lib/intro.txt"]

All in all this isn't actually as bad as I thought it might be. If
anyone can think of any cleaner way to proceed I am all ears...

Thanks,
Till

      reply	other threads:[~2011-06-10 20:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-10 16:00 [Caml-list] " Till Varoquaux
2011-06-10 20:58 ` Till Varoquaux [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='BANLkTi=ZDwDuR7h0mMpiZC6ihON0DgLxuw@mail.gmail.com' \
    --to=till@pps.jussieu.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).