-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexplore.ml
More file actions
33 lines (27 loc) · 1 KB
/
explore.ml
File metadata and controls
33 lines (27 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(* © 2014 RunOrg *)
module String = BatString
let (//) = Filename.concat
(** Traversing all directories at the target location, extracting a list of
files and their contents. *)
(** The source path. Expected as the first command-line argument. *)
let source_path =
if Array.length Sys.argv < 3 then (
print_endline "Usage: doc-runorg [inpath] [outpath]" ;
exit (-1)) ;
Sys.argv.(1)
(** Create a list of all *.htm files inside the source directory. Recurses
into sub-directories. All paths are relative to the source path. *)
let all_htm =
let rec recurse path acc file =
let file_path = path // file in
if String.ends_with file ".htm" then file_path :: acc else
let full_path = source_path // file_path in
if Sys.is_directory full_path then
Array.fold_left (recurse file_path) acc (Sys.readdir full_path)
else
acc
in
recurse "" [] ""
(** Load [Read.t] for every file. *)
let all_data =
List.map (fun path -> Read.parse (source_path // path) path) all_htm