@@ -1550,35 +1550,12 @@ and print_constructor_declarations ~state ~private_flag
15501550and print_constructor_declaration2 ~state i
15511551 (cd : Parsetree.constructor_declaration ) cmt_tbl =
15521552 let comment_attrs, attrs =
1553- List. partition
1554- (fun ((id , payload ) : Parsetree. attribute ) ->
1555- match (id, payload) with
1556- | ( {txt = " res.doc" },
1557- PStr
1558- [
1559- {
1560- pstr_desc =
1561- Pstr_eval
1562- ({pexp_desc = Pexp_constant (Pconst_string (_, _))}, _);
1563- };
1564- ] ) ->
1565- true
1566- | _ -> false )
1567- cd.pcd_attributes
1553+ ParsetreeViewer. partition_doc_comment_attributes cd.pcd_attributes
15681554 in
15691555 let comment_doc =
15701556 match comment_attrs with
15711557 | [] -> Doc. nil
1572- | comment_attrs ->
1573- Doc. concat
1574- [
1575- Doc. group
1576- (Doc. join_with_sep
1577- (List. map
1578- (fun attr -> print_attribute ~state attr cmt_tbl)
1579- comment_attrs));
1580- Doc. hard_line;
1581- ]
1558+ | comment_attrs -> print_doc_comments ~state cmt_tbl comment_attrs
15821559 in
15831560 let attrs = print_attributes ~state attrs cmt_tbl in
15841561 let is_dot_dot_dot = cd.pcd_name.txt = " ..." in
@@ -5601,6 +5578,15 @@ and print_bs_object_row ~state (lbl, expr) cmt_tbl =
56015578 in
56025579 print_comments doc cmt_tbl cmt_loc
56035580
5581+ and print_doc_comments ~state cmt_tbl attrs =
5582+ Doc. concat
5583+ [
5584+ Doc. group
5585+ (Doc. join_with_sep
5586+ (List. map (fun attr -> print_attribute ~state attr cmt_tbl) attrs));
5587+ Doc. hard_line;
5588+ ]
5589+
56045590(* The optional loc indicates whether we need to print the attributes in
56055591 * relation to some location. In practise this means the following:
56065592 * `@attr type t = string` -> on the same line, print on the same line
@@ -5613,21 +5599,7 @@ and print_attributes ?loc ?(inline = false) ~state
56135599 | [] -> Doc. nil
56145600 | attrs ->
56155601 let comment_attrs, attrs =
5616- List. partition
5617- (fun ((id , payload ) : Parsetree. attribute ) ->
5618- match (id, payload) with
5619- | ( {txt = " res.doc" },
5620- PStr
5621- [
5622- {
5623- pstr_desc =
5624- Pstr_eval
5625- ({pexp_desc = Pexp_constant (Pconst_string (_, _))}, _);
5626- };
5627- ] ) ->
5628- true
5629- | _ -> false )
5630- attrs
5602+ ParsetreeViewer. partition_doc_comment_attributes attrs
56315603 in
56325604 let line_break =
56335605 match loc with
@@ -5642,16 +5614,7 @@ and print_attributes ?loc ?(inline = false) ~state
56425614 let comment_doc =
56435615 match comment_attrs with
56445616 | [] -> Doc. nil
5645- | comment_attrs ->
5646- Doc. concat
5647- [
5648- Doc. group
5649- (Doc. join_with_sep
5650- (List. map
5651- (fun attr -> print_attribute ~state attr cmt_tbl)
5652- comment_attrs));
5653- Doc. hard_line;
5654- ]
5617+ | comment_attrs -> print_doc_comments ~state cmt_tbl comment_attrs
56555618 in
56565619 let attrs_doc =
56575620 match attrs with
0 commit comments