[MLton] SML documentation tool(s)

Daniel C. Wang danwang@CS.Princeton.EDU
Fri, 17 Jun 2005 09:52:31 -0700

A very long long time ago. I hacked the SML/NJ frontend to extract MLDoc 
from commented SML.  The hack was pretty simple.
First slurp in the AST for a ML file. Next slurp the whole file in as 
one big string. Walk the ast looking for function decls or anything else 
you wanted to annotate. Use the source position info in the ast to find 
a location in the original string. Then just do a little regexp 
searching to find the apporpiate comment. I submited this hack to the 
MLDoc folks but I don't know what happened to it.
The purpose was to generate MLdoc boilerplate for the SL/NJ library 
which was allready heavily commented.

Doing this with MLTon or any compiler should be an easy one day hack for 
someone who understands the MLton internals. If you do this after 
elaboration you can even take advantange of typeinfo to do something 
fancier. I'd suggest doing something a little smarter than my "slupr" 
the whole file in as a strings. In fact, doesn't MLTon generate etags 
info already? It would be easy just to use the etags info to search for 
comments or to hack the etags suport to do this.

Stephen Weeks wrote:

>I strongly prefer keeping documentation and code integrated
>(notwithstanding the current MLton structure documentation).  I don't
>have a strong preference as to whether we extract code from
>documentation (like ML-Doc or noweb) or documentation from code (like
>Javadoc).  I would start to get nervous, though, if the extraction of
>code from documentation became complex, since at some point one could
>start extending the language in the documentation system, which would
>be bad.