Skip to content

Commit

Permalink
Apply suggestions from PR review
Browse files Browse the repository at this point in the history
Suggested by @panglesd.
  • Loading branch information
jonludlam committed Sep 14, 2023
1 parent bb23d20 commit 6bcde37
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
13 changes: 7 additions & 6 deletions src/odoc/bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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. *)
Expand Down Expand Up @@ -732,8 +732,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
Expand Down
18 changes: 11 additions & 7 deletions src/odoc/html_page.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -76,7 +80,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 -> []

Expand Down
8 changes: 6 additions & 2 deletions src/odoc/html_page.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6bcde37

Please sign in to comment.