src/Pure/Thy/present.ML
author wenzelm
Thu, 15 Sep 2005 17:16:56 +0200
changeset 17412 e26cb20ef0cc
parent 17221 6cd180204582
child 17496 26535df536ae
permissions -rw-r--r--
TableFun/Symtab: curried lookup and update;
     1 (*  Title:      Pure/Thy/present.ML
     2     ID:         $Id$
     3     Author:     Markus Wenzel and Stefan Berghofer, TU Muenchen
     4 
     5 Theory presentation: HTML, graph files, (PDF)LaTeX documents.
     6 *)
     7 
     8 signature BASIC_PRESENT =
     9 sig
    10   val no_document: ('a -> 'b) -> 'a -> 'b
    11   val section: string -> unit
    12 end;
    13 
    14 signature PRESENT =
    15 sig
    16   include BASIC_PRESENT
    17   val get_info: theory -> {name: string, session: string list, is_local: bool}
    18   val write_graph: {name: string, ID: string, dir: string, unfold: bool,
    19    path: string, parents: string list} list -> Path.T -> unit
    20   val init: bool -> bool -> string -> bool -> string list -> string list ->
    21     string -> (bool * Path.T) option -> Url.T option * bool -> bool -> unit
    22   val finish: unit -> unit
    23   val init_theory: string -> unit
    24   val verbatim_source: string -> (unit -> Symbol.symbol list) -> unit
    25   val old_symbol_source: string -> (unit -> Symbol.symbol list) -> unit
    26   val theory_output: string -> string -> unit
    27   val begin_theory: Path.T option -> string -> string list ->
    28     (Path.T * bool) list -> theory -> theory
    29   val add_hook: (string -> (string * thm list) list -> unit) -> unit
    30   val results: string -> (string * thm list) list -> unit
    31   val theorem: string -> thm -> unit
    32   val theorems: string -> thm list -> unit
    33   val chapter: string -> unit
    34   val subsection: string -> unit
    35   val subsubsection: string -> unit
    36   val drafts: string -> Path.T list -> Path.T
    37 end;
    38 
    39 structure Present: PRESENT =
    40 struct
    41 
    42 
    43 (** paths **)
    44 
    45 val output_path = Path.variable "ISABELLE_BROWSER_INFO";
    46 
    47 val tex_ext = Path.ext "tex";
    48 val tex_path = tex_ext o Path.basic;
    49 val html_ext = Path.ext "html";
    50 val html_path = html_ext o Path.basic;
    51 val index_path = Path.basic "index.html";
    52 val readme_html_path = Path.basic "README.html";
    53 val readme_path = Path.basic "README";
    54 val documentN = "document";
    55 val document_path = Path.basic documentN;
    56 val doc_indexN = "session";
    57 val graph_path = Path.basic "session.graph";
    58 val graph_pdf_path = Path.basic "session_graph.pdf";
    59 val graph_eps_path = Path.basic "session_graph.eps";
    60 
    61 val session_path = Path.basic ".session";
    62 val session_entries_path = Path.unpack ".session/entries";
    63 val pre_index_path = Path.unpack ".session/pre-index";
    64 
    65 fun mk_rel_path [] ys = Path.make ys
    66   | mk_rel_path xs [] = Path.appends (replicate (length xs) Path.parent)
    67   | mk_rel_path (ps as x :: xs) (qs as y :: ys) = if x = y then mk_rel_path xs ys else
    68       Path.appends (replicate (length ps) Path.parent @ [Path.make qs]);
    69 
    70 fun show_path path = Path.pack (Path.append (File.pwd ()) path);
    71 
    72 
    73 
    74 (** additional theory data **)
    75 
    76 structure BrowserInfoData = TheoryDataFun
    77 (struct
    78   val name = "Pure/browser_info";
    79   type T = {name: string, session: string list, is_local: bool};
    80   val empty = {name = "", session = [], is_local = false}: T;
    81   val copy = I;
    82   fun extend _ = empty;
    83   fun merge _ _ = empty;
    84   fun print _ _ = ();
    85 end);
    86 
    87 val _ = Context.add_setup [BrowserInfoData.init];
    88 
    89 fun get_info thy =
    90   if Context.theory_name thy mem_string [Context.ProtoPureN, Context.PureN, Context.CPureN]
    91   then {name = Context.PureN, session = [], is_local = false}
    92   else BrowserInfoData.get thy;
    93 
    94 
    95 
    96 (** graphs **)
    97 
    98 type graph_node =
    99   {name: string, ID: string, dir: string, unfold: bool,
   100    path: string, parents: string list};
   101 
   102 fun write_graph gr path =
   103   File.write path (cat_lines (map (fn {name, ID, dir, unfold, path, parents} =>
   104     "\"" ^ name ^ "\" \"" ^ ID ^ "\" \"" ^ dir ^ (if unfold then "\" + \"" else "\" \"") ^
   105     path ^ "\" > " ^ space_implode " " (map Library.quote parents) ^ " ;") gr));
   106 
   107 fun ID_of sess s = space_implode "/" (sess @ [s]);
   108 
   109 (*retrieve graph data from initial theory loader database*)
   110 fun init_graph remote_path curr_sess = map (fn name =>
   111   let
   112     val {name = sess_name, session, is_local} = get_info (ThyInfo.theory name);
   113     val path' = Path.append (Path.make session) (html_path name);
   114   in
   115    {name = name, ID = ID_of session name, dir = sess_name,
   116     path =
   117       if null session then "" else
   118       if is_some remote_path andalso not is_local then
   119         Url.pack (Url.append (the remote_path) (Url.File
   120           (Path.append (Path.make session) (html_path name))))
   121       else Path.pack (Path.append (mk_rel_path curr_sess session) (html_path name)),
   122     unfold = false,
   123     parents =
   124       map (fn s => ID_of (#session (get_info (ThyInfo.theory s))) s) (ThyInfo.get_preds name)}
   125   end) (ThyInfo.names ());
   126 
   127 fun ins_graph_entry (entry as {ID, ...}) (gr: graph_node list) =
   128   filter_out (fn entry' => #ID entry' = ID) gr @ [entry];
   129 
   130 
   131 
   132 (** global browser info state **)
   133 
   134 (* type theory_info *)
   135 
   136 type theory_info = {tex_source: Buffer.T, html_source: Buffer.T, html: Buffer.T};
   137 
   138 fun make_theory_info (tex_source, html_source, html) =
   139   {tex_source = tex_source, html_source = html_source, html = html}: theory_info;
   140 
   141 val empty_theory_info = make_theory_info (Buffer.empty, Buffer.empty, Buffer.empty);
   142 
   143 fun map_theory_info f {tex_source, html_source, html} =
   144   make_theory_info (f (tex_source, html_source, html));
   145 
   146 
   147 (* type browser_info *)
   148 
   149 type browser_info = {theories: theory_info Symtab.table, files: (Path.T * string) list,
   150   tex_index: Buffer.T, html_index: Buffer.T, graph: graph_node list};
   151 
   152 fun make_browser_info (theories, files, tex_index, html_index, graph) =
   153   {theories = theories, files = files, tex_index = tex_index, html_index = html_index,
   154     graph = graph}: browser_info;
   155 
   156 val empty_browser_info = make_browser_info (Symtab.empty, [], Buffer.empty, Buffer.empty, []);
   157 
   158 fun init_browser_info remote_path curr_sess = make_browser_info
   159   (Symtab.empty, [], Buffer.empty, Buffer.empty, init_graph remote_path curr_sess);
   160 
   161 fun map_browser_info f {theories, files, tex_index, html_index, graph} =
   162   make_browser_info (f (theories, files, tex_index, html_index, graph));
   163 
   164 
   165 (* state *)
   166 
   167 val browser_info = ref empty_browser_info;
   168 fun change_browser_info f = browser_info := map_browser_info f (! browser_info);
   169 
   170 val suppress_tex_source = ref false;
   171 fun no_document f x = Library.setmp suppress_tex_source true f x;
   172 
   173 fun init_theory_info name info =
   174   change_browser_info (fn (theories, files, tex_index, html_index, graph) =>
   175     (Symtab.update (name, info) theories, files, tex_index, html_index, graph));
   176 
   177 fun change_theory_info name f =
   178   change_browser_info (fn (info as (theories, files, tex_index, html_index, graph)) =>
   179     (case Symtab.lookup theories name of
   180       NONE => (warning ("Browser info: cannot access theory document " ^ quote name); info)
   181     | SOME info => (Symtab.update (name, map_theory_info f info) theories, files,
   182         tex_index, html_index, graph)));
   183 
   184 
   185 fun add_file file =
   186   change_browser_info (fn (theories, files, tex_index, html_index, graph) =>
   187     (theories, file :: files, tex_index, html_index, graph));
   188 
   189 fun add_tex_index txt =
   190   change_browser_info (fn (theories, files, tex_index, html_index, graph) =>
   191     (theories, files, Buffer.add txt tex_index, html_index, graph));
   192 
   193 fun add_html_index txt =
   194   change_browser_info (fn (theories, files, tex_index, html_index, graph) =>
   195     (theories, files, tex_index, Buffer.add txt html_index, graph));
   196 
   197 fun add_graph_entry e =
   198   change_browser_info (fn (theories, files, tex_index, html_index, graph) =>
   199     (theories, files, tex_index, html_index, ins_graph_entry e graph));
   200 
   201 fun add_tex_source name txt =
   202   if ! suppress_tex_source then ()
   203   else change_theory_info name (fn (tex_source, html_source, html) =>
   204     (Buffer.add txt tex_source, html_source, html));
   205 
   206 fun add_html_source name txt = change_theory_info name (fn (tex_source, html_source, html) =>
   207   (tex_source, Buffer.add txt html_source, html));
   208 
   209 fun add_html name txt = change_theory_info name (fn (tex_source, html_source, html) =>
   210   (tex_source, html_source, Buffer.add txt html));
   211 
   212 
   213 
   214 (** global session state **)
   215 
   216 (* session_info *)
   217 
   218 type session_info =
   219   {name: string, parent: string, session: string, path: string list, html_prefix: Path.T,
   220     info: bool, doc_format: string, doc_graph: bool, documents: (string * string) list,
   221     doc_prefix1: (Path.T * Path.T) option, doc_prefix2: (bool * Path.T) option,
   222     remote_path: Url.T option, verbose: bool, readme: Path.T option};
   223 
   224 fun make_session_info
   225   (name, parent, session, path, html_prefix, info, doc_format, doc_graph, documents,
   226     doc_prefix1, doc_prefix2, remote_path, verbose, readme) =
   227   {name = name, parent = parent, session = session, path = path, html_prefix = html_prefix,
   228     info = info, doc_format = doc_format, doc_graph = doc_graph, documents = documents,
   229     doc_prefix1 = doc_prefix1, doc_prefix2 = doc_prefix2, remote_path = remote_path,
   230     verbose = verbose, readme = readme}: session_info;
   231 
   232 
   233 (* state *)
   234 
   235 val session_info = ref (NONE: session_info option);
   236 
   237 fun with_session x f = (case ! session_info of NONE => x | SOME info => f info);
   238 fun with_context f = f (Context.theory_name (Context.the_context ()));
   239 
   240 
   241 
   242 (** document preparation **)
   243 
   244 (* maintain index *)
   245 
   246 val session_entries =
   247   HTML.session_entries o
   248     map (fn name => (Url.File (Path.append (Path.basic name) index_path), name));
   249 
   250 fun get_entries dir =
   251   split_lines (File.read (Path.append dir session_entries_path));
   252 
   253 fun put_entries entries dir =
   254   File.write (Path.append dir session_entries_path) (cat_lines entries);
   255 
   256 
   257 fun create_index dir =
   258   File.read (Path.append dir pre_index_path) ^
   259     session_entries (get_entries dir) ^ HTML.end_index
   260   |> File.write (Path.append dir index_path);
   261 
   262 fun update_index dir name =
   263   (case try get_entries dir of
   264     NONE => warning ("Browser info: cannot access session index of " ^ quote (Path.pack dir))
   265   | SOME es => (put_entries ((es \ name) @ [name]) dir; create_index dir));
   266 
   267 
   268 (* document versions *)
   269 
   270 fun read_version str =
   271   (case space_explode "=" str of
   272     [name] => (name, "")
   273   | [name, tags] => (name, tags)
   274   | _ => error ("Malformed document version specification: " ^ quote str));
   275 
   276 fun read_versions strs =
   277   rev (gen_distinct eq_fst (rev ((documentN, "") :: map read_version strs)))
   278   |> filter_out (equal "-" o #2);
   279 
   280 
   281 (* init session *)
   282 
   283 fun name_of_session elems = space_implode "/" ("Isabelle" :: elems);
   284 
   285 fun init build info doc doc_graph doc_versions path name doc_prefix2
   286     (remote_path, first_time) verbose =
   287   if not build andalso not info andalso doc = "" andalso is_none doc_prefix2 then
   288     (browser_info := empty_browser_info; session_info := NONE)
   289   else
   290     let
   291       val parent_name = name_of_session (Library.take (length path - 1, path));
   292       val session_name = name_of_session path;
   293       val sess_prefix = Path.make path;
   294       val html_prefix = Path.append (Path.expand output_path) sess_prefix;
   295 
   296       val (doc_prefix1, documents) =
   297         if doc = "" then (NONE, [])
   298         else if not (File.exists document_path) then (conditional verbose (fn () =>
   299           std_error "Warning: missing document directory\n"); (NONE, []))
   300         else (SOME (Path.append html_prefix document_path, html_prefix),
   301           read_versions doc_versions);
   302 
   303       val parent_index_path = Path.append Path.parent index_path;
   304       val index_up_lnk = if first_time then
   305           Url.append (the remote_path) (Url.File (Path.append sess_prefix parent_index_path))
   306         else Url.File parent_index_path;
   307       val readme =
   308         if File.exists readme_html_path then SOME readme_html_path
   309         else if File.exists readme_path then SOME readme_path
   310         else NONE;
   311 
   312       val docs =
   313         (case readme of NONE => [] | SOME p => [(Url.File p, "README")]) @
   314         map (fn (name, _) => (Url.File (Path.ext doc (Path.basic name)), name)) documents;
   315       val index_text = HTML.begin_index (index_up_lnk, parent_name)
   316         (Url.File index_path, session_name) docs (Url.unpack "medium.html");
   317     in
   318       session_info := SOME (make_session_info (name, parent_name, session_name, path, html_prefix,
   319       info, doc, doc_graph, documents, doc_prefix1, doc_prefix2, remote_path, verbose, readme));
   320       browser_info := init_browser_info remote_path path;
   321       add_html_index index_text
   322     end;
   323 
   324 
   325 (* isatool wrappers *)
   326 
   327 fun isatool_document verbose format name tags path result_path =
   328   let
   329     val s = "\"$ISATOOL\" document -c -o '" ^ format ^ "' \
   330       \-n '" ^ name ^ "' -t '" ^ tags ^ "' " ^ File.shell_path path ^
   331       " 2>&1" ^ (if verbose then "" else " >/dev/null");
   332     val doc_path = Path.append result_path (Path.ext format (Path.basic name));
   333   in
   334     conditional verbose (fn () => writeln s);
   335     system s;
   336     conditional (not (File.exists doc_path)) (fn () =>
   337       error ("No document: " ^ quote (show_path doc_path)));
   338     doc_path
   339   end;
   340 
   341 fun isatool_browser graph =
   342   let
   343     val pdf_path = File.tmp_path graph_pdf_path;
   344     val eps_path = File.tmp_path graph_eps_path;
   345     val gr_path = File.tmp_path graph_path;
   346     val s = "browser -o " ^ File.shell_path pdf_path ^ " " ^ File.shell_path gr_path;
   347   in
   348     write_graph graph gr_path;
   349     if File.isatool s <> 0 orelse not (File.exists eps_path) orelse not (File.exists pdf_path)
   350     then error "Failed to prepare dependency graph"
   351     else
   352       let val pdf = File.read pdf_path and eps = File.read eps_path
   353       in File.rm pdf_path; File.rm eps_path; File.rm gr_path; (pdf, eps) end
   354   end;
   355 
   356 
   357 (* finish session -- output all generated text *)
   358 
   359 fun write_tex src name path =
   360   Buffer.write (Path.append path (tex_path name)) src;
   361 
   362 fun write_tex_index tex_index path =
   363   write_tex (Buffer.add Latex.tex_trailer tex_index) doc_indexN path;
   364 
   365 
   366 fun finish () = with_session () (fn {name, info, html_prefix, doc_format, doc_graph,
   367     documents, doc_prefix1, doc_prefix2, path, verbose, readme, ...} =>
   368   let
   369     val {theories, files, tex_index, html_index, graph} = ! browser_info;
   370     val thys = Symtab.dest theories;
   371     val parent_html_prefix = Path.append html_prefix Path.parent;
   372 
   373     fun finish_tex path (a, {tex_source, ...}: theory_info) = write_tex tex_source a path;
   374     fun finish_html (a, {html, ...}: theory_info) =
   375       Buffer.write (Path.append html_prefix (html_path a)) (Buffer.add HTML.end_theory html);
   376 
   377     val opt_graphs =
   378       if doc_graph andalso (is_some doc_prefix1 orelse is_some doc_prefix2) then
   379         SOME (isatool_browser graph)
   380       else NONE;
   381 
   382     fun prepare_sources cp path =
   383      (File.mkdir path;
   384       if cp then File.copy_dir document_path path else ();
   385       File.isatool ("latex -o sty " ^ File.shell_path (Path.append path (Path.basic "root.tex")));
   386       (case opt_graphs of NONE => () | SOME (pdf, eps) =>
   387         (File.write (Path.append path graph_pdf_path) pdf;
   388           File.write (Path.append path graph_eps_path) eps));
   389       write_tex_index tex_index path;
   390       List.app (finish_tex path) thys);
   391   in
   392     conditional info (fn () =>
   393      (File.mkdir (Path.append html_prefix session_path);
   394       Buffer.write (Path.append html_prefix pre_index_path) html_index;
   395       File.write (Path.append html_prefix session_entries_path) "";
   396       create_index html_prefix;
   397       if length path > 1 then update_index parent_html_prefix name else ();
   398       (case readme of NONE => () | SOME path => File.copy path html_prefix);
   399       write_graph graph (Path.append html_prefix graph_path);
   400       File.copy (Path.unpack "~~/lib/browser/GraphBrowser.jar") html_prefix;
   401       List.app (fn (a, txt) => File.write (Path.append html_prefix (Path.basic a)) txt)
   402         (HTML.applet_pages name (Url.File index_path, name));
   403       File.copy (Path.unpack "~~/lib/html/isabelle.css") html_prefix;
   404       List.app finish_html thys;
   405       List.app (uncurry File.write) files;
   406       conditional verbose (fn () =>
   407         std_error ("Browser info at " ^ show_path html_prefix ^ "\n"))));
   408 
   409     (case doc_prefix2 of NONE => () | SOME (cp, path) =>
   410      (prepare_sources cp path;
   411       conditional verbose (fn () => std_error ("Document sources at " ^ show_path path ^ "\n"))));
   412 
   413     (case doc_prefix1 of NONE => () | SOME (path, result_path) =>
   414       documents |> List.app (fn (name, tags) =>
   415        let
   416          val _ = prepare_sources true path;
   417          val doc_path = isatool_document true doc_format name tags path result_path;
   418        in
   419          conditional verbose (fn () => std_error ("Document at " ^ show_path doc_path ^ "\n"))
   420        end));
   421 
   422     browser_info := empty_browser_info;
   423     session_info := NONE
   424   end);
   425 
   426 
   427 (* theory elements *)
   428 
   429 fun init_theory name = with_session () (fn _ => init_theory_info name empty_theory_info);
   430 
   431 fun verbatim_source name mk_text =
   432   with_session () (fn _ => add_html_source name (HTML.verbatim_source (mk_text ())));
   433 
   434 fun old_symbol_source name mk_text =
   435   with_session () (fn _ => add_tex_source name
   436     (Latex.symbol_source (K true, K true) name (mk_text ())));
   437 
   438 fun theory_output name s =
   439   with_session () (fn _ => add_tex_source name (Latex.isabelle_file name s));
   440 
   441 
   442 fun parent_link remote_path curr_session name =
   443   let val {name = _, session, is_local} = get_info (ThyInfo.theory name)
   444   in (if null session then NONE else
   445      SOME (if is_some remote_path andalso not is_local then
   446        Url.append (the remote_path) (Url.File
   447          (Path.append (Path.make session) (html_path name)))
   448      else Url.File (Path.append (mk_rel_path curr_session session)
   449        (html_path name))), name)
   450   end;
   451 
   452 fun begin_theory optpath name raw_parents orig_files thy =
   453     with_session thy (fn {name = sess_name, session, path, html_prefix, remote_path, ...} =>
   454   let
   455     val parents = map (parent_link remote_path path) raw_parents;
   456     val ml_path = ThyLoad.ml_path name;
   457     val files = map (apsnd SOME) orig_files @
   458       (if is_some (ThyLoad.check_file optpath ml_path) then [(ml_path, NONE)] else []);
   459 
   460     fun prep_file (raw_path, loadit) =
   461       (case ThyLoad.check_file optpath raw_path of
   462         SOME (path, _) =>
   463           let
   464             val base = Path.base path;
   465             val base_html = html_ext base;
   466           in
   467             add_file (Path.append html_prefix base_html,
   468               HTML.ml_file (Url.File base) (File.read path));
   469             (SOME (Url.File base_html), Url.File raw_path, loadit)
   470           end
   471       | NONE => (warning ("Browser info: expected to find ML file" ^ quote (Path.pack raw_path));
   472           (NONE, Url.File raw_path, loadit)));
   473 
   474     val files_html = map prep_file files;
   475 
   476     fun prep_html_source (tex_source, html_source, html) =
   477       let
   478         val txt = HTML.begin_theory (Url.File index_path, session)
   479           name parents files_html (Buffer.content html_source)
   480       in (tex_source, Buffer.empty, Buffer.add txt html) end;
   481 
   482     val entry =
   483      {name = name, ID = ID_of path name, dir = sess_name, unfold = true,
   484       path = Path.pack (html_path name),
   485       parents = map (fn s => ID_of (#session (get_info (ThyInfo.theory s))) s) raw_parents};
   486 
   487   in
   488     change_theory_info name prep_html_source;
   489     add_graph_entry entry;
   490     add_html_index (HTML.theory_entry (Url.File (html_path name), name));
   491     add_tex_index (Latex.theory_entry name);
   492     BrowserInfoData.put {name = sess_name, session = path, is_local = is_some remote_path} thy
   493   end);
   494 
   495 
   496 val hooks = ref ([]: (string -> (string * thm list) list -> unit) list);
   497 fun add_hook f = hooks := (f :: ! hooks);
   498 
   499 fun results k xs =
   500  (List.app (fn f => (try (fn () => f k xs) (); ())) (! hooks);
   501   with_session () (fn _ => with_context add_html (HTML.results k xs)));
   502 
   503 fun theorem a th = results "theorem" [(a, [th])];
   504 fun theorems a ths = results "theorems" [(a, ths)];
   505 fun chapter s = with_session () (fn _ => with_context add_html (HTML.chapter s));
   506 fun section s = with_session () (fn _ => with_context add_html (HTML.section s));
   507 fun subsection s = with_session () (fn _ => with_context add_html (HTML.subsection s));
   508 fun subsubsection s = with_session () (fn _ => with_context add_html (HTML.subsubsection s));
   509 
   510 
   511 
   512 (** draft document output **)
   513 
   514 fun drafts doc_format src_paths =
   515   let
   516     fun prep_draft (tex_index, path) =
   517       let
   518         val base = Path.base path;
   519         val name =
   520           (case Path.pack (#1 (Path.split_ext base)) of "" => gensym "DUMMY" | s => s);
   521       in
   522         if File.exists path then
   523           (Buffer.add (Latex.theory_entry name) tex_index, (name, base, File.read path))
   524         else error ("Bad file: " ^ quote (Path.pack path))
   525       end;
   526     val (tex_index, srcs) = foldl_map prep_draft (Buffer.empty, src_paths);
   527 
   528     val doc_path = File.tmp_path document_path;
   529     val result_path = Path.append doc_path Path.parent;
   530     val _ = File.mkdir doc_path;
   531     val root_path = Path.append doc_path (Path.basic "root.tex");
   532     val _ = File.copy (Path.unpack "~~/lib/texinputs/draft.tex") root_path;
   533     val _ = File.isatool ("latex -o sty " ^ File.shell_path root_path);
   534     val _ = File.isatool ("latex -o syms " ^ File.shell_path root_path);
   535 
   536     fun known name =
   537       let val ss = split_lines (File.read (Path.append doc_path (Path.basic name)))
   538       in fn s => s mem_string ss end;
   539     val known_syms = known "syms.lst";
   540     val known_ctrls = known "ctrls.lst";
   541 
   542     val _ = srcs |> List.app (fn (name, base, txt) =>
   543       Symbol.explode txt
   544       |> Latex.symbol_source (known_syms, known_ctrls) (Path.pack base)
   545       |> File.write (Path.append doc_path (tex_path name)));
   546     val _ = write_tex_index tex_index doc_path;
   547   in isatool_document false doc_format documentN "" doc_path result_path end;
   548 
   549 
   550 end;
   551 
   552 structure BasicPresent: BASIC_PRESENT = Present;
   553 open BasicPresent;