Skip to content

Commit

Permalink
Integrate simplified json index output
Browse files Browse the repository at this point in the history
  • Loading branch information
jonludlam committed Dec 4, 2024
1 parent 5f09935 commit 59ab30a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/driver/compile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,16 @@ let html_generate ~occurrence_file output_dir linked =
({ roots; output_file; json; search_dir = _; sidebar } as index :
Odoc_unit.index) =
let () =
Odoc.compile_index ~json ~occurrence_file ~output_file ~roots ()
Odoc.compile_index ~json ~occurrence_file ~output_file ~roots ~simplified:false ~wrap:false ()
in
let sidebar =
match sidebar with
| None -> None
| Some { output_file; json; pkg_dir } ->
Odoc.sidebar_generate ~output_file ~json index.output_file ();
Odoc.sidebar_generate ~output_file:(Fpath.(output_dir // pkg_dir / "sidebar.json")) ~json:true index.output_file ();
Odoc.compile_index ~json:true ~occurrence_file ~output_file:(Fpath.(output_dir // pkg_dir / "index.js")) ~simplified:true ~wrap:true ~roots ();

Some output_file
in
(sherlodoc_index_one ~output_dir index, sidebar)
Expand Down
6 changes: 4 additions & 2 deletions src/driver/odoc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,21 @@ let link ?(ignore_output = false) ~input_file:file ?output_file ~docs ~libs
ignore @@ Cmd_outputs.submit log desc cmd (Some output_file)

let compile_index ?(ignore_output = false) ~output_file ?occurrence_file ~json
~roots () =
~roots ~simplified ~wrap () =
let roots =
List.fold_left (fun c r -> Cmd.(c % "--root" % p r)) Cmd.empty roots
in
let json = if json then Cmd.v "--json" else Cmd.empty in
let simplified = if simplified then Cmd.v "--simplified-json" else Cmd.empty in
let wrap = if wrap then Cmd.v "--wrap-json" else Cmd.empty in
let occ =
match occurrence_file with
| None -> Cmd.empty
| Some f -> Cmd.(v "--occurrences" % p f)
in
let cmd =
Cmd.(
!odoc % "compile-index" %% json %% v "-o" % p output_file %% roots %% occ)
!odoc % "compile-index" %% json %% simplified %% wrap %% v "-o" % p output_file %% roots %% occ)
in
let desc =
Printf.sprintf "Generating index for %s" (Fpath.to_string output_file)
Expand Down
2 changes: 2 additions & 0 deletions src/driver/odoc.mli
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ val compile_index :
?occurrence_file:Fpath.t ->
json:bool ->
roots:Fpath.t list ->
simplified:bool ->
wrap:bool ->
unit ->
unit

Expand Down

0 comments on commit 59ab30a

Please sign in to comment.