diff --git a/CHANGES.md b/CHANGES.md index bdff746..94427e2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +### unreleased + +- Fix typos and improve logs display (by [clementd](https://clementd.wtf)) + ### v2.8.0 2025-12-17 Nantes (France) #### Yocaml diff --git a/lib/core/data.mli b/lib/core/data.mli index d7933c8..5014346 100644 --- a/lib/core/data.mli +++ b/lib/core/data.mli @@ -410,7 +410,7 @@ module Validation : sig -> (t -> 'a validated_value) -> 'a validated_record (** [optional_or ~default assoc field validator] optional [field] of [assoc], - validated by [validator]. If the field does not exists, it return default. + validated by [validator]. If the field does not exist, it returns default. ([default] is not validated) *) val field : diff --git a/lib/core/eff.ml b/lib/core/eff.ml index 076ce14..80fe8a5 100644 --- a/lib/core/eff.ml +++ b/lib/core/eff.ml @@ -216,7 +216,7 @@ let erase_file ~on path = if file then perform @@ Yocaml_erase_file (on, path) else logf ~src:yocaml_log_src ~level:`Warning - "%a is not a file (or does not exists)" Path.pp path + "%a is not a file (or does not exist)" Path.pp path let read_directory ~on ?(only = `Both) ?(where = fun _ -> true) path = let* is_dir = is_directory ~on path in @@ -237,7 +237,7 @@ let read_directory ~on ?(only = `Both) ?(where = fun _ -> true) path = List.filter_map predicate children else let+ () = - logf ~src:yocaml_log_src ~level:`Warning "%a does not exists" Path.pp path + logf ~src:yocaml_log_src ~level:`Warning "%a does not exist" Path.pp path in [] diff --git a/lib/core/eff.mli b/lib/core/eff.mli index d8a0f03..1f023bd 100644 --- a/lib/core/eff.mli +++ b/lib/core/eff.mli @@ -289,10 +289,10 @@ val run : ('b, 'c) Effect.Deep.handler -> ('a -> 'b t) -> 'a -> 'c Exception that can be propagated by the performance of effects. *) exception File_not_exists of filesystem * Path.t -(** Exception raised when a file does not exists. *) +(** Exception raised when a file does not exist. *) exception Invalid_path of filesystem * Path.t -(** Exception raised when a file does not has a basename. *) +(** Exception raised when a file does not have a basename. *) exception File_is_a_directory of filesystem * Path.t (** Exception raised when we try to use a directory as a regular file. *) @@ -358,7 +358,7 @@ val file_exists : on:filesystem -> Path.t -> bool t val read_file : ?snapshot:bool -> on:filesystem -> Path.t -> string t (** [read_file ?snapshot ~on path] perform the effect [Yocaml_read_file] with a given [path] and try to read it. Perform [Yocaml_failwith] with - {!exception:File_not_exists} if the file does not exists. [snapshot] is used + {!exception:File_not_exists} if the file does not exist. [snapshot] is used to perform a snapshot of the file. *) val read_file_as_metadata : @@ -392,7 +392,7 @@ val read_file_with_metadata : val mtime : on:filesystem -> Path.t -> int t (** [mtime ~on path] perform the effect [Yocaml_source_get_mtime] with a given [path] and try to get the modification time. Perform [Yocaml_failwith] with - {!exception:File_not_exists} if the file does not exists. + {!exception:File_not_exists} if the file does not exist. The logic of [mtime] differs slightly from that of Unix. If a directory is given as an argument, the function will return the largest [mtime] diff --git a/lib/core/lexicon.ml b/lib/core/lexicon.ml index 6eea82d..56490d6 100644 --- a/lib/core/lexicon.ml +++ b/lib/core/lexicon.ml @@ -93,7 +93,7 @@ let unknown_error ppf exn = (Printexc.to_string exn) let file_not_exists source path ppf () = - Format.fprintf ppf "The file `%a` (on `%a`) does not exists" Path.pp path + Format.fprintf ppf "The file `%a` (on `%a`) does not exist" Path.pp path pp_filesystem source let invalid_path source path ppf () = @@ -114,6 +114,6 @@ let directory_is_a_file source path ppf () = let directory_not_exists source path ppf () = Format.fprintf ppf - "The following directory: `%a` (on `%a`) does not exists (or is maybe a \ + "The following directory: `%a` (on `%a`) does not exist (or is maybe a \ file and not a directory)" Path.pp path pp_filesystem source diff --git a/lib/runtime/log.ml b/lib/runtime/log.ml index 866c03a..e06d74b 100644 --- a/lib/runtime/log.ml +++ b/lib/runtime/log.ml @@ -25,7 +25,7 @@ let level_to_logs = function let msg ?src level message = let level = level_to_logs level in - Logs.msg ?src level (fun print -> print "%s" message) + Logs.msg ?src level (fun print -> print " %s" message) let setup ?level () = match level with diff --git a/test/e2e/run.t b/test/e2e/run.t index 02a60fc..5fd5e48 100644 --- a/test/e2e/run.t +++ b/test/e2e/run.t @@ -1,33 +1,33 @@ Run the generator $ ./bin/gen.exe ./bin/gen.exe - [DEBUG]Trigger in ./ - [DEBUG]Cache initiated in `./_www/.cache` - [DEBUG]`./_www/style.css` will be written - [INFO]`./_www/style.css` has been written - [DEBUG]`./_www/articles/first_article.html` will be written - [INFO]`./_www/articles/first_article.html` has been written - [DEBUG]./content/templates/article.html already stored - [DEBUG]./content/templates/layout.html already stored - [DEBUG]`./_www/articles/second_article.html` will be written - [INFO]`./_www/articles/second_article.html` has been written - [DEBUG]./content/templates/article.html already stored - [DEBUG]./content/templates/layout.html already stored - [DEBUG]`./_www/articles-with-applicative-read/first_article.html` will be written - [INFO]`./_www/articles-with-applicative-read/first_article.html` has been written - [DEBUG]./content/templates/article.html already stored - [DEBUG]./content/templates/layout.html already stored - [DEBUG]`./_www/articles-with-applicative-read/second_article.html` will be written - [INFO]`./_www/articles-with-applicative-read/second_article.html` has been written - [DEBUG]./content/templates/article.html already stored - [DEBUG]./content/templates/layout.html already stored - [DEBUG]`./_www/articles-with-applicative-read-2/first_article.html` will be written - [INFO]`./_www/articles-with-applicative-read-2/first_article.html` has been written - [DEBUG]./content/templates/article.html already stored - [DEBUG]./content/templates/layout.html already stored - [DEBUG]`./_www/articles-with-applicative-read-2/second_article.html` will be written - [INFO]`./_www/articles-with-applicative-read-2/second_article.html` has been written - [DEBUG]Cache stored in `./_www/.cache` + [DEBUG] Trigger in ./ + [DEBUG] Cache initiated in `./_www/.cache` + [DEBUG] `./_www/style.css` will be written + [INFO] `./_www/style.css` has been written + [DEBUG] `./_www/articles/first_article.html` will be written + [INFO] `./_www/articles/first_article.html` has been written + [DEBUG] ./content/templates/article.html already stored + [DEBUG] ./content/templates/layout.html already stored + [DEBUG] `./_www/articles/second_article.html` will be written + [INFO] `./_www/articles/second_article.html` has been written + [DEBUG] ./content/templates/article.html already stored + [DEBUG] ./content/templates/layout.html already stored + [DEBUG] `./_www/articles-with-applicative-read/first_article.html` will be written + [INFO] `./_www/articles-with-applicative-read/first_article.html` has been written + [DEBUG] ./content/templates/article.html already stored + [DEBUG] ./content/templates/layout.html already stored + [DEBUG] `./_www/articles-with-applicative-read/second_article.html` will be written + [INFO] `./_www/articles-with-applicative-read/second_article.html` has been written + [DEBUG] ./content/templates/article.html already stored + [DEBUG] ./content/templates/layout.html already stored + [DEBUG] `./_www/articles-with-applicative-read-2/first_article.html` will be written + [INFO] `./_www/articles-with-applicative-read-2/first_article.html` has been written + [DEBUG] ./content/templates/article.html already stored + [DEBUG] ./content/templates/layout.html already stored + [DEBUG] `./_www/articles-with-applicative-read-2/second_article.html` will be written + [INFO] `./_www/articles-with-applicative-read-2/second_article.html` has been written + [DEBUG] Cache stored in `./_www/.cache` Inspect tree $ tree _www @@ -204,15 +204,15 @@ Inspect Second Applicative read (same content of article) Run the Liquid generator $ ./bin/gen_liquid.exe ./bin/gen_liquid.exe - [DEBUG]Trigger in ./ - [DEBUG]Cache restored from `./_www/.cache` - [DEBUG]`./_www/liquid-articles/first_article.html` will be written - [INFO]`./_www/liquid-articles/first_article.html` has been written - [DEBUG]./content/templates/article.liquid already stored - [DEBUG]./content/templates/layout.liquid already stored - [DEBUG]`./_www/liquid-articles/second_article.html` will be written - [INFO]`./_www/liquid-articles/second_article.html` has been written - [DEBUG]Cache stored in `./_www/.cache` + [DEBUG] Trigger in ./ + [DEBUG] Cache restored from `./_www/.cache` + [DEBUG] `./_www/liquid-articles/first_article.html` will be written + [INFO] `./_www/liquid-articles/first_article.html` has been written + [DEBUG] ./content/templates/article.liquid already stored + [DEBUG] ./content/templates/layout.liquid already stored + [DEBUG] `./_www/liquid-articles/second_article.html` will be written + [INFO] `./_www/liquid-articles/second_article.html` has been written + [DEBUG] Cache stored in `./_www/.cache` Inspect tree after Liquid generation $ tree _www _www @@ -278,17 +278,17 @@ Inspect Liquid Second Article Observe Residual Removing $ ./bin/gen_residuals.exe ./bin/gen_residuals.exe - [DEBUG]Cache initiated in `./residuals_build/cache` - [DEBUG]`./residuals_build/1.txt` will be written - [INFO]`./residuals_build/1.txt` has been written - [DEBUG]`./residuals_build/2.txt` will be written - [INFO]`./residuals_build/2.txt` has been written - [DEBUG]`./residuals_build/3.txt` will be written - [INFO]`./residuals_build/3.txt` has been written - [INFO]Remove residuals for ./residuals_build - [INFO]./residuals_build/4.txt deleted! - [INFO]./residuals_build/5.txt deleted! - [DEBUG]Cache stored in `./residuals_build/cache` + [DEBUG] Cache initiated in `./residuals_build/cache` + [DEBUG] `./residuals_build/1.txt` will be written + [INFO] `./residuals_build/1.txt` has been written + [DEBUG] `./residuals_build/2.txt` will be written + [INFO] `./residuals_build/2.txt` has been written + [DEBUG] `./residuals_build/3.txt` will be written + [INFO] `./residuals_build/3.txt` has been written + [INFO] Remove residuals for ./residuals_build + [INFO] ./residuals_build/4.txt deleted! + [INFO] ./residuals_build/5.txt deleted! + [DEBUG] Cache stored in `./residuals_build/cache` $ ls residuals_build 1.txt @@ -298,12 +298,12 @@ Observe Residual Removing $ ./bin/gen_residuals.exe ./bin/gen_residuals.exe - [DEBUG]Cache restored from `./residuals_build/cache` - [DEBUG]`./residuals_build/1.txt` always has the same hash as in the cache, already up-to-date - [DEBUG]`./residuals_build/2.txt` always has the same hash as in the cache, already up-to-date - [DEBUG]`./residuals_build/3.txt` always has the same hash as in the cache, already up-to-date - [INFO]Remove residuals for ./residuals_build - [DEBUG]Cache stored in `./residuals_build/cache` + [DEBUG] Cache restored from `./residuals_build/cache` + [DEBUG] `./residuals_build/1.txt` always has the same hash as in the cache, already up-to-date + [DEBUG] `./residuals_build/2.txt` always has the same hash as in the cache, already up-to-date + [DEBUG] `./residuals_build/3.txt` always has the same hash as in the cache, already up-to-date + [INFO] Remove residuals for ./residuals_build + [DEBUG] Cache stored in `./residuals_build/cache` $ ls residuals_build 1.txt diff --git a/test/lib/fs.ml b/test/lib/fs.ml index 72a17c3..dab2b30 100644 --- a/test/lib/fs.ml +++ b/test/lib/fs.ml @@ -366,7 +366,7 @@ let run ~trace program input = match get !trace.system path with | Some (Dir _) -> true | _ -> false - (* We suppose that if a file does not exists, + (* We suppose that if a file does not exist, it is not a directory... *) in continue k res) @@ -379,7 +379,7 @@ let run ~trace program input = match get !trace.system path with | Some (File _) -> true | _ -> false - (* We suppose that if a file does not exists, + (* We suppose that if a file does not exist, it is not a file... *) in continue k res) diff --git a/test/lib/gen.ml b/test/lib/gen.ml index 498a082..7ccb939 100644 --- a/test/lib/gen.ml +++ b/test/lib/gen.ml @@ -16,11 +16,11 @@ let csexp = let open QCheck2.Gen in - let atom = small_string ~gen:printable |> map Yocaml.Sexp.atom in - let node self n = small_list (self (n / 10)) |> map Yocaml.Sexp.node in + let atom = string_small |> map Yocaml.Sexp.atom in + let node self n = list_small (self (n / 10)) |> map Yocaml.Sexp.node in fix (fun self -> function | 0 -> atom - | n -> frequency [ (1, atom); (5, node self n) ]) + | n -> oneof_weighted [ (1, atom); (5, node self n) ]) |> sized let alphanumeric = @@ -32,20 +32,20 @@ let sexp = let atom = string_size ~gen:alphanumeric (int_range 1 100) |> map Yocaml.Sexp.atom in - let node self n = small_list (self (n / 10)) |> map Yocaml.Sexp.node in + let node self n = list_small (self (n / 10)) |> map Yocaml.Sexp.node in fix (fun self -> function | 0 -> atom - | n -> frequency [ (1, atom); (5, node self n) ]) + | n -> oneof_weighted [ (1, atom); (5, node self n) ]) |> sized let path = let open QCheck2.Gen in let fragment = - string_size ~gen:(char_range 'a' 'z') (int_range 1 10) |> small_list + string_size ~gen:(char_range 'a' 'z') (int_range 1 10) |> list_small in let rel = fragment |> map Yocaml.Path.rel in let abs = fragment |> map Yocaml.Path.abs in - frequency [ (5, rel); (5, abs) ] + oneof_weighted [ (5, rel); (5, abs) ] let deps = let open QCheck2.Gen in @@ -56,8 +56,8 @@ let cache_entry = map3 (fun last_build_date hash deps -> Yocaml.Cache.entry ?last_build_date hash deps) - (opt int) - (small_string ~gen:printable) + (option int) + string_small deps let cache = @@ -67,4 +67,4 @@ let cache = let+ k = path in (k, v) in - line |> small_list |> map Yocaml.Cache.from_list + line |> list_small |> map Yocaml.Cache.from_list