Skip to content

Remove @ocaml.doc/.text and Docstrings module #6859

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

Merged
merged 3 commits into from
Jul 6, 2024
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
3 changes: 0 additions & 3 deletions jscomp/core/bs_conditional_initial.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

(* Clflags.keep_docs := false; *)
(* default to false -check later*)
(* Clflags.keep_locs := false; *)
let setup_env () =
Env.Persistent_signature.load := Bs_cmi_load.load_cmi;
Matching.make_test_sequence_variant_constant := Polyvar_pattern_match.make_test_sequence_variant_constant;
Expand Down
6 changes: 2 additions & 4 deletions jscomp/gentype/Annotation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ let tag_is_one_of_the_gentype_annotations s =
let tag_is_gentype_ignore_interface s =
s = "genType.ignoreInterface" || s = "gentype.ignoreInterface"

let tag_is_doc s =
match s with
| "ocaml.doc" | "res.doc" -> true
| _ -> false
let tag_is_doc s = s = "res.doc"

let tag_is_intern_local s = s = "internal.local"

let rec get_attribute_payload check_text (attributes : Typedtree.attributes) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export type t = "A" | "B";
/** hello */
export const flat: number = DocstringsJS.flat as any;

/** \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 */
/** * Sign a message with a key.
*
* @param message - A message to be signed
* @param key - The key with which to sign the message
* @returns A signed message */
export const signMessage: (message:string, key:number) => string = DocstringsJS.signMessage as any;

export const one: (a:number) => number = DocstringsJS.one as any;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
@ocaml.doc(" hello ") @genType
/** hello */
@genType
let flat = 34

@ocaml.doc("
/**
* Sign a message with a key.
*
* @param message - A message to be signed
* @param key - The key with which to sign the message
* @returns A signed message
")
*/
@genType
let signMessage = (. message, key) => message ++ string_of_int(key)

Expand Down
77 changes: 30 additions & 47 deletions jscomp/ml/ast_helper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

open Asttypes
open Parsetree
open Docstrings

type lid = Longident.t loc
type str = string loc
Expand Down Expand Up @@ -239,11 +238,6 @@ module Sig = struct

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

module Str = struct
Expand All @@ -262,97 +256,87 @@ module Str = struct
let include_ ?loc a = mk ?loc (Pstr_include a)
let extension ?loc ?(attrs = []) a = mk ?loc (Pstr_extension (a, attrs))
let attribute ?loc a = mk ?loc (Pstr_attribute a)
let text txt =
let f_txt = Ext_list.filter txt (fun ds -> docstring_body ds <> "") in
List.map
(fun ds -> attribute ~loc:(docstring_loc ds) (text_attr ds))
f_txt
end

module Val = struct
let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs)
let mk ?(loc = !default_loc) ?(attrs = [])
?(prim = []) name typ =
{
pval_name = name;
pval_type = typ;
pval_attributes = add_docs_attrs docs attrs;
pval_attributes = attrs;
pval_loc = loc;
pval_prim = prim;
}
end

module Md = struct
let mk ?(loc = !default_loc) ?(attrs = [])
?(docs = empty_docs) ?(text = []) name typ =
name typ =
{
pmd_name = name;
pmd_type = typ;
pmd_attributes =
add_text_attrs text (add_docs_attrs docs attrs);
pmd_attributes = attrs;
pmd_loc = loc;
}
end

module Mtd = struct
let mk ?(loc = !default_loc) ?(attrs = [])
?(docs = empty_docs) ?(text = []) ?typ name =
?typ name =
{
pmtd_name = name;
pmtd_type = typ;
pmtd_attributes =
add_text_attrs text (add_docs_attrs docs attrs);
pmtd_attributes = attrs;
pmtd_loc = loc;
}
end

module Mb = struct
let mk ?(loc = !default_loc) ?(attrs = [])
?(docs = empty_docs) ?(text = []) name expr =
name expr =
{
pmb_name = name;
pmb_expr = expr;
pmb_attributes =
add_text_attrs text (add_docs_attrs docs attrs);
pmb_attributes = attrs;
pmb_loc = loc;
}
end

module Opn = struct
let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs)
let mk ?(loc = !default_loc) ?(attrs = [])
?(override = Fresh) lid =
{
popen_lid = lid;
popen_override = override;
popen_loc = loc;
popen_attributes = add_docs_attrs docs attrs;
popen_attributes = attrs;
}
end

module Incl = struct
let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs) mexpr =
let mk ?(loc = !default_loc) ?(attrs = []) mexpr =
{
pincl_mod = mexpr;
pincl_loc = loc;
pincl_attributes = add_docs_attrs docs attrs;
pincl_attributes = attrs;
}

end

module Vb = struct
let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs)
?(text = []) pat expr =
let mk ?(loc = !default_loc) ?(attrs = [])
pat expr =
{
pvb_pat = pat;
pvb_expr = expr;
pvb_attributes =
add_text_attrs text (add_docs_attrs docs attrs);
pvb_attributes = attrs;
pvb_loc = loc;
}
end

module Type = struct
let mk ?(loc = !default_loc) ?(attrs = [])
?(docs = empty_docs) ?(text = [])
let mk ?(loc = !default_loc) ?(attrs = [])
?(params = [])
?(cstrs = [])
?(kind = Ptype_abstract)
Expand All @@ -366,70 +350,69 @@ module Type = struct
ptype_kind = kind;
ptype_private = priv;
ptype_manifest = manifest;
ptype_attributes =
add_text_attrs text (add_docs_attrs docs attrs);
ptype_attributes = attrs;
ptype_loc = loc;
}

let constructor ?(loc = !default_loc) ?(attrs = []) ?(info = empty_info)
let constructor ?(loc = !default_loc) ?(attrs = [])
?(args = Pcstr_tuple []) ?res name =
{
pcd_name = name;
pcd_args = args;
pcd_res = res;
pcd_loc = loc;
pcd_attributes = add_info_attrs info attrs;
pcd_attributes = attrs;
}

let field ?(loc = !default_loc) ?(attrs = []) ?(info = empty_info)
let field ?(loc = !default_loc) ?(attrs = [])
?(mut = Immutable) name typ =
{
pld_name = name;
pld_mutable = mut;
pld_type = typ;
pld_loc = loc;
pld_attributes = add_info_attrs info attrs;
pld_attributes = attrs;
}

end

(** Type extensions *)
module Te = struct
let mk ?(attrs = []) ?(docs = empty_docs)
let mk ?(attrs = [])
?(params = []) ?(priv = Public) path constructors =
{
ptyext_path = path;
ptyext_params = params;
ptyext_constructors = constructors;
ptyext_private = priv;
ptyext_attributes = add_docs_attrs docs attrs;
ptyext_attributes = attrs;
}

let constructor ?(loc = !default_loc) ?(attrs = [])
?(docs = empty_docs) ?(info = empty_info) name kind =
name kind =
{
pext_name = name;
pext_kind = kind;
pext_loc = loc;
pext_attributes = add_docs_attrs docs (add_info_attrs info attrs);
pext_attributes = attrs;
}

let decl ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs)
?(info = empty_info) ?(args = Pcstr_tuple []) ?res name =
let decl ?(loc = !default_loc) ?(attrs = [])
?(args = Pcstr_tuple []) ?res name =
{
pext_name = name;
pext_kind = Pext_decl(args, res);
pext_loc = loc;
pext_attributes = add_docs_attrs docs (add_info_attrs info attrs);
pext_attributes = attrs;
}

let rebind ?(loc = !default_loc) ?(attrs = [])
?(docs = empty_docs) ?(info = empty_info) name lid =
name lid =
{
pext_name = name;
pext_kind = Pext_rebind lid;
pext_loc = loc;
pext_attributes = add_docs_attrs docs (add_info_attrs info attrs);
pext_attributes = attrs;
}

end
31 changes: 14 additions & 17 deletions jscomp/ml/ast_helper.mli
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
(** Helpers to produce Parsetree fragments *)

open Asttypes
open Docstrings
open Parsetree

type lid = Longident.t loc
Expand Down Expand Up @@ -177,40 +176,40 @@ module Exp:
(** Value declarations *)
module Val:
sig
val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs ->
val mk: ?loc:loc -> ?attrs:attrs ->
?prim:string list -> str -> core_type -> value_description
end

(** Type declarations *)
module Type:
sig
val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text ->
val mk: ?loc:loc -> ?attrs:attrs ->
?params:(core_type * variance) list ->
?cstrs:(core_type * core_type * loc) list ->
?kind:type_kind -> ?priv:private_flag -> ?manifest:core_type -> str ->
type_declaration

val constructor: ?loc:loc -> ?attrs:attrs -> ?info:info ->
val constructor: ?loc:loc -> ?attrs:attrs ->
?args:constructor_arguments -> ?res:core_type -> str ->
constructor_declaration
val field: ?loc:loc -> ?attrs:attrs -> ?info:info ->
val field: ?loc:loc -> ?attrs:attrs ->
?mut:mutable_flag -> str -> core_type -> label_declaration
end

(** Type extensions *)
module Te:
sig
val mk: ?attrs:attrs -> ?docs:docs ->
val mk: ?attrs:attrs ->
?params:(core_type * variance) list -> ?priv:private_flag ->
lid -> extension_constructor list -> type_extension

val constructor: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?info:info ->
val constructor: ?loc:loc -> ?attrs:attrs ->
str -> extension_constructor_kind -> extension_constructor

val decl: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?info:info ->
val decl: ?loc:loc -> ?attrs:attrs ->
?args:constructor_arguments -> ?res:core_type -> str ->
extension_constructor
val rebind: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?info:info ->
val rebind: ?loc:loc -> ?attrs:attrs ->
str -> lid -> extension_constructor
end

Expand Down Expand Up @@ -267,7 +266,6 @@ module Sig:
val include_: ?loc:loc -> include_description -> signature_item
val extension: ?loc:loc -> ?attrs:attrs -> extension -> signature_item
val attribute: ?loc:loc -> attribute -> signature_item
val text: text -> signature_item list
end

(** Structure items *)
Expand All @@ -288,46 +286,45 @@ module Str:
val include_: ?loc:loc -> include_declaration -> structure_item
val extension: ?loc:loc -> ?attrs:attrs -> extension -> structure_item
val attribute: ?loc:loc -> attribute -> structure_item
val text: text -> structure_item list
end

(** Module declarations *)
module Md:
sig
val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text ->
val mk: ?loc:loc -> ?attrs:attrs ->
str -> module_type -> module_declaration
end

(** Module type declarations *)
module Mtd:
sig
val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text ->
val mk: ?loc:loc -> ?attrs:attrs ->
?typ:module_type -> str -> module_type_declaration
end

(** Module bindings *)
module Mb:
sig
val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text ->
val mk: ?loc:loc -> ?attrs:attrs ->
str -> module_expr -> module_binding
end

(** Opens *)
module Opn:
sig
val mk: ?loc: loc -> ?attrs:attrs -> ?docs:docs ->
val mk: ?loc: loc -> ?attrs:attrs ->
?override:override_flag -> lid -> open_description
end

(** Includes *)
module Incl:
sig
val mk: ?loc: loc -> ?attrs:attrs -> ?docs:docs -> 'a -> 'a include_infos
val mk: ?loc: loc -> ?attrs:attrs -> 'a -> 'a include_infos
end

(** Value bindings *)
module Vb:
sig
val mk: ?loc: loc -> ?attrs:attrs -> ?docs:docs -> ?text:text ->
val mk: ?loc: loc -> ?attrs:attrs ->
pattern -> expression -> value_binding
end
1 change: 0 additions & 1 deletion jscomp/ml/clflags.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ end



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


Expand Down
Loading