Skip to content

Disable the missing root warning by default #881

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

Merged
merged 1 commit into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/model/error.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open Result

let enable_missing_root_warning = ref false

type full_location_payload = Odoc_parser.Warning.t = {
location : Location_.span;
message : string;
Expand Down
2 changes: 2 additions & 0 deletions src/model/error.mli
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
type t

val enable_missing_root_warning : bool ref

val make :
?suggestion:string ->
('a, Format.formatter, unit, Location_.span -> t) format4 ->
Expand Down
14 changes: 12 additions & 2 deletions src/odoc/bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,20 @@ let warnings_options =
let env = Arg.env_var "ODOC_PRINT_WARNINGS" ~doc in
Arg.(value & opt bool true & info ~docs ~doc ~env [ "print-warnings" ])
in
let enable_missing_root_warning =
let doc =
"Produce a warning when a root is missing. This is usually a build \
system problem so is disabled for users by default."
in
let env = Arg.env_var "ODOC_ENABLE_MISSING_ROOT_WARNING" ~doc in
Arg.(value & flag & info ~docs ~doc ~env [ "enable-missing-root-warning" ])
in
Term.(
const (fun warn_error print_warnings ->
const (fun warn_error print_warnings enable_missing_root_warning ->
Odoc_model.Error.enable_missing_root_warning :=
enable_missing_root_warning;
{ Odoc_model.Error.warn_error; print_warnings })
$ warn_error $ print_warnings)
$ warn_error $ print_warnings $ enable_missing_root_warning)

let dst ?create () =
let doc = "Output directory where the HTML tree is expected to be saved." in
Expand Down
3 changes: 2 additions & 1 deletion src/xref2/lookup_failures.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ let raise_warnings ~filename failures =
let catch_failures ~filename f =
let r, failures = with_ref acc [] f in
Error.catch_warnings (fun () ->
raise_root_errors ~filename failures;
if !Error.enable_missing_root_warning then
raise_root_errors ~filename failures;
raise_warnings ~filename failures;
r)

Expand Down
4 changes: 2 additions & 2 deletions test/xref2/multi_file_module_type_of.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ In this instance, module S will not be expanded because we are not providing an
odoc file for `Test0` - so there will be a warning when we run `odoc compile`
on test1.cmti:

$ odoc compile --package foo test1.cmti
$ odoc compile --package foo test1.cmti --enable-missing-root-warning
File "test1.cmti":
Warning: Couldn't find the following modules:
Test0

Similarly, module `T` also can not be expanded, therefore we expect
another warning when we run `odoc compile` on test2.cmti:

$ odoc compile --package foo test2.cmti -I .
$ odoc compile --package foo test2.cmti -I . --enable-missing-root-warning
File "test2.cmti":
Warning: Couldn't find the following modules:
Test1
Expand Down
2 changes: 1 addition & 1 deletion test/xref2/unexpanded_module_type_of.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This is a test for [this issue](https://github.com/ocaml/odoc/issues/500)
Compiling an odoc file for `test` without compiling one for `test0`
should _not_ result in an exception, merely a warning.

$ odoc compile --package test test.cmti
$ odoc compile --package test test.cmti --enable-missing-root-warning
File "test.cmti":
Warning: Couldn't find the following modules:
Test0
2 changes: 1 addition & 1 deletion test/xref2/warnings.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ A contains both parsing errors and a reference to B that isn't compiled yet:

A contains linking errors:

$ odoc link a.odoc
$ odoc link a.odoc --enable-missing-root-warning
File "a.odoc":
Warning: Couldn't find the following modules:
B
Expand Down