equal
deleted
inserted
replaced
94 fun display_graph gr = |
94 fun display_graph gr = |
95 let |
95 let |
96 val _ = writeln "Displaying graph ..."; |
96 val _ = writeln "Displaying graph ..."; |
97 val path = File.tmp_path (Path.explode "tmp.graph"); |
97 val path = File.tmp_path (Path.explode "tmp.graph"); |
98 val _ = write_graph gr path; |
98 val _ = write_graph gr path; |
99 val _ = File.isatool ("browser -c " ^ File.shell_path path ^ " &"); |
99 val _ = File.isabelle_tool ("browser -c " ^ File.shell_path path ^ " &"); |
100 in () end; |
100 in () end; |
101 |
101 |
102 |
102 |
103 fun ID_of sess s = space_implode "/" (sess @ [s]); |
103 fun ID_of sess s = space_implode "/" (sess @ [s]); |
104 fun ID_of_thy thy = ID_of (#session (get_info thy)) (Context.theory_name thy); |
104 fun ID_of_thy thy = ID_of (#session (get_info thy)) (Context.theory_name thy); |
319 browser_info := init_browser_info remote_path path thys; |
319 browser_info := init_browser_info remote_path path thys; |
320 add_html_index (0, index_text) |
320 add_html_index (0, index_text) |
321 end); |
321 end); |
322 |
322 |
323 |
323 |
324 (* isatool wrappers *) |
324 (* isabelle tool wrappers *) |
325 |
325 |
326 fun isatool_document verbose format name tags path result_path = |
326 fun isabelle_document verbose format name tags path result_path = |
327 let |
327 let |
328 val s = "\"$ISATOOL\" document -c -o '" ^ format ^ "' \ |
328 val s = "\"$ISATOOL\" document -c -o '" ^ format ^ "' \ |
329 \-n '" ^ name ^ "' -t '" ^ tags ^ "' " ^ File.shell_path path ^ |
329 \-n '" ^ name ^ "' -t '" ^ tags ^ "' " ^ File.shell_path path ^ |
330 " 2>&1" ^ (if verbose then "" else " >/dev/null"); |
330 " 2>&1" ^ (if verbose then "" else " >/dev/null"); |
331 val doc_path = Path.append result_path (Path.ext format (Path.basic name)); |
331 val doc_path = Path.append result_path (Path.ext format (Path.basic name)); |
335 File.exists doc_path orelse |
335 File.exists doc_path orelse |
336 error ("No document: " ^ quote (show_path doc_path)); |
336 error ("No document: " ^ quote (show_path doc_path)); |
337 doc_path |
337 doc_path |
338 end; |
338 end; |
339 |
339 |
340 fun isatool_browser graph = |
340 fun isabelle_browser graph = |
341 let |
341 let |
342 val pdf_path = File.tmp_path graph_pdf_path; |
342 val pdf_path = File.tmp_path graph_pdf_path; |
343 val eps_path = File.tmp_path graph_eps_path; |
343 val eps_path = File.tmp_path graph_eps_path; |
344 val gr_path = File.tmp_path graph_path; |
344 val gr_path = File.tmp_path graph_path; |
345 val s = "browser -o " ^ File.shell_path pdf_path ^ " " ^ File.shell_path gr_path; |
345 val s = "browser -o " ^ File.shell_path pdf_path ^ " " ^ File.shell_path gr_path; |
346 in |
346 in |
347 write_graph graph gr_path; |
347 write_graph graph gr_path; |
348 if File.isatool s <> 0 orelse not (File.exists eps_path) orelse not (File.exists pdf_path) |
348 if File.isabelle_tool s <> 0 orelse not (File.exists eps_path) orelse not (File.exists pdf_path) |
349 then error "Failed to prepare dependency graph" |
349 then error "Failed to prepare dependency graph" |
350 else |
350 else |
351 let val pdf = File.read pdf_path and eps = File.read eps_path |
351 let val pdf = File.read pdf_path and eps = File.read eps_path |
352 in File.rm pdf_path; File.rm eps_path; File.rm gr_path; (pdf, eps) end |
352 in File.rm pdf_path; File.rm eps_path; File.rm gr_path; (pdf, eps) end |
353 end; |
353 end; |
378 File.write_buffer (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 (isabelle_browser sorted_graph) |
384 else NONE; |
384 else NONE; |
385 |
385 |
386 fun prepare_sources cp path = |
386 fun prepare_sources cp path = |
387 (File.mkdir path; |
387 (File.mkdir path; |
388 if cp then File.copy_dir document_path path else (); |
388 if cp then File.copy_dir document_path path else (); |
389 File.isatool ("latex -o sty " ^ File.shell_path (Path.append path (Path.basic "root.tex"))); |
389 File.isabelle_tool ("latex -o sty " ^ File.shell_path (Path.append path (Path.basic "root.tex"))); |
390 (case opt_graphs of NONE => () | SOME (pdf, eps) => |
390 (case opt_graphs of NONE => () | SOME (pdf, eps) => |
391 (File.write (Path.append path graph_pdf_path) pdf; |
391 (File.write (Path.append path graph_pdf_path) pdf; |
392 File.write (Path.append path graph_eps_path) eps)); |
392 File.write (Path.append path graph_eps_path) eps)); |
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); |
416 |
416 |
417 (case doc_prefix1 of NONE => () | SOME (path, result_path) => |
417 (case doc_prefix1 of NONE => () | SOME (path, result_path) => |
418 documents |> List.app (fn (name, tags) => |
418 documents |> List.app (fn (name, tags) => |
419 let |
419 let |
420 val _ = prepare_sources true path; |
420 val _ = prepare_sources true path; |
421 val doc_path = isatool_document true doc_format name tags path result_path; |
421 val doc_path = isabelle_document true doc_format name tags path result_path; |
422 in |
422 in |
423 if verbose then Output.std_error ("Document at " ^ show_path doc_path ^ "\n") else () |
423 if verbose then Output.std_error ("Document at " ^ show_path doc_path ^ "\n") else () |
424 end)); |
424 end)); |
425 |
425 |
426 browser_info := empty_browser_info; |
426 browser_info := empty_browser_info; |
512 val doc_path = File.tmp_path document_path; |
512 val doc_path = File.tmp_path document_path; |
513 val result_path = Path.append doc_path Path.parent; |
513 val result_path = Path.append doc_path Path.parent; |
514 val _ = File.mkdir doc_path; |
514 val _ = File.mkdir doc_path; |
515 val root_path = Path.append doc_path (Path.basic "root.tex"); |
515 val root_path = Path.append doc_path (Path.basic "root.tex"); |
516 val _ = File.copy (Path.explode "~~/lib/texinputs/draft.tex") root_path; |
516 val _ = File.copy (Path.explode "~~/lib/texinputs/draft.tex") root_path; |
517 val _ = File.isatool ("latex -o sty " ^ File.shell_path root_path); |
517 val _ = File.isabelle_tool ("latex -o sty " ^ File.shell_path root_path); |
518 val _ = File.isatool ("latex -o syms " ^ File.shell_path root_path); |
518 val _ = File.isabelle_tool ("latex -o syms " ^ File.shell_path root_path); |
519 |
519 |
520 fun known name = |
520 fun known name = |
521 let val ss = split_lines (File.read (Path.append doc_path (Path.basic name))) |
521 let val ss = split_lines (File.read (Path.append doc_path (Path.basic name))) |
522 in member (op =) ss end; |
522 in member (op =) ss end; |
523 val known_syms = known "syms.lst"; |
523 val known_syms = known "syms.lst"; |
526 val _ = srcs |> List.app (fn (name, base, txt) => |
526 val _ = srcs |> List.app (fn (name, base, txt) => |
527 Symbol.explode txt |
527 Symbol.explode txt |
528 |> Latex.symbol_source (known_syms, known_ctrls) (Path.implode base) |
528 |> Latex.symbol_source (known_syms, known_ctrls) (Path.implode base) |
529 |> File.write (Path.append doc_path (tex_path name))); |
529 |> File.write (Path.append doc_path (tex_path name))); |
530 val _ = write_tex_index tex_index doc_path; |
530 val _ = write_tex_index tex_index doc_path; |
531 in isatool_document false doc_format documentN "" doc_path result_path end; |
531 in isabelle_document false doc_format documentN "" doc_path result_path end; |
532 |
532 |
533 |
533 |
534 end; |
534 end; |
535 |
535 |
536 structure BasicPresent: BASIC_PRESENT = Present; |
536 structure BasicPresent: BASIC_PRESENT = Present; |