From 6cc2fc829105df463765a4ee7da9085617d2e9db Mon Sep 17 00:00:00 2001 From: Alasdair Date: Mon, 18 May 2020 16:16:30 +0100 Subject: Add a header and a default page to the index in coverage reports --- sailcov/main.ml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'sailcov') diff --git a/sailcov/main.ml b/sailcov/main.ml index a861be0c..96c8fdf6 100644 --- a/sailcov/main.ml +++ b/sailcov/main.ml @@ -8,6 +8,7 @@ let opt_all = ref "all_branches" let opt_tab_width = ref 4 let opt_index = ref None +let opt_index_default = ref None type color = { hue: int; @@ -44,7 +45,10 @@ let options = " set the tab width for html output (default: 4)"); ( "--index", Arg.String (fun str -> opt_index := Some str), - " create an index.html page"); + " create an .html page as an index"); + ( "--index-default", + Arg.String (fun str -> opt_index_default := Some str), + " The .sail file that will be displayed by the generated index page by default"); ( "--covered-hue", Arg.Int (fun n -> opt_good_color := { !opt_good_color with hue = clamp_degree n }), " set the hue (between 0 and 360) of the color used for code that is covered (default: 120 (green))"); @@ -260,6 +264,7 @@ let main () = output_string chan (Printf.sprintf "%s" (Filename.remove_extension (Filename.basename file))); output_string chan "\n"; output_string chan "\n"; + output_string chan (Printf.sprintf "

%s

\n" desc); output_string chan "\n"; Array.iter (fun line -> @@ -341,8 +346,16 @@ let main () = (Filename.remove_extension (Filename.basename file)) desc ) !opt_files; output_string chan ""; - - output_string chan "\n"; + + output_string chan ""; + begin match !opt_index_default with + | Some default_file -> + Printf.ksprintf (output_string chan) "" + (Filename.remove_extension (Filename.basename default_file)); + | None -> + output_string chan "" + end; + output_string chan "\n"; output_string chan "\n"; output_string chan ""; close_out chan -- cgit v1.2.3