@@ -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
@@ -5600,6 +5577,15 @@ and print_bs_object_row ~state (lbl, expr) cmt_tbl =
56005577 in
56015578 print_comments doc cmt_tbl cmt_loc
56025579
5580+ and print_doc_comments ~state cmt_tbl attrs =
5581+ Doc. concat
5582+ [
5583+ Doc. group
5584+ (Doc. join_with_sep
5585+ (List. map (fun attr -> print_attribute ~state attr cmt_tbl) attrs));
5586+ Doc. hard_line;
5587+ ]
5588+
56035589(* The optional loc indicates whether we need to print the attributes in
56045590 * relation to some location. In practise this means the following:
56055591 * `@attr type t = string` -> on the same line, print on the same line
@@ -5612,21 +5598,7 @@ and print_attributes ?loc ?(inline = false) ~state
56125598 | [] -> Doc. nil
56135599 | attrs ->
56145600 let comment_attrs, attrs =
5615- List. partition
5616- (fun ((id , payload ) : Parsetree. attribute ) ->
5617- match (id, payload) with
5618- | ( {txt = " res.doc" },
5619- PStr
5620- [
5621- {
5622- pstr_desc =
5623- Pstr_eval
5624- ({pexp_desc = Pexp_constant (Pconst_string (_, _))}, _);
5625- };
5626- ] ) ->
5627- true
5628- | _ -> false )
5629- attrs
5601+ ParsetreeViewer. partition_doc_comment_attributes attrs
56305602 in
56315603 let line_break =
56325604 match loc with
@@ -5641,16 +5613,7 @@ and print_attributes ?loc ?(inline = false) ~state
56415613 let comment_doc =
56425614 match comment_attrs with
56435615 | [] -> Doc. nil
5644- | comment_attrs ->
5645- Doc. concat
5646- [
5647- Doc. group
5648- (Doc. join_with_sep
5649- (List. map
5650- (fun attr -> print_attribute ~state attr cmt_tbl)
5651- comment_attrs));
5652- Doc. hard_line;
5653- ]
5616+ | comment_attrs -> print_doc_comments ~state cmt_tbl comment_attrs
56545617 in
56555618 let attrs_doc =
56565619 match attrs with
0 commit comments