-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplified search index #1284
Simplified search index #1284
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,21 +23,28 @@ let parse_input_files input = | |
(Ok []) input | ||
>>= fun files -> Ok (List.concat files) | ||
|
||
let compile_to_json ~output ~occurrences hierarchies = | ||
let compile_to_json ~output ~occurrences ~wrap ~simplified hierarchies = | ||
let output_channel = | ||
Fs.Directory.mkdir_p (Fs.File.dirname output); | ||
open_out_bin (Fs.File.to_string output) | ||
in | ||
let output = Format.formatter_of_out_channel output_channel in | ||
if wrap then Format.fprintf output "let documents = "; | ||
let all = | ||
List.fold_left | ||
(fun acc hierarchy -> | ||
Tree.fold_left | ||
~f:(fun acc entry -> Json_search.of_entry ?occurrences entry :: acc) | ||
~f:(fun acc entry -> | ||
Json_search.of_entry ~simplified ?occurrences entry :: acc) | ||
acc hierarchy) | ||
[] hierarchies | ||
in | ||
Format.fprintf output "%s" (Odoc_utils.Json.to_string (`Array (List.rev all))); | ||
if wrap then | ||
Format.fprintf output | ||
";\n\ | ||
const options = { keys: ['name', 'comment'] };\n\ | ||
var idx_fuse = new Fuse(documents, options);\n"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are making that the use of Fuse part of odoc (and not part of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a temporary grotty hack that I'd like to go away as soon as we've got proper sherlodoc support in ocaml.org. I'll see about hiding the options in the CLI. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it is something we are not going to keep, why not making it generated by the driver, from the output json file? This way, no need to hide it, and we have a guarantee no-one relies on it, if it happens to stay a bit longer before being removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (This could be done after the beta release, but before the actual release!) |
||
Ok () | ||
|
||
let read_occurrences file = | ||
|
@@ -52,7 +59,7 @@ let absolute_normalization p = | |
Fpath.normalize p | ||
|
||
let compile out_format ~output ~warnings_options ~occurrences ~roots | ||
~inputs_in_file ~odocls = | ||
~inputs_in_file ~simplified_json ~wrap_json ~odocls = | ||
let handle_warnings f = | ||
let res = Error.catch_warnings f in | ||
Error.handle_warnings ~warnings_options res |> Result.join | ||
|
@@ -126,5 +133,7 @@ let compile out_format ~output ~warnings_options ~occurrences ~roots | |
List.map hierarchy_of_group root_groups | ||
in | ||
match out_format with | ||
| `JSON -> compile_to_json ~output ~occurrences hierarchies | ||
| `JSON -> | ||
compile_to_json ~output ~occurrences ~simplified:simplified_json | ||
~wrap:wrap_json hierarchies | ||
| `Marshall -> Ok (Odoc_file.save_index output hierarchies) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
(** This module generates json intended to be consumed by search engines. *) | ||
|
||
val of_entry : | ||
simplified:bool -> | ||
?occurrences:Odoc_occurrences.Table.t -> | ||
Odoc_index.Entry.t -> | ||
Odoc_utils.Json.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or
.js
in this PR