File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -215,11 +215,26 @@ type cmt_scan_entry = {
215215
216216 If missing, returns the empty list and callers should fall back to legacy behavior. *)
217217
218+ let newerFile a b =
219+ match (Sys. file_exists a, Sys. file_exists b) with
220+ | true , true ->
221+ let mtime_a = (Unix. stat a).st_mtime in
222+ let mtime_b = (Unix. stat b).st_mtime in
223+ if mtime_b > mtime_a then b else a
224+ | true , false -> a
225+ | false , true -> b
226+ | false , false -> a
227+
218228let readCmtScan () =
219- let sourceDirsFile =
229+ let bsFile =
220230 [" lib" ; " bs" ; " .sourcedirs.json" ]
221231 |> List. fold_left Filename. concat runConfig.bsbProjectRoot
222232 in
233+ let lspFile =
234+ [" lib" ; " lsp" ; " .sourcedirs.json" ]
235+ |> List. fold_left Filename. concat runConfig.bsbProjectRoot
236+ in
237+ let sourceDirsFile = newerFile bsFile lspFile in
223238 let entries = ref [] in
224239 let read_entry (json : Ext_json_types.t ) =
225240 match json with
Original file line number Diff line number Diff line change @@ -40,7 +40,16 @@ let getRuntimeDir rootPath =
4040 None ))
4141 | true -> Some rootPath
4242
43- let getLibBs path = Files. ifExists (path /+ " lib" /+ " bs" )
43+ let getLibBs path =
44+ let bs = path /+ " lib" /+ " bs" in
45+ let lsp = path /+ " lib" /+ " lsp" in
46+ match (Sys. file_exists bs, Sys. file_exists lsp) with
47+ | true , true ->
48+ let mtime path = (Unix. stat path).st_mtime in
49+ if mtime lsp > mtime bs then Some lsp else Some bs
50+ | true , false -> Some bs
51+ | false , true -> Some lsp
52+ | false , false -> None
4453
4554let getStdlib base =
4655 match getRuntimeDir base with
Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ let debugFollowCtxPath = ref false
22
33let isDocGenFromCompiler = ref false
44
5- let libDir : string option ref = ref None
6-
75let inIncrementalTypecheckingMode =
86 ref
97 (try
Original file line number Diff line number Diff line change @@ -37,12 +37,9 @@ let newBsPackage ~rootPath =
3737
3838 let parseRaw raw =
3939 let libBs =
40- match ! Cfg. libDir with
41- | Some dir -> Files. ifExists (Filename. concat rootPath dir)
42- | None -> (
43- match ! Cfg. isDocGenFromCompiler with
44- | true -> BuildSystem. getStdlib rootPath
45- | false -> BuildSystem. getLibBs rootPath)
40+ match ! Cfg. isDocGenFromCompiler with
41+ | true -> BuildSystem. getStdlib rootPath
42+ | false -> BuildSystem. getLibBs rootPath
4643 in
4744 match Json. parse raw with
4845 | Some config -> (
Original file line number Diff line number Diff line change @@ -3,10 +3,9 @@ let docHelp =
33
44Output documentation to standard output
55
6- Usage : rescript- tools doc < FILE > [ -- lib - dir < DIR > ]
6+ Usage : rescript- tools doc < FILE >
77
8- Example : rescript- tools doc ./ path/ to / EntryPointLib. res
9- Example : rescript- tools doc ./ path/ to / EntryPointLib. res -- lib- dir lib/ lsp| }
8+ Example : rescript- tools doc ./ path/ to / EntryPointLib. res| }
109
1110let formatCodeblocksHelp =
1211 {| ReScript Tools
@@ -61,21 +60,13 @@ let main () =
6160 | "doc" :: rest -> (
6261 match rest with
6362 | [" -h" ] | [" --help" ] -> logAndExit (Ok docHelp)
64- | path :: args ->
63+ | path :: _ ->
6564 (* NOTE: Internal use to generate docs from compiler *)
6665 let () =
6766 match Sys. getenv_opt " FROM_COMPILER" with
6867 | Some "true" -> Analysis.Cfg. isDocGenFromCompiler := true
6968 | _ -> ()
7069 in
71- let rec parseArgs = function
72- | "--lib-dir" :: dir :: remaining ->
73- Analysis.Cfg. libDir := Some dir;
74- parseArgs remaining
75- | _ :: remaining -> parseArgs remaining
76- | [] -> ()
77- in
78- parseArgs args;
7970 logAndExit (Tools. extractDocs ~entry PointFile:path ~debug: false )
8071 | _ -> logAndExit (Error docHelp))
8172 | "migrate" :: file :: opts -> (
You can’t perform that action at this time.
0 commit comments