src/Pure/Thy/present.ML
changeset 28027 051d5ccbafc5
parent 27862 8f727f7c8c1d
child 28375 c879d88d038a
equal deleted inserted replaced
28026:dad9a2f178ac 28027:051d5ccbafc5
   357 
   357 
   358 fun sorted_index index = map snd (sort (int_ord o pairself fst) (rev index));
   358 fun sorted_index index = map snd (sort (int_ord o pairself fst) (rev index));
   359 fun index_buffer index = Buffer.add (implode (sorted_index index)) Buffer.empty;
   359 fun index_buffer index = Buffer.add (implode (sorted_index index)) Buffer.empty;
   360 
   360 
   361 fun write_tex src name path =
   361 fun write_tex src name path =
   362   Buffer.write (Path.append path (tex_path name)) src;
   362   File.write_buffer (Path.append path (tex_path name)) src;
   363 
   363 
   364 fun write_tex_index tex_index path =
   364 fun write_tex_index tex_index path =
   365   write_tex (index_buffer tex_index |> Buffer.add Latex.tex_trailer) doc_indexN path;
   365   write_tex (index_buffer tex_index |> Buffer.add Latex.tex_trailer) doc_indexN path;
   366 
   366 
   367 
   367 
   373     val thys = Symtab.dest theories;
   373     val thys = Symtab.dest theories;
   374     val parent_html_prefix = Path.append html_prefix Path.parent;
   374     val parent_html_prefix = Path.append html_prefix Path.parent;
   375 
   375 
   376     fun finish_tex path (a, {tex_source, ...}: theory_info) = write_tex tex_source a path;
   376     fun finish_tex path (a, {tex_source, ...}: theory_info) = write_tex tex_source a path;
   377     fun finish_html (a, {html, ...}: theory_info) =
   377     fun finish_html (a, {html, ...}: theory_info) =
   378       Buffer.write (Path.append html_prefix (html_path a)) (Buffer.add HTML.end_document html);
   378       File.write_buffer (Path.append html_prefix (html_path a)) (Buffer.add HTML.end_document html);
   379 
   379 
   380     val sorted_graph = sorted_index graph;
   380     val sorted_graph = sorted_index graph;
   381     val opt_graphs =
   381     val opt_graphs =
   382       if doc_graph andalso (is_some doc_prefix1 orelse is_some doc_prefix2) then
   382       if doc_graph andalso (is_some doc_prefix1 orelse is_some doc_prefix2) then
   383         SOME (isatool_browser sorted_graph)
   383         SOME (isatool_browser sorted_graph)
   393       write_tex_index tex_index path;
   393       write_tex_index tex_index path;
   394       List.app (finish_tex path) thys);
   394       List.app (finish_tex path) thys);
   395   in
   395   in
   396     if info then
   396     if info then
   397      (File.mkdir (Path.append html_prefix session_path);
   397      (File.mkdir (Path.append html_prefix session_path);
   398       Buffer.write (Path.append html_prefix pre_index_path) (index_buffer html_index);
   398       File.write_buffer (Path.append html_prefix pre_index_path) (index_buffer html_index);
   399       File.write (Path.append html_prefix session_entries_path) "";
   399       File.write (Path.append html_prefix session_entries_path) "";
   400       create_index html_prefix;
   400       create_index html_prefix;
   401       if length path > 1 then update_index parent_html_prefix name else ();
   401       if length path > 1 then update_index parent_html_prefix name else ();
   402       (case readme of NONE => () | SOME path => File.copy path html_prefix);
   402       (case readme of NONE => () | SOME path => File.copy path html_prefix);
   403       write_graph sorted_graph (Path.append html_prefix graph_path);
   403       write_graph sorted_graph (Path.append html_prefix graph_path);