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

Fix indentation of doc-strings in classes #2387

Merged
merged 3 commits into from
Jul 3, 2023
Merged
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: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
- Restore short form for first-class modules: `((module M) : (module S))` is formatted as `(module M : S)`) (#2280, #2300, @gpetiot, @Julow)
- Restore short form formatting of record field aliases (#2282, @gpetiot)
- Tweaks the JaneStreet profile to be more consistent with ocp-indent (#2214, #2281, #2284, #2289, #2299, #2302, #2309, #2310, #2311, #2313, #2316, #2362, #2363, @gpetiot, @Julow)
- Improve formatting of class signatures (#2301, @gpetiot, @Julow)
- Improve formatting of class signatures (#2301, #2387, @gpetiot, @Julow)
- JaneStreet profile: treat comments as doc-comments (#2261, #2344, #2354, #2365, @gpetiot, @Julow)
- Don't indent attributes after a let/val/external (#2317, @Julow)
- Adjust indentation of class-expr function body (#2328, @gpetiot)
Expand Down
6 changes: 1 addition & 5 deletions lib/Fmt_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2730,11 +2730,7 @@ and fmt_class_signature c ~ctx ~parens ?ext self_ fields =
$ fmt_extension_suffix c ext
$ self_ $ fmt "@ "
$ hvbox 0
( ( match fields with
| {pctf_desc= Pctf_attribute a; _} :: _ when Attr.is_doc a ->
str "\n"
| _ -> noop )
$ fmt_if_k (List.is_empty fields)
( fmt_if_k (List.is_empty fields)
(Cmts.fmt_within ~pro:noop c (Ast.location ctx))
$ fmt_item_list c ctx update_config ast fmt_item fields )
$ fmt_if (not (List.is_empty fields)) "@;<1000 -2>"
Expand Down
4 changes: 4 additions & 0 deletions test/passing/tests/class_sig.mli
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ class c : int -> object end
class c (* a *) : (* b *) int (* c *) -> (* d *) object (* e *) end (* f *)

class c : object end

class c : object
(** Standalone doc-string. *)
end
9 changes: 4 additions & 5 deletions test/passing/tests/object.ml
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,13 @@ class a = object end
and b = object end

class type x = object

(** floatting1 *)
(** floatting1 *)

(** floatting2 *)
(** floatting2 *)

method x : int
method x : int

(** floatting3 *)
(** floatting3 *)
end

class x =
Expand Down