I am writing a tool that reads an .mli file and automatically generates a binding to use the corresponding module from the Julia language.
I am using the
Parse.interface function to parse an .mli file. However, it does not retain documentation comments. Do you know of any way to parse an .mli file while keeping the comments attached to each declaration?
The standard Ocaml parser should retain doc-comments, turning then into attributes. Are you saying that that’s not happening? You can check by parsing with compiler-libs, then pretty-printing with same – you should see the doc-comment attributes.
Oh, I did not know that doc-comments were turned into attributes. Do you have a reference to a place documenting this behavior?
Heh, I don’t. But I learned it by doing the experiment I suggested. Also though, I believe that this is how
odoc works (last I checked, at least). I also note that this is not how ocanldoc works – it actually searches for doc-comments in the text between lexemes, etc, etc.
Oh! Thank you! I hadn’t found this when I was searching for a description of the behaviour. Now I can compare this to my unit-tests.