why3session_html.ml 18.6 KB
Newer Older
Andrei Paskevich's avatar
Andrei Paskevich committed
1 2 3
(********************************************************************)
(*                                                                  *)
(*  The Why3 Verification Platform   /   The Why3 Development Team  *)
4
(*  Copyright 2010-2015   --   INRIA - CNRS - Paris-Sud University  *)
Andrei Paskevich's avatar
Andrei Paskevich committed
5 6 7 8
(*                                                                  *)
(*  This software is distributed under the terms of the GNU Lesser  *)
(*  General Public License version 2.1, with the special exception  *)
(*  on linking described in file LICENSE.                           *)
9
(*                                                                  *)
Andrei Paskevich's avatar
Andrei Paskevich committed
10
(********************************************************************)
11

12
open Format
13
open Why3
14
open Why3session_lib
15

16
module Hprover = Whyconf.Hprover
17 18
module S = Session

19
let output_dir = ref ""
20
let opt_context = ref false
21

22
type style = SimpleTree | Jstree | Table
23

24 25
let opt_style = ref Table
let default_style = "table"
26 27

let set_opt_style = function
28
  | "simple" -> opt_style := SimpleTree
29
  | "jstree" -> opt_style := Jstree
30
  | "table" -> opt_style := Table
Andrei Paskevich's avatar
Andrei Paskevich committed
31
  | _ ->
32 33 34
    eprintf "Unknown html style, ignored@."

let () = set_opt_style default_style
35

36 37 38 39 40 41 42 43 44
let opt_pp = ref []

let set_opt_pp_in,set_opt_pp_cmd,set_opt_pp_out =
  let suf = ref "" in
  let cmd = ref "" in
  (fun s -> suf := s),
  (fun s -> cmd := s),
  (fun s -> opt_pp := (!suf,(!cmd,s))::!opt_pp)

45
let spec =
46 47
  ("-o",
   Arg.Set_string output_dir,
MARCHE Claude's avatar
MARCHE Claude committed
48
   "<path> output directory ('-' for stdout)") ::
49
  ("--context", Arg.Set opt_context,
50
   " add context around the generated HTML code") ::
51
  ("--style", Arg.Symbol (["simpletree";"jstree";"table"], set_opt_style),
MARCHE Claude's avatar
MARCHE Claude committed
52
   " style to use, defaults to '" ^ default_style ^ "'."
53
) ::
54
  ("--add_pp", Arg.Tuple
55 56 57
    [Arg.String set_opt_pp_in;
     Arg.String set_opt_pp_cmd;
     Arg.String set_opt_pp_out],
58
  "<suffix> <cmd> <out_suffix> declare a pretty-printer for edited proofs") ::
59 60
  ("--coqdoc",
   Arg.Unit (fun ()->
61
    opt_pp := (".v",("coqdoc --no-index --html -o %o %i",".html"))::!opt_pp),
MARCHE Claude's avatar
MARCHE Claude committed
62
  " use coqdoc to print Coq proofs") ::
63
  common_options
64

François Bobot's avatar
François Bobot committed
65
open Session
66

67
type context =
68
    (string ->
69
     (formatter -> unit session -> unit) -> unit session
70 71
     -> unit, formatter, unit) format

72 73
let run_file (context : context) print_session fname =
  let project_dir = Session.get_project_dir fname in
74
  let session,_use_shapes = Session.read_session project_dir in
75 76 77 78 79 80
  let output_dir =
    if !output_dir = "" then project_dir else !output_dir
  in
  let basename = Filename.basename project_dir in
  let cout =
    if output_dir = "-" then stdout else
81
      open_out (Filename.concat output_dir ("why3session.html"))
82
  in
83 84 85 86 87 88 89 90
  let fmt = formatter_of_out_channel cout in
  if !opt_context
  then fprintf fmt context basename (print_session basename) session
  else print_session basename fmt session;
  pp_print_flush fmt ();
  if output_dir <> "-" then close_out cout


91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
module Table =
struct


  let rec transf_depth tr =
    List.fold_left
      (fun depth g -> max depth (goal_depth g)) 0 tr.S.transf_goals
  and goal_depth g =
    S.PHstr.fold
      (fun _st tr depth -> max depth (1 + transf_depth tr))
      g.S.goal_transformations 1

  let theory_depth t =
    List.fold_left
      (fun depth g -> max depth (goal_depth g)) 0 t.S.theory_goals

107
  let provers_stats provers theory =
108
    S.theory_iter_proof_attempt (fun a ->
109
      Hprover.replace provers a.S.proof_prover a.S.proof_prover) theory
110 111 112 113

  let print_prover = Whyconf.print_prover


Andrei Paskevich's avatar
Andrei Paskevich committed
114 115 116
  let color_of_status ?(dark=false) fmt b =
    fprintf fmt "%s" (if b then
        if dark then "008000" else "C0FFC0"
117 118 119 120 121 122 123 124 125
      else "FF0000")

let print_results fmt provers proofs =
  List.iter (fun p ->
    fprintf fmt "<td bgcolor=\"#";
    begin
      try
        let pr = S.PHprover.find proofs p in
        let s = pr.S.proof_state in
126 127
        begin
          match s with
128 129 130 131 132 133 134 135
	  | S.Done res ->
	    begin
	      match res.Call_provers.pr_answer with
		| Call_provers.Valid ->
                  fprintf fmt "C0FFC0\">%.2f" res.Call_provers.pr_time
		| Call_provers.Invalid ->
                  fprintf fmt "FF0000\">Invalid"
		| Call_provers.Timeout ->
MARCHE Claude's avatar
MARCHE Claude committed
136
                  fprintf fmt "FF8000\">Timeout (%ds)"
137
                    (Call_provers.get_time pr.S.proof_limit)
138
		| Call_provers.OutOfMemory ->
MARCHE Claude's avatar
MARCHE Claude committed
139
                  fprintf fmt "FF8000\">Out Of Memory (%dM)"
140
                    (Call_provers.get_time pr.S.proof_limit)
141 142
		| Call_provers.StepLimitExceeded ->
                  fprintf fmt "FF8000\">Step limit exceeded"
143
		| Call_provers.Unknown _ ->
MARCHE Claude's avatar
MARCHE Claude committed
144
                  fprintf fmt "FF8000\">%.2f" res.Call_provers.pr_time
145
		| Call_provers.Failure _ ->
Andrei Paskevich's avatar
Andrei Paskevich committed
146 147 148
                  fprintf fmt "FF8000\">Failure"
		| Call_provers.HighFailure ->
                  fprintf fmt "FF8000\">High Failure"
149
	    end
150
	  | S.InternalFailure _ -> fprintf fmt "E0E0E0\">Internal Failure"
151 152 153 154
          | S.Interrupted -> fprintf fmt "E0E0E0\">Not yet run"
          | S.Unedited -> fprintf fmt "E0E0E0\">Not yet edited"
          | S.Scheduled | S.Running
          | S.JustEdited -> assert false
155
        end;
156
        if pr.S.proof_obsolete then fprintf fmt " (obsolete)"
MARCHE Claude's avatar
MARCHE Claude committed
157
      with Not_found -> fprintf fmt "E0E0E0\">---"
158 159 160
    end;
    fprintf fmt "</td>") provers

MARCHE Claude's avatar
MARCHE Claude committed
161 162
let rec num_lines acc tr =
  List.fold_left
Andrei Paskevich's avatar
Andrei Paskevich committed
163 164
    (fun acc g -> 1 +
      PHstr.fold (fun _ tr acc -> 1 + num_lines acc tr)
MARCHE Claude's avatar
MARCHE Claude committed
165 166 167
      g.goal_transformations acc)
    acc tr.transf_goals

168 169
  let rec print_transf fmt depth max_depth provers tr =
    fprintf fmt "<tr>";
170
    for _i=1 to 0 (* depth-1 *) do fprintf fmt "<td></td>" done;
Andrei Paskevich's avatar
Andrei Paskevich committed
171
    fprintf fmt "<td bgcolor=\"#%a\" colspan=\"%d\">"
172
      (color_of_status ~dark:false) (Opt.inhabited tr.S.transf_verified)
MARCHE Claude's avatar
MARCHE Claude committed
173 174 175
      (max_depth - depth + 1);
    (* for i=1 to depth-1 do fprintf fmt "&nbsp;&nbsp;&nbsp;&nbsp;" done; *)
    fprintf fmt "%s</td>" tr.transf_name ;
176
    for _i=1 (* depth *) to (*max_depth - 1 + *) List.length provers do
177 178 179
      fprintf fmt "<td bgcolor=\"#E0E0E0\"></td>"
    done;
    fprintf fmt "</tr>@\n";
MARCHE Claude's avatar
MARCHE Claude committed
180 181 182 183 184 185 186 187 188 189 190
    fprintf fmt "<td rowspan=\"%d\">&nbsp;&nbsp;</td>" (num_lines 0 tr);
    let (_:bool) = List.fold_left
      (fun is_first g ->
        print_goal fmt is_first (depth+1) max_depth provers g;
        false)
      true tr.transf_goals
    in ()

  and print_goal fmt is_first depth max_depth provers g =
    if not is_first then fprintf fmt "<tr>";
    (* for i=1 to 0 (\* depth-1 *\) do fprintf fmt "<td></td>" done; *)
Andrei Paskevich's avatar
Andrei Paskevich committed
191
    fprintf fmt "<td bgcolor=\"#%a\" colspan=\"%d\">"
192 193
      (color_of_status ~dark:false) (Opt.inhabited g.S.goal_verified)
      (max_depth - depth + 1);
MARCHE Claude's avatar
MARCHE Claude committed
194
    (* for i=1 to depth-1 do fprintf fmt "&nbsp;&nbsp;&nbsp;&nbsp;" done; *)
195 196 197 198 199 200 201 202
    fprintf fmt "%s</td>" (S.goal_expl g);
(*    for i=depth to max_depth-1 do fprintf fmt "<td></td>" done; *)
    print_results fmt provers g.goal_external_proofs;
    fprintf fmt "</tr>@\n";
    PHstr.iter
      (fun _ tr -> print_transf fmt depth max_depth provers tr)
      g.goal_transformations

203
  let print_theory fn fmt th =
204 205
    let depth = theory_depth th in
    if depth > 0 then
206
    let provers = Hprover.create 9 in
207 208
    provers_stats provers th;
    let provers =
209
      Hprover.fold (fun _ pr acc -> pr :: acc) provers []
210 211
    in
    let provers = List.sort Whyconf.Prover.compare provers in
212 213 214 215 216 217 218
    let name =
      try
        let (l,t,_) = Theory.restore_path th.theory_name in
        String.concat "." ([fn]@l@[t])
      with Not_found -> fn ^ "." ^ th.theory_name.Ident.id_string
    in
    fprintf fmt "<h2><font color=\"#%a\">Theory \"%s\": "
219
      (color_of_status ~dark:true) (Opt.inhabited th.S.theory_verified)
220 221 222 223 224 225
      name;
    begin match th.S.theory_verified with
    | Some t -> fprintf fmt "fully verified in %.02f s" t
    | None -> fprintf fmt "not fully verified"
    end;
    fprintf fmt "</font></h2>@\n";
MARCHE Claude's avatar
MARCHE Claude committed
226

227
    fprintf fmt "<table border=\"1\"><tr><td colspan=\"%d\">Obligations</td>" depth;
MARCHE Claude's avatar
MARCHE Claude committed
228
    (* fprintf fmt "<table border=\"1\"><tr><td>Obligations</td>"; *)
229 230 231 232
    List.iter
      (fun pr -> fprintf fmt "<td text-rotation=\"90\">%a</td>" print_prover pr)
      provers;
    fprintf fmt "</td></tr>@\n";
MARCHE Claude's avatar
MARCHE Claude committed
233
    List.iter (print_goal fmt true 1 depth provers) th.theory_goals;
234 235 236 237
    fprintf fmt "</table>@\n"

  let print_file fmt f =
    (* fprintf fmt "<h1>File %s</h1>@\n" f.file_name; *)
238 239
    let fn = Filename.basename f.file_name in
    let fn = Filename.chop_extension fn in
240
    fprintf fmt "%a"
241
      (Pp.print_list Pp.newline (print_theory fn)) f.file_theories
242 243 244 245 246 247 248 249

  let print_session name fmt s =
    fprintf fmt "<h1>Why3 Proof Results for Project \"%s\"</h1>@\n" name;
    fprintf fmt "%a"
      (Pp.print_iter2 PHstr.iter Pp.newline Pp.nothing Pp.nothing
         print_file) s.session_files


250 251 252 253 254 255 256 257 258 259 260
  let context : context = "<!DOCTYPE html\
PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\
<html xmlns=\"http://www.w3.org/1999/xhtml\">\
<head>\
<title>Why3 session of %s</title>\
</head>\
<body>\
%a\
</body>\
</html>\
261 262 263 264 265 266 267 268
"

  let run_one = run_file context print_session

end



269 270 271
module Simple =
struct

272
  let print_prover = Whyconf.print_prover
273 274

  let print_proof_status fmt = function
275 276 277 278
    | Interrupted -> fprintf fmt "Not yet run"
    | Unedited -> fprintf fmt "Not yet edited"
    | JustEdited | Scheduled | Running -> assert false
    | Done pr -> fprintf fmt "Done: %a" Call_provers.print_prover_result pr
279
    | InternalFailure exn ->
280
      fprintf fmt "Failure: %a"Exn_printer.exn_printer exn
281

282 283
  let print_proof_attempt fmt pa =
    fprintf fmt "<li>%a : %a</li>"
François Bobot's avatar
François Bobot committed
284
      print_prover pa.proof_prover
285 286 287 288 289
      print_proof_status pa.proof_state

  let rec print_transf fmt tr =
    fprintf fmt "<li>%s : <ul>%a</ul></li>"
      tr.transf_name
François Bobot's avatar
François Bobot committed
290
      (Pp.print_list Pp.newline print_goal) tr.transf_goals
291 292 293

  and print_goal fmt g =
    fprintf fmt "<li>%s : <ul>%a%a</ul></li>"
François Bobot's avatar
François Bobot committed
294 295
      g.goal_name.Ident.id_string
      (Pp.print_iter2 PHprover.iter Pp.newline Pp.nothing
296
         Pp.nothing print_proof_attempt)
François Bobot's avatar
François Bobot committed
297 298
      g.goal_external_proofs
      (Pp.print_iter2 PHstr.iter Pp.newline Pp.nothing
299
         Pp.nothing print_transf)
François Bobot's avatar
François Bobot committed
300
      g.goal_transformations
301 302 303

  let print_theory fmt th =
    fprintf fmt "<li>%s : <ul>%a</ul></li>"
François Bobot's avatar
François Bobot committed
304 305
      th.theory_name.Ident.id_string
      (Pp.print_list Pp.newline print_goal) th.theory_goals
306 307 308 309

  let print_file fmt f =
    fprintf fmt "<li>%s : <ul>%a</ul></li>"
      f.file_name
François Bobot's avatar
François Bobot committed
310
      (Pp.print_list Pp.newline print_theory) f.file_theories
311 312 313

  let print_session _name fmt s =
    fprintf fmt "<ul>%a</ul>"
François Bobot's avatar
François Bobot committed
314 315
      (Pp.print_iter2 PHstr.iter Pp.newline Pp.nothing Pp.nothing
         print_file) s.session_files
316 317


318 319 320 321 322 323 324 325 326 327 328
  let context : context = "<!DOCTYPE html\
PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\
<html xmlns=\"http://www.w3.org/1999/xhtml\">\
<head>\
<title>Why3 session of %s</title>\
</head>\
<body>\
%a\
</body>\
</html>\
329
"
330

331
  let run_one = run_file context print_session
332

333
end
334

335

336 337 338
module Jstree =
struct

339 340 341 342 343
  let print_verified fmt b =
    if b
    then fprintf fmt "class='verified'"
    else fprintf fmt "class='notverified'"

344
  let print_prover = Whyconf.print_prover
345 346

  let print_proof_status fmt = function
347 348 349 350
    | Interrupted -> fprintf fmt "<span class='notverified'>Not yet run</span>"
    | Unedited -> fprintf fmt "<span class='notverified'>Not yet edited</span>"
    | JustEdited | Scheduled | Running -> assert false
    | Done pr -> fprintf fmt "<span class='verified'>Done: %a</span>"
351
      Call_provers.print_prover_result pr
352
    | InternalFailure exn ->
353
      fprintf fmt "<span class='notverified'>Failure: %a</span>"
354
        Exn_printer.exn_printer exn
355

356 357 358 359 360 361 362 363 364 365 366 367 368 369
  let cmd_regexp = Str.regexp "%\\(.\\)"

  let pp_run input cmd output =
    let replace s = match Str.matched_group 1 s with
      | "%" -> "%"
      | "i" -> input
      | "o" -> output
      | _ -> failwith "unknown format specifier, use %%i, %%o"
    in
    let cmd = Str.global_substitute cmd_regexp replace cmd in
    let c = Sys.command cmd in
    if c <> 0 then
      eprintf "[Error] '%s' stopped abnormaly : code %i" cmd c

370

371
  let find_pp edited =
372
    let edited_dst = Filename.concat !output_dir "edited" in
373 374 375
    let basename = Filename.basename edited in
    try
      let suff,(cmd,suff_out) =
376
        List.find (fun (s,_) -> Strings.ends_with basename s) !opt_pp in
377 378 379 380 381 382 383 384
      let base =
        String.sub basename 0 (String.length basename - String.length suff) in
      let base_dst = (base^suff_out) in
      if !opt_context then
        pp_run edited cmd (Filename.concat edited_dst base_dst);
      base_dst
    with Not_found ->
      eprintf "Default %s@." basename;
385
      (* default printer *)
386 387 388 389 390 391
      let base = try Filename.chop_extension basename with _ -> basename in
      let base_dst = base^".txt" in
      if !opt_context then
        Sysutil.copy_file edited (Filename.concat edited_dst base_dst);
      base_dst

392 393
let print_session name fmt session =

394
  let print_proof_attempt fmt pa =
395
    match get_edited_as_abs session pa with
396 397
      | None ->
        fprintf fmt "@[<hov><li rel='prover' ><a href='#'>%a : %a</a></li>@]"
François Bobot's avatar
François Bobot committed
398
          print_prover pa.proof_prover
399 400 401 402 403 404
          print_proof_status pa.proof_state
      | Some f ->
        let output = find_pp f in
        fprintf fmt "@[<hov><li rel='prover' ><a href='#' \
onclick=\"showedited('%s'); return false;\">%a : %a</a></li>@]"
          output
François Bobot's avatar
François Bobot committed
405
          print_prover pa.proof_prover
406
          print_proof_status pa.proof_state in
407 408 409

  let rec print_transf fmt tr =
    fprintf fmt
410 411
      "@[<hov><li rel='transf'><a href='#'>\
<span %a>%s</span></a>@,<ul>%a</ul></li>@]"
412
      print_verified (Opt.inhabited tr.transf_verified)
413
      tr.transf_name
François Bobot's avatar
François Bobot committed
414
      (Pp.print_list Pp.newline print_goal) tr.transf_goals
415 416 417

  and print_goal fmt g =
    fprintf fmt
418 419
      "@[<hov><li rel='goal'><a href='#'>\
<span %a>%s</a></a>@,<ul>%a%a</ul></li>@]"
420
      print_verified (Opt.inhabited g.goal_verified)
François Bobot's avatar
François Bobot committed
421 422
      g.goal_name.Ident.id_string
      (Pp.print_iter2 PHprover.iter Pp.newline Pp.nothing
423
         Pp.nothing print_proof_attempt)
François Bobot's avatar
François Bobot committed
424 425
      g.goal_external_proofs
      (Pp.print_iter2 PHstr.iter Pp.newline Pp.nothing
426
         Pp.nothing print_transf)
427
      g.goal_transformations in
428 429

  let print_theory fmt th =
430 431 432 433 434 435
    let name =
      try
        let (l,t,_) = Theory.restore_path th.theory_name in
        String.concat "." (l@[t])
      with Not_found -> th.theory_name.Ident.id_string
    in
436
    fprintf fmt
437 438
      "@[<hov><li rel='theory'><a href='#'>\
<span %a>%s</span></a>@,<ul>%a</ul></li>@]"
439
      print_verified (Opt.inhabited th.theory_verified)
440
      name
441
      (Pp.print_list Pp.newline print_goal) th.theory_goals in
442 443

  let print_file fmt f =
444 445 446
    fprintf fmt
      "@[<hov><li rel='file'><a href='#'>\
<span %a>%s</span></a>@,<ul>%a</ul></li>@]"
447
      print_verified (Opt.inhabited f.file_verified)
448
      f.file_name
449
      (Pp.print_list Pp.newline print_theory) f.file_theories in
450

451
  let print_session_aux fmt name =
452 453
    fprintf fmt "@[<hov><ul><a href='#'>%s</a>@,%a</ul>@]"
      name
François Bobot's avatar
François Bobot committed
454
      (Pp.print_iter2 PHstr.iter Pp.newline Pp.nothing Pp.nothing print_file)
455
      session.session_files in
456 457

    fprintf fmt
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
      "<a href='#' onclick=\"$('#%s_session').jstree('open_all');\">\
expand all\
</a> <a href='#' onclick=\"$('#%s_session').jstree('close_all');\">\
close all\
</a>\
<div id=\"%s_session\" class=\"session\">\
%a\
</div>\
<script type=\"text/javascript\" class=\"source\">\
$(function () {\
  $(\"#%s_session\").jstree({\
      \"types\" : {\
	   \"types\" : {\
	   \"file\" : {\
		\"icon\" : { \"image\" : \"images/folder16.png\"},\
		      },\
	   \"theory\" : {\
		\"icon\" : { \"image\" : \"images/folder16.png\"},\
		      },\
	   \"goal\" : {\
		\"icon\" : { \"image\" : \"images/file16.png\"},\
		      },\
	   \"prover\" : {\
		\"icon\" : { \"image\" : \"images/wizard16.png\"},\
		      },\
	   \"transf\" : {\
		\"icon\" : { \"image\" : \"images/configure16.png\"},\
		      },\
                        }\
                },\
      \"plugins\" : [\"themes\",\"html_data\",\"types\"]\
        });\
});\
</script>\
492
"
493
  name name name print_session_aux name name
494 495


496 497 498 499 500 501 502 503 504 505
  let context : context = "<!DOCTYPE html\
PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\
<html xmlns=\"http://www.w3.org/1999/xhtml\">\
<head>\
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\
    <title>Why3 session of %s</title>\
    <link rel=\"stylesheet\" type=\"text/css\"\
     href=\"javascript/session.css\" />\
    <script type=\"text/javascript\" src=\"javascript/jquery.js\"></script>\
506
    <script type=\"text/javascript\" src=\"javascript/jquery.jstree.js\">\
507
</script>\
508
    <script type=\"text/javascript\" src=\"javascript/session.js\">\
509 510 511 512 513 514 515 516 517 518 519 520 521 522
</script>\
</head>\
<body>\
%a\
<iframe src=\"\"  id='edited'>\
<p>Your browser does not support iframes.</p>\
</iframe>\
<script type=\"text/javascript\" class=\"source\">\
$(function () {\
  $('#edited').hide()\
})\
</script>\
</body>\
</html>\
523 524
"

525
  let run_files config =
526
    let edited_dst = Filename.concat !output_dir "edited" in
527 528
    if !opt_context then
      if not (Sys.file_exists edited_dst) then Unix.mkdir edited_dst 0o755;
529
    iter_files (run_file context print_session);
530
    if !opt_context then
531
      let data_dir = Whyconf.datadir (Whyconf.get_main config) in
532
      (* copy images *)
533
      let img_dir_src = Filename.concat data_dir "images" in
534
      let img_dir_src = Filename.concat img_dir_src "boomy" in
535
      let img_dir_dst = Filename.concat !output_dir "images" in
536 537 538 539 540 541
      if not (Sys.file_exists img_dir_dst) then Unix.mkdir img_dir_dst 0o755;
      List.iter (fun img_name ->
        let from = Filename.concat img_dir_src img_name in
        let to_  = Filename.concat img_dir_dst img_name in
        Sysutil.copy_file from to_)
        ["folder16.png";"file16.png";"wizard16.png";"configure16.png"];
542
      (* copy javascript *)
543
      let js_dir_src = Filename.concat data_dir "javascript" in
544
      let js_dir_dst = Filename.concat !output_dir "javascript" in
545 546 547 548 549
      Sysutil.copy_dir js_dir_src js_dir_dst

end


550 551

let run () =
552
  let _,config,should_exit1 = read_env_spec () in
553
  if should_exit1 then exit 1;
554 555 556
  match !opt_style with
    | Table -> iter_files Table.run_one
    | SimpleTree -> iter_files Simple.run_one
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572
    | Jstree ->
      if !output_dir = "-" then begin
        Format.eprintf "Option \"-o -\" is not compatible with \"--style jstree\".@.";
        exit 1
      end;
      if !output_dir = "" then begin
        let first = ref true in
        iter_files (fun fname ->
          if not !first then begin
            Format.eprintf "Option \"-o -\" is mandatory when \"--style jstree\" is used for several files at once.@.";
            exit 1
          end;
          output_dir := Session.get_project_dir fname;
          first := false);
      end;
      Jstree.run_files config
573 574 575 576


let cmd =
  { cmd_spec = spec;
577
    cmd_desc = "output session in HTML format";
578 579 580
    cmd_name = "html";
    cmd_run  = run;
  }
581 582 583 584 585 586 587


(*
Local Variables:
compile-command: "unset LANG; make -C ../.. bin/why3session.byte"
End:
*)