Skip to content

Commit 3238452

Browse files
authored
Remove @ocaml.doc/.text and Docstrings module (#6859)
* Remove @ocaml.doc/.text and Docstrings module * Fix another remaining @ocaml.text * Fix gentype test
1 parent 13e39a0 commit 3238452

File tree

12 files changed

+58
-596
lines changed

12 files changed

+58
-596
lines changed

jscomp/core/bs_conditional_initial.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
(* Clflags.keep_docs := false; *)
26-
(* default to false -check later*)
27-
(* Clflags.keep_locs := false; *)
2825
let setup_env () =
2926
Env.Persistent_signature.load := Bs_cmi_load.load_cmi;
3027
Matching.make_test_sequence_variant_constant := Polyvar_pattern_match.make_test_sequence_variant_constant;

jscomp/gentype/Annotation.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ let tag_is_one_of_the_gentype_annotations s =
3636
let tag_is_gentype_ignore_interface s =
3737
s = "genType.ignoreInterface" || s = "gentype.ignoreInterface"
3838

39-
let tag_is_doc s =
40-
match s with
41-
| "ocaml.doc" | "res.doc" -> true
42-
| _ -> false
39+
let tag_is_doc s = s = "res.doc"
40+
4341
let tag_is_intern_local s = s = "internal.local"
4442

4543
let rec get_attribute_payload check_text (attributes : Typedtree.attributes) =

jscomp/gentype_tests/typescript-react-example/src/Docstrings.gen.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ export type t = "A" | "B";
1010
/** hello */
1111
export const flat: number = DocstringsJS.flat as any;
1212

13-
/** \n * Sign a message with a key.\n *\n * @param message - A message to be signed\n * @param key - The key with which to sign the message\n * @returns A signed message\n */
13+
/** * Sign a message with a key.
14+
*
15+
* @param message - A message to be signed
16+
* @param key - The key with which to sign the message
17+
* @returns A signed message */
1418
export const signMessage: (message:string, key:number) => string = DocstringsJS.signMessage as any;
1519

1620
export const one: (a:number) => number = DocstringsJS.one as any;

jscomp/gentype_tests/typescript-react-example/src/Docstrings.res

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
@ocaml.doc(" hello ") @genType
1+
/** hello */
2+
@genType
23
let flat = 34
34

4-
@ocaml.doc("
5+
/**
56
* Sign a message with a key.
67
*
78
* @param message - A message to be signed
89
* @param key - The key with which to sign the message
910
* @returns A signed message
10-
")
11+
*/
1112
@genType
1213
let signMessage = (. message, key) => message ++ string_of_int(key)
1314

jscomp/ml/ast_helper.ml

Lines changed: 30 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
open Asttypes
1919
open Parsetree
20-
open Docstrings
2120

2221
type lid = Longident.t loc
2322
type str = string loc
@@ -239,11 +238,6 @@ module Sig = struct
239238

240239
let extension ?loc ?(attrs = []) a = mk ?loc (Psig_extension (a, attrs))
241240
let attribute ?loc a = mk ?loc (Psig_attribute a)
242-
let text txt =
243-
let f_txt = Ext_list.filter txt (fun ds -> docstring_body ds <> "") in
244-
List.map
245-
(fun ds -> attribute ~loc:(docstring_loc ds) (text_attr ds))
246-
f_txt
247241
end
248242

249243
module Str = struct
@@ -262,97 +256,87 @@ module Str = struct
262256
let include_ ?loc a = mk ?loc (Pstr_include a)
263257
let extension ?loc ?(attrs = []) a = mk ?loc (Pstr_extension (a, attrs))
264258
let attribute ?loc a = mk ?loc (Pstr_attribute a)
265-
let text txt =
266-
let f_txt = Ext_list.filter txt (fun ds -> docstring_body ds <> "") in
267-
List.map
268-
(fun ds -> attribute ~loc:(docstring_loc ds) (text_attr ds))
269-
f_txt
270259
end
271260

272261
module Val = struct
273-
let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs)
262+
let mk ?(loc = !default_loc) ?(attrs = [])
274263
?(prim = []) name typ =
275264
{
276265
pval_name = name;
277266
pval_type = typ;
278-
pval_attributes = add_docs_attrs docs attrs;
267+
pval_attributes = attrs;
279268
pval_loc = loc;
280269
pval_prim = prim;
281270
}
282271
end
283272

284273
module Md = struct
285274
let mk ?(loc = !default_loc) ?(attrs = [])
286-
?(docs = empty_docs) ?(text = []) name typ =
275+
name typ =
287276
{
288277
pmd_name = name;
289278
pmd_type = typ;
290-
pmd_attributes =
291-
add_text_attrs text (add_docs_attrs docs attrs);
279+
pmd_attributes = attrs;
292280
pmd_loc = loc;
293281
}
294282
end
295283

296284
module Mtd = struct
297285
let mk ?(loc = !default_loc) ?(attrs = [])
298-
?(docs = empty_docs) ?(text = []) ?typ name =
286+
?typ name =
299287
{
300288
pmtd_name = name;
301289
pmtd_type = typ;
302-
pmtd_attributes =
303-
add_text_attrs text (add_docs_attrs docs attrs);
290+
pmtd_attributes = attrs;
304291
pmtd_loc = loc;
305292
}
306293
end
307294

308295
module Mb = struct
309296
let mk ?(loc = !default_loc) ?(attrs = [])
310-
?(docs = empty_docs) ?(text = []) name expr =
297+
name expr =
311298
{
312299
pmb_name = name;
313300
pmb_expr = expr;
314-
pmb_attributes =
315-
add_text_attrs text (add_docs_attrs docs attrs);
301+
pmb_attributes = attrs;
316302
pmb_loc = loc;
317303
}
318304
end
319305

320306
module Opn = struct
321-
let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs)
307+
let mk ?(loc = !default_loc) ?(attrs = [])
322308
?(override = Fresh) lid =
323309
{
324310
popen_lid = lid;
325311
popen_override = override;
326312
popen_loc = loc;
327-
popen_attributes = add_docs_attrs docs attrs;
313+
popen_attributes = attrs;
328314
}
329315
end
330316

331317
module Incl = struct
332-
let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs) mexpr =
318+
let mk ?(loc = !default_loc) ?(attrs = []) mexpr =
333319
{
334320
pincl_mod = mexpr;
335321
pincl_loc = loc;
336-
pincl_attributes = add_docs_attrs docs attrs;
322+
pincl_attributes = attrs;
337323
}
338324

339325
end
340326

341327
module Vb = struct
342-
let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs)
343-
?(text = []) pat expr =
328+
let mk ?(loc = !default_loc) ?(attrs = [])
329+
pat expr =
344330
{
345331
pvb_pat = pat;
346332
pvb_expr = expr;
347-
pvb_attributes =
348-
add_text_attrs text (add_docs_attrs docs attrs);
333+
pvb_attributes = attrs;
349334
pvb_loc = loc;
350335
}
351336
end
352337

353338
module Type = struct
354-
let mk ?(loc = !default_loc) ?(attrs = [])
355-
?(docs = empty_docs) ?(text = [])
339+
let mk ?(loc = !default_loc) ?(attrs = [])
356340
?(params = [])
357341
?(cstrs = [])
358342
?(kind = Ptype_abstract)
@@ -366,70 +350,69 @@ module Type = struct
366350
ptype_kind = kind;
367351
ptype_private = priv;
368352
ptype_manifest = manifest;
369-
ptype_attributes =
370-
add_text_attrs text (add_docs_attrs docs attrs);
353+
ptype_attributes = attrs;
371354
ptype_loc = loc;
372355
}
373356

374-
let constructor ?(loc = !default_loc) ?(attrs = []) ?(info = empty_info)
357+
let constructor ?(loc = !default_loc) ?(attrs = [])
375358
?(args = Pcstr_tuple []) ?res name =
376359
{
377360
pcd_name = name;
378361
pcd_args = args;
379362
pcd_res = res;
380363
pcd_loc = loc;
381-
pcd_attributes = add_info_attrs info attrs;
364+
pcd_attributes = attrs;
382365
}
383366

384-
let field ?(loc = !default_loc) ?(attrs = []) ?(info = empty_info)
367+
let field ?(loc = !default_loc) ?(attrs = [])
385368
?(mut = Immutable) name typ =
386369
{
387370
pld_name = name;
388371
pld_mutable = mut;
389372
pld_type = typ;
390373
pld_loc = loc;
391-
pld_attributes = add_info_attrs info attrs;
374+
pld_attributes = attrs;
392375
}
393376

394377
end
395378

396379
(** Type extensions *)
397380
module Te = struct
398-
let mk ?(attrs = []) ?(docs = empty_docs)
381+
let mk ?(attrs = [])
399382
?(params = []) ?(priv = Public) path constructors =
400383
{
401384
ptyext_path = path;
402385
ptyext_params = params;
403386
ptyext_constructors = constructors;
404387
ptyext_private = priv;
405-
ptyext_attributes = add_docs_attrs docs attrs;
388+
ptyext_attributes = attrs;
406389
}
407390

408391
let constructor ?(loc = !default_loc) ?(attrs = [])
409-
?(docs = empty_docs) ?(info = empty_info) name kind =
392+
name kind =
410393
{
411394
pext_name = name;
412395
pext_kind = kind;
413396
pext_loc = loc;
414-
pext_attributes = add_docs_attrs docs (add_info_attrs info attrs);
397+
pext_attributes = attrs;
415398
}
416399

417-
let decl ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs)
418-
?(info = empty_info) ?(args = Pcstr_tuple []) ?res name =
400+
let decl ?(loc = !default_loc) ?(attrs = [])
401+
?(args = Pcstr_tuple []) ?res name =
419402
{
420403
pext_name = name;
421404
pext_kind = Pext_decl(args, res);
422405
pext_loc = loc;
423-
pext_attributes = add_docs_attrs docs (add_info_attrs info attrs);
406+
pext_attributes = attrs;
424407
}
425408

426409
let rebind ?(loc = !default_loc) ?(attrs = [])
427-
?(docs = empty_docs) ?(info = empty_info) name lid =
410+
name lid =
428411
{
429412
pext_name = name;
430413
pext_kind = Pext_rebind lid;
431414
pext_loc = loc;
432-
pext_attributes = add_docs_attrs docs (add_info_attrs info attrs);
415+
pext_attributes = attrs;
433416
}
434417

435418
end

jscomp/ml/ast_helper.mli

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
(** Helpers to produce Parsetree fragments *)
1717

1818
open Asttypes
19-
open Docstrings
2019
open Parsetree
2120

2221
type lid = Longident.t loc
@@ -177,40 +176,40 @@ module Exp:
177176
(** Value declarations *)
178177
module Val:
179178
sig
180-
val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs ->
179+
val mk: ?loc:loc -> ?attrs:attrs ->
181180
?prim:string list -> str -> core_type -> value_description
182181
end
183182

184183
(** Type declarations *)
185184
module Type:
186185
sig
187-
val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text ->
186+
val mk: ?loc:loc -> ?attrs:attrs ->
188187
?params:(core_type * variance) list ->
189188
?cstrs:(core_type * core_type * loc) list ->
190189
?kind:type_kind -> ?priv:private_flag -> ?manifest:core_type -> str ->
191190
type_declaration
192191

193-
val constructor: ?loc:loc -> ?attrs:attrs -> ?info:info ->
192+
val constructor: ?loc:loc -> ?attrs:attrs ->
194193
?args:constructor_arguments -> ?res:core_type -> str ->
195194
constructor_declaration
196-
val field: ?loc:loc -> ?attrs:attrs -> ?info:info ->
195+
val field: ?loc:loc -> ?attrs:attrs ->
197196
?mut:mutable_flag -> str -> core_type -> label_declaration
198197
end
199198

200199
(** Type extensions *)
201200
module Te:
202201
sig
203-
val mk: ?attrs:attrs -> ?docs:docs ->
202+
val mk: ?attrs:attrs ->
204203
?params:(core_type * variance) list -> ?priv:private_flag ->
205204
lid -> extension_constructor list -> type_extension
206205

207-
val constructor: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?info:info ->
206+
val constructor: ?loc:loc -> ?attrs:attrs ->
208207
str -> extension_constructor_kind -> extension_constructor
209208

210-
val decl: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?info:info ->
209+
val decl: ?loc:loc -> ?attrs:attrs ->
211210
?args:constructor_arguments -> ?res:core_type -> str ->
212211
extension_constructor
213-
val rebind: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?info:info ->
212+
val rebind: ?loc:loc -> ?attrs:attrs ->
214213
str -> lid -> extension_constructor
215214
end
216215

@@ -267,7 +266,6 @@ module Sig:
267266
val include_: ?loc:loc -> include_description -> signature_item
268267
val extension: ?loc:loc -> ?attrs:attrs -> extension -> signature_item
269268
val attribute: ?loc:loc -> attribute -> signature_item
270-
val text: text -> signature_item list
271269
end
272270

273271
(** Structure items *)
@@ -288,46 +286,45 @@ module Str:
288286
val include_: ?loc:loc -> include_declaration -> structure_item
289287
val extension: ?loc:loc -> ?attrs:attrs -> extension -> structure_item
290288
val attribute: ?loc:loc -> attribute -> structure_item
291-
val text: text -> structure_item list
292289
end
293290

294291
(** Module declarations *)
295292
module Md:
296293
sig
297-
val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text ->
294+
val mk: ?loc:loc -> ?attrs:attrs ->
298295
str -> module_type -> module_declaration
299296
end
300297

301298
(** Module type declarations *)
302299
module Mtd:
303300
sig
304-
val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text ->
301+
val mk: ?loc:loc -> ?attrs:attrs ->
305302
?typ:module_type -> str -> module_type_declaration
306303
end
307304

308305
(** Module bindings *)
309306
module Mb:
310307
sig
311-
val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text ->
308+
val mk: ?loc:loc -> ?attrs:attrs ->
312309
str -> module_expr -> module_binding
313310
end
314311

315312
(** Opens *)
316313
module Opn:
317314
sig
318-
val mk: ?loc: loc -> ?attrs:attrs -> ?docs:docs ->
315+
val mk: ?loc: loc -> ?attrs:attrs ->
319316
?override:override_flag -> lid -> open_description
320317
end
321318

322319
(** Includes *)
323320
module Incl:
324321
sig
325-
val mk: ?loc: loc -> ?attrs:attrs -> ?docs:docs -> 'a -> 'a include_infos
322+
val mk: ?loc: loc -> ?attrs:attrs -> 'a -> 'a include_infos
326323
end
327324

328325
(** Value bindings *)
329326
module Vb:
330327
sig
331-
val mk: ?loc: loc -> ?attrs:attrs -> ?docs:docs -> ?text:text ->
328+
val mk: ?loc: loc -> ?attrs:attrs ->
332329
pattern -> expression -> value_binding
333330
end

jscomp/ml/clflags.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ end
4141

4242

4343

44-
let keep_docs = ref false (* -keep-docs *)
4544
let keep_locs = ref true (* -keep-locs *)
4645

4746

0 commit comments

Comments
 (0)