Skip to content

Commit 9007df2

Browse files
panglesdJulow
authored andcommitted
check that all children are in the search path during linking
The error is changed as child and source-children are no longer references. Signed-off-by: Paul-Elliot <[email protected]> Co-authored-by: Jules Aguillon <[email protected]>
1 parent 84a7b8f commit 9007df2

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/xref2/errors.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ type what =
292292
| `With_type of Cfrag.type_
293293
| `Module_type_expr of Component.ModuleType.expr
294294
| `Module_type_u_expr of Component.ModuleType.U.expr
295-
| `Child of Reference.t
295+
| `Child_module of string
296+
| `Child_page of string
296297
| `Reference of Reference.t ]
297298

298299
let report ~(what : what) ?tools_error action =
@@ -339,7 +340,8 @@ let report ~(what : what) ?tools_error action =
339340
r "module type expression" module_type_expr cexpr
340341
| `Module_type_u_expr cexpr ->
341342
r "module type u expression" u_module_type_expr cexpr
342-
| `Child rf -> r "child reference" model_reference rf
343+
| `Child_module rf -> r "child module" Astring.String.pp rf
344+
| `Child_page rf -> r "child page" Astring.String.pp rf
343345
| `Reference ref -> r "reference" model_reference ref
344346
in
345347
match kind_of_error ~what tools_error with

src/xref2/link.ml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,23 @@ let link ~filename x y =
10101010
if y.Lang.Compilation_unit.linked || y.hidden then y else unit x y)
10111011

10121012
let page env page =
1013+
let () =
1014+
List.iter
1015+
(fun child ->
1016+
let check_resolves ~what f name =
1017+
match f name env with
1018+
| Some _ -> ()
1019+
| None -> Errors.report ~what `Lookup
1020+
in
1021+
match child with
1022+
| Page.Source_tree_child _ -> ()
1023+
| Page.Page_child page ->
1024+
check_resolves ~what:(`Child_page page) Env.lookup_page page
1025+
| Page.Module_child mod_ ->
1026+
check_resolves ~what:(`Child_module mod_) Env.lookup_root_module
1027+
mod_)
1028+
page.Lang.Page.children
1029+
in
10131030
{
10141031
page with
10151032
Page.content = comment_docs env page.Page.name page.content;

test/pages/errors.t/run.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ Parents must be pages
2929
Linking checks the children are all present:
3030
$ odoc compile top1.mld --child foo
3131
$ odoc link page-top1.odoc -I .
32+
File "page-top1.odoc":
33+
Warning: Failed to lookup child page foo
3234

0 commit comments

Comments
 (0)