Skip to content

Commit db2d707

Browse files
Fix error message for --child
1 parent 1823ecd commit db2d707

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/odoc/bin/main.ml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,9 @@ end = struct
194194
Ok (Compile.CliPackage { package = p; output })
195195
| None, None, Some p, [], Some output_dir ->
196196
Ok (Compile.CliParentId { parent_id = p; output_dir })
197-
| None, None, None, _ :: _, None -> Ok (Compile.CliParent {parent=None;output;children})
198-
| None, None, None, [] , None -> Ok (Compile.CliNoParent output)
197+
| None, None, None, _ :: _, None ->
198+
Ok (Compile.CliParent { parent = None; output; children })
199+
| None, None, None, [], None -> Ok (Compile.CliNoParent output)
199200
| Some _, Some _, _, _, _ ->
200201
error "Either --package or --parent should be specified, not both."
201202
| _, Some _, Some _, _, _ ->
@@ -204,8 +205,10 @@ end = struct
204205
error "Either --parent or --parent-id should be specified, not both."
205206
| _, _, None, _, Some _ ->
206207
error "--output-dir can only be passed with --parent-id."
207-
| None, _, _, _ :: _, _ ->
208-
error "--child can only be passed with --parent."
208+
| None, Some _, _, _ :: _, _ ->
209+
error "--child cannot be passed with --package."
210+
| None, _, Some _, _ :: _, _ ->
211+
error "--child cannot be passed with --parent-id."
209212
| _, _, Some _, _, None ->
210213
error "--output-dir is required when passing --parent-id."
211214
in

test/pages/errors.t/run.t

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,44 @@ Let's check for expected errors.
77
We need to match parents with children
88
$ odoc compile -c dummy top1.mld
99
$ odoc compile -I . --parent top1 sub1.mld
10-
ERROR: Specified parent is not a parent of this file
11-
[1]
1210

1311
This is a different code-path:
1412
$ odoc compile top1.mld --child foo
1513
$ odoc compile -I . --parent top1 sub1.mld
16-
ERROR: Specified parent is not a parent of this file
17-
[1]
1814

1915
And these need to specify compilation unit children as well as mld children
2016
$ ocamlc -c -bin-annot m1.mli
2117
$ odoc compile m1.cmti -I . --parent top1
22-
ERROR: Specified parent is not a parent of this file
18+
ERROR: File "m1.cmti":
19+
Specified parent is not a parent of this file
2320
[1]
2421

2522
Parents must be pages
2623
$ odoc compile top1.mld --child M1
2724
$ odoc compile m1.cmti -I . --parent top1
28-
ERROR: Specified parent is not a parent of this file
29-
[1]
3025
$ odoc compile sub1.mld -I . --parent module-M1
3126
ERROR: Expecting page as parent
3227
[1]
3328

3429
Linking checks the children are all present:
3530
$ odoc compile top1.mld --child foo
3631
$ odoc link page-top1.odoc -I .
32+
File "page-top1.odoc":
33+
Warning: Failed to lookup child page foo
3734

35+
There are old and new CLI options. We are checking than an error is produced
36+
when we mix the two kinds.
3837
$ odoc compile --parent bla --parent-id blabla m1.mli
3938
Either --parent or --parent-id should be specified, not both.
4039
[2]
4140
$ odoc compile --parent bla --package blabla m1.mli
4241
Either --package or --parent should be specified, not both.
4342
[2]
4443
$ odoc compile --package bla --child foo -- m1.mli
45-
--child can only be passed with --parent.
44+
--child cannot be passed with --package.
4645
[2]
4746
$ odoc compile --parent-id bla --child foo -- m1.mli
48-
--child can only be passed with --parent.
47+
--child cannot be passed with --parent-id.
4948
[2]
5049
$ odoc compile --package bla --output-dir foo -- m1.mli
5150
--output-dir can only be passed with --parent-id.

0 commit comments

Comments
 (0)