Skip to content

Commit

Permalink
Allow to generate empty indexes
Browse files Browse the repository at this point in the history
Signed-off-by: Paul-Elliot <[email protected]>
  • Loading branch information
panglesd committed Jul 8, 2024
1 parent a040c6f commit 5f843a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
11 changes: 2 additions & 9 deletions src/odoc/bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,8 @@ module Indexing = struct
let index dst json warnings_options includes_rec inputs_in_file inputs =
let marshall = if json then `JSON else `Marshall in
output_file ~dst marshall >>= fun output ->
match (includes_rec, inputs_in_file, inputs) with
| [], [], [] ->
Result.Error
(`Msg
"At least one of --file-list or --include-rec or an .odocl file \
must be passed to odoc compile-index")
| _ ->
Indexing.compile marshall ~output ~warnings_options ~includes_rec
~inputs_in_file ~odocls:inputs
Indexing.compile marshall ~output ~warnings_options ~includes_rec
~inputs_in_file ~odocls:inputs
let cmd =
let dst =
let doc =
Expand Down
8 changes: 3 additions & 5 deletions src/odoc/indexing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ let compile out_format ~output ~warnings_options ~includes_rec ~inputs_in_file
[] include_rec)
|> List.concat)
in
if files = [] then Error (`Msg "No .odocl files were included")
else
match out_format with
| `JSON -> compile_to_json ~output ~warnings_options files
| `Marshall -> compile_to_marshall ~output ~warnings_options files
match out_format with
| `JSON -> compile_to_json ~output ~warnings_options files
| `Marshall -> compile_to_marshall ~output ~warnings_options files
20 changes: 10 additions & 10 deletions test/search/html_search.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,18 @@ Testing the warnings/errors for the `compile-index` command:
Passing an inexistent file:
$ odoc compile-index --include-rec babar
ERROR: No .odocl files were included
[1]
$ odoc compile-index --file-list babar
odoc: option '--file-list': no 'babar' file or directory
Usage: odoc compile-index [--file-list=FILE] [--include-rec=DIR] [--json] [OPTION]… [FILE]…
Try 'odoc compile-index --help' or 'odoc --help' for more information.
[2]
Passing an empty folder:
Passing an empty folder is allowed:
$ mkdir foo
$ odoc compile-index --include-rec foo
Wrong file extensions:
$ odoc compile-index -o index.odoc
ERROR: When generating a binary index, the output must have a .odoc-index file extension
Expand All @@ -259,9 +265,6 @@ Passing an empty folder:
$ odoc compile-index --json -o index.odoc-index
ERROR: When generating a json index, the output must have a .json file extension
[1]
$ odoc compile-index --include-rec foo
ERROR: No .odocl files were included
[1]
Passing a file which is not a correctly marshalled one:
Expand All @@ -272,9 +275,6 @@ Passing a file which is not a correctly marshalled one:
Passing no file:
Passing no file is allowed, generating an empty index:
$ odoc compile-index
ERROR: At least one of --file-list or --include-rec or an .odocl file must be passed to odoc compile-index
[1]

0 comments on commit 5f843a3

Please sign in to comment.