summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/generate.ml16
-rw-r--r--src/generate.mli1
2 files changed, 17 insertions, 0 deletions
diff --git a/src/generate.ml b/src/generate.ml
new file mode 100644
index 0000000..c90cfc9
--- /dev/null
+++ b/src/generate.ml
@@ -0,0 +1,16 @@
+(* Load interface definitions from a directory into a reference tree *)
+let load_interface_definitions dir =
+ let open Reference_tree in
+ let relative_paths = FileUtil.ls dir in
+ let absolute_paths =
+ try Ok (List.map Util.absolute_path relative_paths)
+ with Sys_error no_dir_msg -> Error no_dir_msg
+ in
+ let load_aux tree file =
+ load_from_xml tree file
+ in
+ try begin match absolute_paths with
+ | Ok paths -> Ok (List.fold_left load_aux default paths)
+ | Error msg -> Error msg end
+ with Bad_interface_definition msg -> Error msg
+
diff --git a/src/generate.mli b/src/generate.mli
new file mode 100644
index 0000000..cbb03ff
--- /dev/null
+++ b/src/generate.mli
@@ -0,0 +1 @@
+val load_interface_definitions : string -> (Reference_tree.t, string) result