@@ -423,8 +423,34 @@ Each possible error code is documented in the following section.
423423 (snd (List. split
424424 (List. sort (fun (n1 , _ ) (n2 , _ )-> compare n1 n2) errs)))
425425
426- let all api destdir =
426+ let json_current_version =
427+ let time = Unix. gettimeofday () in
428+ let month, year =
429+ match String. split ' ' (Date. rfc822_to_string (Date. rfc822_of_float time)) with
430+ | [ _; _; m; y; _; _ ] -> m,y
431+ | _ -> failwith " Invalid datetime string"
432+ in
433+ `O [
434+ " api_version_major" , `Float (Int64. to_float api_version_major);
435+ " api_version_minor" , `Float (Int64. to_float api_version_minor);
436+ " current_year" , `String year;
437+ " current_month" , `String month;
438+ ]
439+
440+ let render_template template_file json output_file =
441+ let templ = Stdext.Unixext. string_of_file template_file |> Mustache. of_string in
442+ let rendered = Mustache. render templ json in
443+ let out_chan = open_out output_file in
444+ finally (fun () -> output_string out_chan rendered)
445+ (fun () -> close_out out_chan)
446+
447+ let all api templdir destdir =
427448 Stdext.Unixext. mkdir_rec destdir 0o755 ;
449+
450+ [" cover.mustache" , " cover.yaml" ; " docbook.mustache" , " template.db" ] |>
451+ List. iter (fun (x ,y ) -> render_template
452+ (Filename. concat templdir x) json_current_version (Filename. concat destdir y));
453+
428454 let out_chan = open_out (Filename. concat destdir " api-ref-autogen.md" ) in
429455 let printer text =
430456 fprintf out_chan " %s" text;
0 commit comments