Skip to content

Commit 5ac1ffc

Browse files
committed
Apply suggestions from PR review
Suggested by @panglesd.
1 parent 06f21a4 commit 5ac1ffc

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

src/odoc/bin/main.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ let convert_fpath =
4141
let convert_src_fpath =
4242
let parse inp =
4343
match Arg.(conv_parser file) inp with
44-
| Ok s -> Result.Ok (Html_page.File (Fs.File.of_string s))
44+
| Ok s -> Result.Ok (Html_page.Source.File (Fs.File.of_string s))
4545
| Error _ as e -> e
46-
and print = Html_page.pp in
46+
and print = Html_page.Source.pp in
4747
Arg.conv (parse, print)
4848

4949
let convert_src_dir =
5050
let parse inp =
5151
match Arg.(conv_parser dir) inp with
52-
| Ok s -> Result.Ok (Html_page.Root (Fs.File.of_string s))
52+
| Ok s -> Result.Ok (Html_page.Source.Root (Fs.File.of_string s))
5353
| Error _ as e -> e
54-
and print = Html_page.pp in
54+
and print = Html_page.Source.pp in
5555
Arg.conv (parse, print)
5656

5757
(** On top of the conversion 'string', split into segs. *)
@@ -743,8 +743,9 @@ module Odoc_html_args = struct
743743

744744
let source_root =
745745
let doc =
746-
"Source code root for the compilation unit. It must have been compiled \
747-
with --source-parent passed."
746+
"Source code root for the compilation unit. Used to find the source file \
747+
from the value of --source-name it was compiled with. Incompatible with \
748+
--source-file."
748749
in
749750
Arg.(
750751
value

src/odoc/html_page.ml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@
1616

1717
open Odoc_model
1818

19-
type source = File of Fpath.t | Root of Fpath.t
19+
module Source = struct
20+
type t = File of Fpath.t | Root of Fpath.t
2021

21-
let pp fmt = function
22-
| File f -> Format.fprintf fmt "File: %a" Fpath.pp f
23-
| Root f -> Format.fprintf fmt "File: %a" Fpath.pp f
22+
let pp fmt = function
23+
| File f -> Format.fprintf fmt "File: %a" Fpath.pp f
24+
| Root f -> Format.fprintf fmt "File: %a" Fpath.pp f
2425

25-
let to_string f = Format.asprintf "%a" pp f
26+
let to_string f = Format.asprintf "%a" pp f
27+
end
28+
29+
type source = Source.t
2630

2731
type args = {
2832
html_config : Odoc_html.Config.t;
@@ -38,7 +42,7 @@ let source_documents source_info source ~syntax =
3842
| Some { Lang.Source_info.id; infos }, Some src -> (
3943
let file =
4044
match src with
41-
| File f -> f
45+
| Source.File f -> f
4246
| Root f ->
4347
let open Odoc_model.Paths.Identifier in
4448
let rec get_path_dir : SourceDir.t -> Fpath.t = function
@@ -78,7 +82,7 @@ let source_documents source_info source ~syntax =
7882
(Error.filename_only
7983
"--source argument is invalid on compilation unit that were not \
8084
compiled with --source-parent and --source-name"
81-
(to_string src));
85+
(Source.to_string src));
8286
[]
8387
| None, None -> []
8488

src/odoc/html_page.mli

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@
1616

1717
open Odoc_document
1818

19-
type source = File of Fpath.t | Root of Fpath.t
19+
module Source : sig
20+
type t = File of Fpath.t | Root of Fpath.t
2021

21-
val pp : Format.formatter -> source -> unit
22+
val pp : Format.formatter -> t -> unit
23+
end
24+
25+
type source = Source.t
2226

2327
type args = {
2428
html_config : Odoc_html.Config.t;

0 commit comments

Comments
 (0)