Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing docstring normalization #1736

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/Fmt.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/Fmt_odoc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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))
jberdine marked this conversation as resolved.
Show resolved Hide resolved

let fmt_reference = ign_loc ~f:str_normalized

Expand Down
12 changes: 6 additions & 6 deletions test/passing/tests/doc_comments-no-wrap.mli.ref
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,12 @@ end

(** {%html:<p>Raw markup</p>%} {%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
Expand Down Expand Up @@ -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
]} *)

Expand Down Expand Up @@ -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]. *)
Expand Down
12 changes: 6 additions & 6 deletions test/passing/tests/doc_comments.mli.ref
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,12 @@ end

(** {%html:<p>Raw markup</p>%} {%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
Expand Down Expand Up @@ -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
]} *)

Expand Down Expand Up @@ -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]. *)
Expand Down