\n" ];
- List.iter
- (fun (in_file, out_file, stats) ->
- let a, b = ReportStat.summarize stats in
- let x = if b = 0 then 100 else (100 * a) / b in
- let y = 100 - x in
- output_strings
- [ "
\n";
- "
\n";
- "
\n";
- "
\n";
- "
\n";
- "
\n";
- "
";
- (if b = 0 then "-" else string_of_int x);
- "%
" ]
+ []
+ channel;
+ List.iter
+ (fun (in_file, out_file, stats) ->
+ let a, b = ReportStat.summarize stats in
+ let x = if b = 0 then 100 else (100 * a) / b in
+ let y = 100 - x in
+ output_strings
+ [ "
" ;
+ " " ;
+ "" ]
+ [ "html_footer", html_footer ]
+ out_channel;
+ with e ->
+ close_in_noerr in_channel;
+ close_out_noerr out_channel;
+ raise e);
+ close_in_noerr in_channel;
+ close_out_noerr out_channel;
+ stats
+
+let output verbose dir tab_size data =
+ let files = Hashtbl.fold
+ (fun in_file visited acc ->
+ let l = List.length acc in
+ let basename = Printf.sprintf "file%04d.html" l in
+ let out_file = Filename.concat dir basename in
+ let stats = output_html verbose tab_size in_file out_file visited in
+ (in_file, basename, stats) :: acc)
+ data
+ [] in
+ output_html_index verbose (Filename.concat dir "index.html") (List.sort compare files);
+ output_css (Filename.concat dir "style.css")
addfile ./src/reportHTML.mli
hunk ./src/reportHTML.mli 1
+(*
+ * This file is part of Bisect.
+ * Copyright (C) 2008-2009 Xavier Clerc.
+ *
+ * Bisect is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Bisect is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *)
+
+(** This module defines the output to HTML. *)
+
+
+val output : (string -> unit) -> string -> int -> (string, int array) Hashtbl.t -> unit
+(** [output verbose dir tab_size data] writes all the HTML files for [data]
+ in the directory [dir]. [verbose] is used for verbose output, and
+ [tab_size] is the number of space character to use as a replacement for
+ tabulations. *)
hunk ./src/reportUtils.ml 19
+let version = "1.0-beta"
+
+let url = "http://bisect.x9c.fr"
+
hunk ./src/reportUtils.ml 50
+let split p l =
+ let rec spl acc l =
+ match l with
+ | hd :: tl ->
+ if (p hd) then
+ spl (hd :: acc) tl
+ else
+ (List.rev acc), l
+ | [] -> (List.rev acc), [] in
+ spl [] l
+
+let open_both in_file out_file =
+ let in_channel = open_in in_file in
+ try
+ let out_channel = open_out out_file in
+ (in_channel, out_channel)
+ with e ->
+ close_in_noerr in_channel;
+ raise e
+
+let output_strings lines mapping ch =
+ let get x =
+ try List.assoc x mapping with Not_found -> "" in
+ List.iter
+ (fun l ->
+ let buff = Buffer.create 64 in
+ Buffer.add_substitute buff get l;
+ Buffer.add_char buff '\n';
+ output_string ch (Buffer.contents buff))
+ lines
+
+let escape_line tab_size line offset points =
+ let buff = Buffer.create (String.length line) in
+ let ofs = ref offset in
+ let pts = ref points in
+ let marker n =
+ Buffer.add_string buff "(*[";
+ Buffer.add_string buff (string_of_int n);
+ Buffer.add_string buff "]*)" in
+ let marker_if_any () =
+ match !pts with
+ | (o, n) :: tl when o = !ofs ->
+ marker n;
+ pts := tl
+ | _ -> () in
+ String.iter
+ (fun ch ->
+ marker_if_any ();
+ (match ch with
+ | '<' -> Buffer.add_string buff "<"
+ | '>' -> Buffer.add_string buff ">"
+ | ' ' -> Buffer.add_string buff " "
+ | '\"' -> Buffer.add_string buff """
+ | '&' -> Buffer.add_string buff "&"
+ | '\t' -> for i = 1 to tab_size do Buffer.add_string buff " " done
+ | _ -> Buffer.add_char buff ch);
+ incr ofs)
+ line;
+ List.iter (fun (_, n) -> marker n) !pts;
+ Buffer.contents buff
+
hunk ./src/reportUtils.mli 22
+val version : string
+(** The Bisect version, as a string. *)
+
+val url : string
+(** The Bisect version, as a string. *)
+
hunk ./src/reportUtils.mli 43
+val split : ('a -> bool) -> ('a list) -> 'a list * 'a list
+(** [split p [e1; ...; en]] returns [([e1; ...; e(i-1)], [ei; ...; en])]
+ where is is the lowest index such that [(p ei)] evaluates to false. *)
+
+val open_both : string -> string -> in_channel * out_channel
+(** [open_both in_file out_file] return a [(i, o)] couple where:
+ - [i] is an input channel for [in_file];
+ - [o] is an output channel for [out_file]. *)
+
+val output_strings : string list -> (string * string) list -> out_channel -> unit
+(** [output_strings lines mapping ch] writes the elements of [lines]
+ to the channel [ch]. Also substitutes {i $(xyz)} sequence as described
+ by [Buffer.add_substitute]. The substitution is based on the association
+ list [mapping]. *)
+
+val escape_line : int -> string -> int -> (int * int) list -> string
+(** [escape_line tab_size line offset points] escape the string [line],
+ in such a way it can be used in HTML/XML. [tab_size] is the number
+ of space character to use as a replacement for tabulations. [offset]
+ is the offset of the start of the line, inside the file. [points] is
+ a list of (offset, visits) couples. *)
+
}