CCKTree: more printers (to files)

This commit is contained in:
Simon Cruanes 2014-12-01 21:51:39 +01:00
parent e8f63c3330
commit 5f228501ad
2 changed files with 28 additions and 0 deletions

View file

@ -294,5 +294,20 @@ module Dot = struct
Format.pp_print_flush fmt ()
let pp_single name buf t = pp buf (singleton ~name t)
let print_to_file filename g =
let oc = open_out filename in
let fmt = Format.formatter_of_out_channel oc in
try
print fmt g;
Format.pp_print_flush fmt ();
close_out oc
with e ->
close_out oc;
raise e
let to_file ?(name="graph") filename trees =
let g = make ~name trees in
print_to_file filename g
end

View file

@ -126,5 +126,18 @@ module Dot : sig
val pp_single : string -> attribute list t printer
val print : graph formatter
(** Printer with indentation, etc.
@since NEXT_RELEASE *)
val print_to_file : string -> graph -> unit
(** [print_to_file filename g] prints [g] into a file whose name
is [filename].
@since NEXT_RELEASE *)
val to_file : ?name:string -> string -> attribute list t list -> unit
(** [to_file filename trees] makes a graph out of the trees, opens the
file [filename] and prints the graph into the file.
@param name name of the graph
@since NEXT_RELEASE *)
end