mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 11:45:31 -05:00
CCKTree: more printers (to files)
This commit is contained in:
parent
e8f63c3330
commit
5f228501ad
2 changed files with 28 additions and 0 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue