diff --git a/CHANGES.md b/CHANGES.md index 0906cccbca..44fe0d443d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -18,6 +18,8 @@ + Avoid normalizing newlines inside quoted strings `{|...|}` (#1754, @nojb, @hhugo) + + Add missing normalization of code spans in docstrings (#1736, @jberdine) + #### Changes #### New features diff --git a/lib/Fmt.mli b/lib/Fmt.mli index d53ef983c1..cc6bd064c3 100644 --- a/lib/Fmt.mli +++ b/lib/Fmt.mli @@ -20,9 +20,9 @@ type s = (unit, Format.formatter, unit) format type t type sp = - | Blank (** [ ] *) + | Blank (** [ ] *) | Cut (** [@,] *) - | Space (** [@ ] *) + | Space (** [@ ] *) | Break of int * int (** [@;] *) val sp : sp -> t diff --git a/lib/Fmt_odoc.ml b/lib/Fmt_odoc.ml index 0b0c088acf..b6fe268e5b 100644 --- a/lib/Fmt_odoc.ml +++ b/lib/Fmt_odoc.ml @@ -89,7 +89,8 @@ let fmt_code_block conf s1 s2 = let box = match lines with _ :: _ :: _ -> vbox 0 | _ -> hvbox 0 in box (wrap_code (vbox 0 (list_fl lines fmt_line))) -let fmt_code_span s = hovbox 0 (wrap "[" "]" (str (escape_brackets s))) +let fmt_code_span s = + hovbox 0 (wrap "[" "]" (str_normalized ~escape:escape_brackets s)) let fmt_reference = ign_loc ~f:str_normalized diff --git a/test/passing/tests/doc_comments-no-wrap.mli.ref b/test/passing/tests/doc_comments-no-wrap.mli.ref index c296d80b13..808710a061 100644 --- a/test/passing/tests/doc_comments-no-wrap.mli.ref +++ b/test/passing/tests/doc_comments-no-wrap.mli.ref @@ -344,12 +344,12 @@ end (** {%html:

Raw markup

%} {%Without language%} {%other:Other language%} *) -(** [Multi - Line] +(** [Multi Line] - [ A lot of spaces ] + [A lot of spaces] - [Very looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong] *) + [Very + looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong] *) (** {[ for i = 1 to 3 do @@ -411,7 +411,7 @@ end (** This is a comment with code inside {[ - (** This is a comment with code inside [ let code inside = f inside ] *) + (** This is a comment with code inside [let code inside = f inside] *) let code inside (* comment *) = f inside ]} *) @@ -496,7 +496,7 @@ val k : int (** *) -(** [trim " "] is [""] *) +(** [trim " "] is [""] *) (** [trms (c × (Σᵢ₌₁ⁿ cᵢ × Πⱼ₌₁ᵐᵢ Xᵢⱼ^pᵢⱼ))] is the sequence of terms [Xᵢⱼ] for each [i] and [j]. *) diff --git a/test/passing/tests/doc_comments.mli.ref b/test/passing/tests/doc_comments.mli.ref index 76acdbd8db..9c71bbcf9d 100644 --- a/test/passing/tests/doc_comments.mli.ref +++ b/test/passing/tests/doc_comments.mli.ref @@ -344,12 +344,12 @@ end (** {%html:

Raw markup

%} {%Without language%} {%other:Other language%} *) -(** [Multi - Line] +(** [Multi Line] - [ A lot of spaces ] + [A lot of spaces] - [Very looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong] *) + [Very + looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong] *) (** {[ for i = 1 to 3 do @@ -411,7 +411,7 @@ end (** This is a comment with code inside {[ - (** This is a comment with code inside [ let code inside = f inside ] *) + (** This is a comment with code inside [let code inside = f inside] *) let code inside (* comment *) = f inside ]} *) @@ -496,7 +496,7 @@ val k : int (** *) -(** [trim " "] is [""] *) +(** [trim " "] is [""] *) (** [trms (c × (Σᵢ₌₁ⁿ cᵢ × Πⱼ₌₁ᵐᵢ Xᵢⱼ^pᵢⱼ))] is the sequence of terms [Xᵢⱼ] for each [i] and [j]. *)