Generate autodoc index with SML/NJ HTML lib
authorAdam Chlipala <adamc@hcoop.net>
Mon, 4 Sep 2006 00:49:06 +0000 (00:49 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Mon, 4 Sep 2006 00:49:06 +0000 (00:49 +0000)
src/autodoc.sml
src/htmlPrint.sig
src/htmlPrint.sml

index fae4495..71ff33d 100644 (file)
@@ -87,6 +87,12 @@ fun autodoc {outdir, infiles} =
                                                       P {align = NONE,
                                                          content = PCDATA desc}]
 
                                                       P {align = NONE,
                                                          content = PCDATA desc}]
 
+               val summaries = foldr (fn ((d, desc, _), summaries) =>
+                                       HtmlPrint.output (p_decl_fref (annotate_decl d))
+                                       :: BR {clear = NONE}
+                                       :: summaries)
+                                   [] decls
+
                val entries = map (fn (d, desc, _) =>
                                      let
                                          val cblock = HtmlPrint.output (p_decl (annotate_decl d))
                val entries = map (fn (d, desc, _) =>
                                      let
                                          val cblock = HtmlPrint.output (p_decl (annotate_decl d))
@@ -100,7 +106,17 @@ fun autodoc {outdir, infiles} =
                                                     dblock]
                                      end) decls
 
                                                     dblock]
                                      end) decls
 
-               val body = BlockList (body :: entries)
+               val body = BlockList (body
+                                     :: HR {align = NONE,
+                                            noshade = false,
+                                            size = NONE,
+                                            width = NONE}
+                                     :: TextBlock (TT (TextList summaries))
+                                     :: HR {align = NONE,
+                                            noshade = false,
+                                            size = NONE,
+                                            width = NONE}
+                                     :: entries)
 
                val html = HTML {version = NONE,
                                 head = [Head_TITLE title],
 
                val html = HTML {version = NONE,
                                 head = [Head_TITLE title],
@@ -112,34 +128,43 @@ fun autodoc {outdir, infiles} =
                                              alink = NONE,
                                              content = body}}
            in
                                              alink = NONE,
                                              content = body}}
            in
-               (*TextIO.output (outf, Config.Autodoc.htmlHeader ("Domtool Module " ^ uppercase file'));
-               Option.app (fn desc => (TextIO.output (outf, desc);
-                                       TextIO.output (outf, "\n"))) desc;
-
-               app doDecl decls;
-
-               TextIO.output (outf, Config.Autodoc.htmlFooter);*)
                PrHTML.prHTML {putc = (fn ch => TextIO.output1 (outf, ch)),
                               puts = (fn s => TextIO.output (outf, s))} html;
                TextIO.closeOut outf
            end
 
                PrHTML.prHTML {putc = (fn ch => TextIO.output1 (outf, ch)),
                               puts = (fn s => TextIO.output (outf, s))} html;
                TextIO.closeOut outf
            end
 
+       val title = "Domtool Module Index"
+
+       val items = map (fn file =>
+                           let
+                               val file' = modify file
+                           in
+                               LI {ty = NONE,
+                                   value = NONE,
+                                   content = TextBlock (A {name = NONE,
+                                                           href = SOME (file' ^ ".html"),
+                                                           rel = NONE,
+                                                           rev = NONE,
+                                                           title = NONE,
+                                                           content = PCDATA (uppercase file')})}
+                           end) infiles
+
+       val index = HTML {version = NONE,
+                         head = [Head_TITLE title],
+                         body = BODY {background = NONE,
+                                      bgcolor = NONE,
+                                      text = NONE,
+                                      link = NONE,
+                                      vlink = NONE,
+                                      alink = NONE,
+                                      content = UL {ty = NONE,
+                                                    compact = false,
+                                                    content = items}}}
+
        val outf = TextIO.openOut (outdir ^ "/index.html")
     in
        val outf = TextIO.openOut (outdir ^ "/index.html")
     in
-       TextIO.output (outf, Config.Autodoc.htmlHeader "Domtool Module Index");
-
-       app (fn file =>
-               let
-                   val file' = modify file
-               in
-                   TextIO.output (outf, "<li> <a href=\"");
-                   TextIO.output (outf, file');
-                   TextIO.output (outf, ".html\">");
-                   TextIO.output (outf, uppercase file');
-                   TextIO.output (outf, "</a></li>\n")
-               end) infiles;
-                        
-       TextIO.output (outf, Config.Autodoc.htmlFooter);
+       PrHTML.prHTML {putc = (fn ch => TextIO.output1 (outf, ch)),
+                      puts = (fn s => TextIO.output (outf, s))} index; 
        TextIO.closeOut outf;
 
        app doFile infiles
        TextIO.closeOut outf;
 
        app doFile infiles
index 7b0297b..016a579 100644 (file)
@@ -28,6 +28,7 @@ val p_pred : Ast.pred -> PD.pp_desc
 val p_typ : Ast.typ -> PD.pp_desc
 val p_exp : Ast.exp -> PD.pp_desc
 val p_decl : Ast.decl' -> PD.pp_desc
 val p_typ : Ast.typ -> PD.pp_desc
 val p_exp : Ast.exp -> PD.pp_desc
 val p_decl : Ast.decl' -> PD.pp_desc
+val p_decl_fref : Ast.decl' -> PD.pp_desc
 
 val output : PD.pp_desc -> HTML.text
 
 
 val output : PD.pp_desc -> HTML.text
 
index d607d46..5b756c3 100644 (file)
@@ -181,6 +181,26 @@ fun p_decl d =
                                [dBox [keyword "context", space 1,
                                       ident name]])
 
                                [dBox [keyword "context", space 1,
                                       ident name]])
 
+fun p_decl_fref d =
+    case d of
+       DExternType name => dBox [keyword "extern", space 1,
+                                 keyword "type", space 1,
+                                 style (HTMLDev.link ("#T_" ^ name), [ident name])]
+      | DExternVal (name, t) => dBox [keyword "extern", space 1,
+                                     keyword "val", space 1,
+                                     style (HTMLDev.link ("#V_" ^ name), [ident name]),
+                                     space 1,
+                                     string ":", space 1,
+                                     p_typ t]
+      | DVal (name, NONE, _) => string "Unannotated val declaration!"
+      | DVal (name, SOME t, _) => dBox [keyword "val", space 1,
+                                       style (HTMLDev.link ("#V_" ^ name), [ident name]),
+                                       space 1,
+                                       punct ":", space 1,
+                                       p_typ t]
+      | DContext name => dBox [keyword "context", space 1,
+                              style (HTMLDev.link ("#C_" ^ name), [ident name])]
+
 fun output d =
     let
        val dev = HTMLDev.openDev {wid = 80,
 fun output d =
     let
        val dev = HTMLDev.openDev {wid = 80,