@@ -140,6 +140,11 @@ module Clflags = Reason_syntax_util.Clflags
140140
141141*)
142142
143+ let make_floating_doc = function
144+ | {attr_name = {txt = "ocaml.doc" ; _} as attr_name ; _} as attr ->
145+ {attr with attr_name = {attr_name with txt = " ocaml.text" }}
146+ | attr -> attr
147+
143148let uncurry_payload ?(name =" bs" ) loc =
144149 { attr_name = {loc; txt = name};
145150 attr_payload = PStr [] ;
@@ -987,6 +992,7 @@ let mkBsObjTypeSugar ~loc ~closed rows =
987992let doc_loc loc = {txt = " ocaml.doc" ; loc = loc}
988993
989994let doc_attr text loc =
995+ (* Here is where we will convert from markdown to odoc - transform the "text" *)
990996 let open Parsetree in
991997 let exp =
992998 { pexp_desc = Pexp_constant (Pconst_string (text, None ));
@@ -1730,8 +1736,12 @@ structure_item:
17301736 | let_bindings
17311737 { val_of_let_bindings $ 1 }
17321738 ) { [$ 1 ] }
1733- | located_attributes
1734- { List. map (fun x -> mkstr ~loc: x.loc (Pstr_attribute x.txt)) $ 1 }
1739+ | located_attributes
1740+ {
1741+ List. map
1742+ (fun x -> mkstr ~loc: x.loc (Pstr_attribute (make_floating_doc x.txt)))
1743+ $ 1
1744+ }
17351745;
17361746
17371747module_binding_body:
@@ -1951,7 +1961,9 @@ signature_item:
19511961signature_items:
19521962 | as_loc(signature_item) { [mksig ~loc: $ 1. loc $ 1. txt] }
19531963 | located_attributes
1954- { List. map (fun x -> mksig ~loc: x.loc (Psig_attribute x.txt)) $ 1 }
1964+ { List. map
1965+ (fun x -> mksig ~loc: x.loc (Psig_attribute (make_floating_doc x.txt)))
1966+ $ 1 }
19551967;
19561968
19571969open_declaration:
@@ -2111,7 +2123,9 @@ class_field:
21112123 { mkcf_attrs (Pcf_extension $ 2 ) $ 1 }
21122124 ) { [$ 1 ] }
21132125 | located_attributes
2114- { List. map (fun x -> mkcf ~loc: x.loc (Pcf_attribute x.txt)) $ 1 }
2126+ { List. map
2127+ (fun x -> mkcf ~loc: x.loc (Pcf_attribute (make_floating_doc x.txt)))
2128+ $ 1 }
21152129;
21162130
21172131value:
@@ -2375,7 +2389,9 @@ class_sig_field:
23752389 { mkctf_attrs (Pctf_extension $ 2 ) $ 1 }
23762390 ) { [$ 1 ] }
23772391 | located_attributes
2378- { List. map (fun x -> mkctf ~loc: x.loc (Pctf_attribute x.txt)) $ 1 }
2392+ { List. map
2393+ (fun x -> mkctf ~loc: x.loc (Pctf_attribute (make_floating_doc x.txt)))
2394+ $ 1 }
23792395;
23802396
23812397value_type:
@@ -4983,7 +4999,13 @@ attribute:
49834999 attr_loc = mklocation $ symbolstartpos $ endpos
49845000 }
49855001 }
4986- | DOCSTRING { doc_attr $ 1 (mklocation $ symbolstartpos $ endpos) }
5002+ | DOCSTRING {
5003+ (* Here is where we will make another copy of doc_attr but with
5004+ * reason.doc/text instead of ocaml.doc/text and _that_ is the one that the
5005+ * printer should pay attention to, completely ignoring the ocaml.doc/text
5006+ * ones. The ocaml.doc/text ones would only be received by odoc. *)
5007+ doc_attr $ 1 (mklocation $ symbolstartpos $ endpos)
5008+ }
49875009;
49885010
49895011(* Inlined to avoid having to deal with buggy $symbolstartpos *)
0 commit comments