Skip to content

Commit 0dec6de

Browse files
committed
Driver: include occurrences count in the search index
Signed-off-by: Paul-Elliot <peada@free.fr>
1 parent 35410e3 commit 0dec6de

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

doc/driver.mld

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ Some more details about the json format:
783783
Search engines written in OCaml can also call the [Odoc_model.Fold.unit] and [Odoc_model.Fold.page] function, in conjunction with [Odoc_search.Entry.entry_of_item] in order to get an OCaml value of each element to be indexed.
784784

785785
{[
786-
let index_generate ?(ignore_output = false) () =
786+
let index_generate ?(ignore_output = false) occurrence_file =
787787
let open Cmd in
788788
let files =
789789
OS.Dir.contents (Fpath.v ".")
@@ -796,7 +796,7 @@ let index_generate ?(ignore_output = false) () =
796796
let index_map = Fpath.v "index.map" in
797797
let () = Bos.OS.File.write_lines index_map files |> get_ok in
798798
let cmd =
799-
odoc % "compile-index" % "-o" % "html/index.json" % "--file-list"
799+
odoc % "compile-index" % "-o" % "html/index.json" % "--occurrences" % p occurrence_file % "--file-list"
800800
% p index_map
801801
in
802802
let lines = run cmd in
@@ -855,7 +855,9 @@ The following code executes all of the above, and we're done!
855855
{[
856856
let compiled = compile_all () in
857857
let linked = link_all compiled in
858-
let () = index_generate () in
858+
let occurrence_file = Fpath.v "occurrences-odoc_and_deps.odoc" in
859+
let _ = count_occurrences occurrence_file in
860+
let () = index_generate occurrence_file in
859861
let _ = js_index () in
860862
let _ = count_occurrences (Fpath.v "occurrences-from-odoc.odoc") in
861863
generate_all linked

src/occurrences/table.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ let rec get t id =
7676
| `SourcePage _ | `Page _ | `LeafPage _ | `CoreType _ | `SourceLocation _
7777
| `CoreException _ | `Label _ | `SourceLocationMod _ | `Result _
7878
| `AssetFile _ | `SourceDir _ | `SourceLocationInternal _ ->
79-
assert false
79+
None
8080

8181
let rec iter f tbl =
8282
H.iter

0 commit comments

Comments
 (0)