Skip to content

Commit c3f025d

Browse files
committed
Disable the missing root warning by default
It can be re-enabled via the command-line option --enable-missing-root-warning But since this is usually a build system issue rather than something end-users will need to worry about, let's not complain about it. Note that this will _not_ suppress warnings generated if references aren't resolved - so if you explicitly have a reference to something in a dependency library and it's not found when linking, you'll still get a warning. Fixes: #825
1 parent e300c9f commit c3f025d

File tree

7 files changed

+22
-7
lines changed

7 files changed

+22
-7
lines changed

src/model/error.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
open Result
22

3+
let enable_missing_root_warning = ref false
4+
35
type full_location_payload = Odoc_parser.Warning.t = {
46
location : Location_.span;
57
message : string;

src/model/error.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
type t
22

3+
val enable_missing_root_warning : bool ref
4+
35
val make :
46
?suggestion:string ->
57
('a, Format.formatter, unit, Location_.span -> t) format4 ->

src/odoc/bin/main.ml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,20 @@ let warnings_options =
8282
let env = Arg.env_var "ODOC_PRINT_WARNINGS" ~doc in
8383
Arg.(value & opt bool true & info ~docs ~doc ~env [ "print-warnings" ])
8484
in
85+
let enable_missing_root_warning =
86+
let doc =
87+
"Produce a warning when a root is missing. This is usually a build \
88+
system problem so is disabled for users by default."
89+
in
90+
let env = Arg.env_var "ODOC_ENABLE_MISSING_ROOT_WARNING" ~doc in
91+
Arg.(value & flag & info ~docs ~doc ~env [ "enable-missing-root-warning" ])
92+
in
8593
Term.(
86-
const (fun warn_error print_warnings ->
94+
const (fun warn_error print_warnings enable_missing_root_warning ->
95+
Odoc_model.Error.enable_missing_root_warning :=
96+
enable_missing_root_warning;
8797
{ Odoc_model.Error.warn_error; print_warnings })
88-
$ warn_error $ print_warnings)
98+
$ warn_error $ print_warnings $ enable_missing_root_warning)
8999

90100
let dst ?create () =
91101
let doc = "Output directory where the HTML tree is expected to be saved." in

src/xref2/lookup_failures.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ let raise_warnings ~filename failures =
5959
let catch_failures ~filename f =
6060
let r, failures = with_ref acc [] f in
6161
Error.catch_warnings (fun () ->
62-
raise_root_errors ~filename failures;
62+
if !Error.enable_missing_root_warning then
63+
raise_root_errors ~filename failures;
6364
raise_warnings ~filename failures;
6465
r)
6566

test/xref2/multi_file_module_type_of.t/run.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ In this instance, module S will not be expanded because we are not providing an
2626
odoc file for `Test0` - so there will be a warning when we run `odoc compile`
2727
on test1.cmti:
2828

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

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

37-
$ odoc compile --package foo test2.cmti -I .
37+
$ odoc compile --package foo test2.cmti -I . --enable-missing-root-warning
3838
File "test2.cmti":
3939
Warning: Couldn't find the following modules:
4040
Test1

test/xref2/unexpanded_module_type_of.t/run.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This is a test for [this issue](https://github.com/ocaml/odoc/issues/500)
1515
Compiling an odoc file for `test` without compiling one for `test0`
1616
should _not_ result in an exception, merely a warning.
1717

18-
$ odoc compile --package test test.cmti
18+
$ odoc compile --package test test.cmti --enable-missing-root-warning
1919
File "test.cmti":
2020
Warning: Couldn't find the following modules:
2121
Test0

test/xref2/warnings.t/run.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ A contains both parsing errors and a reference to B that isn't compiled yet:
2828
2929
A contains linking errors:
3030
31-
$ odoc link a.odoc
31+
$ odoc link a.odoc --enable-missing-root-warning
3232
File "a.odoc":
3333
Warning: Couldn't find the following modules:
3434
B

0 commit comments

Comments
 (0)