diff --git a/src/odoc/bin/main.ml b/src/odoc/bin/main.ml index 1d3784a4a6..83c79bf2e6 100644 --- a/src/odoc/bin/main.ml +++ b/src/odoc/bin/main.ml @@ -41,17 +41,17 @@ let convert_fpath = let convert_src_fpath = let parse inp = match Arg.(conv_parser file) inp with - | Ok s -> Result.Ok (Html_page.File (Fs.File.of_string s)) + | Ok s -> Result.Ok (Html_page.Source.File (Fs.File.of_string s)) | Error _ as e -> e - and print = Html_page.pp in + and print = Html_page.Source.pp in Arg.conv (parse, print) let convert_src_dir = let parse inp = match Arg.(conv_parser dir) inp with - | Ok s -> Result.Ok (Html_page.Root (Fs.File.of_string s)) + | Ok s -> Result.Ok (Html_page.Source.Root (Fs.File.of_string s)) | Error _ as e -> e - and print = Html_page.pp in + and print = Html_page.Source.pp in Arg.conv (parse, print) (** On top of the conversion 'string', split into segs. *) @@ -743,8 +743,9 @@ module Odoc_html_args = struct let source_root = let doc = - "Source code root for the compilation unit. It must have been compiled \ - with --source-parent passed." + "Source code root for the compilation unit. Used to find the source file \ + from the value of --source-name it was compiled with. Incompatible with \ + --source-file." in Arg.( value diff --git a/src/odoc/html_page.ml b/src/odoc/html_page.ml index 0578870632..b0c790416a 100644 --- a/src/odoc/html_page.ml +++ b/src/odoc/html_page.ml @@ -16,13 +16,17 @@ open Odoc_model -type source = File of Fpath.t | Root of Fpath.t +module Source = struct + type t = File of Fpath.t | Root of Fpath.t -let pp fmt = function - | File f -> Format.fprintf fmt "File: %a" Fpath.pp f - | Root f -> Format.fprintf fmt "File: %a" Fpath.pp f + let pp fmt = function + | File f -> Format.fprintf fmt "File: %a" Fpath.pp f + | Root f -> Format.fprintf fmt "File: %a" Fpath.pp f -let to_string f = Format.asprintf "%a" pp f + let to_string f = Format.asprintf "%a" pp f +end + +type source = Source.t type args = { html_config : Odoc_html.Config.t; @@ -38,7 +42,7 @@ let source_documents source_info source ~syntax = | Some { Lang.Source_info.id; infos }, Some src -> ( let file = match src with - | File f -> f + | Source.File f -> f | Root f -> let open Odoc_model.Paths.Identifier in let rec get_path_dir : SourceDir.t -> Fpath.t = function @@ -78,7 +82,7 @@ let source_documents source_info source ~syntax = (Error.filename_only "--source argument is invalid on compilation unit that were not \ compiled with --source-parent and --source-name" - (to_string src)); + (Source.to_string src)); [] | None, None -> [] diff --git a/src/odoc/html_page.mli b/src/odoc/html_page.mli index faa34e5e79..579acd3a3c 100644 --- a/src/odoc/html_page.mli +++ b/src/odoc/html_page.mli @@ -16,9 +16,13 @@ open Odoc_document -type source = File of Fpath.t | Root of Fpath.t +module Source : sig + type t = File of Fpath.t | Root of Fpath.t -val pp : Format.formatter -> source -> unit + val pp : Format.formatter -> t -> unit +end + +type source = Source.t type args = { html_config : Odoc_html.Config.t;