Skip to content

Use markdown instead of ocamldoc for docblock comment #5095

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 18 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Unescape more stuff
  • Loading branch information
chenglou committed Apr 25, 2021
commit 275fec50586e93ea0f343b51f75796ba2e6c56c0
2 changes: 1 addition & 1 deletion jscomp/others/js_dict.mli
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


type 'a t
(** Dictionary type (ie an '\{ \}' JS object). However it is restricted
(** Dictionary type (ie an '{ }' JS object). However it is restricted
to hold a single type; therefore values must have the same type.

This Dictionary type is mostly used with the `Js_json.t` type. *)
Expand Down
16 changes: 8 additions & 8 deletions jscomp/others/js_float.ml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ external isFinite : float -> bool = "isFinite" [@@bs.val] [@@bs.scope "Number"]

{b Returns} a `string` representing the given value in exponential notation

@raise RangeError if digits is not in the range \`0, 20\` (inclusive)
@raise RangeError if digits is not in the range [0, 20] (inclusive)

@example {[
(* prints "7.71234e+1" *)
Expand All @@ -85,13 +85,13 @@ external toExponential : float -> string = "toExponential" [@@bs.send]
(** Formats a `float` using exponential (scientific) notation

{b digits} specifies how many digits should appear after the decimal point. The
value must be in the range \`0, 20\` (inclusive).
value must be in the range [0, 20] (inclusive).

{b Returns} a `string` representing the given value in exponential notation

The output will be rounded or padded with zeroes if necessary.

@raise RangeError if digits is not in the range \`0, 20\` (inclusive)
@raise RangeError if digits is not in the range [0, 20] (inclusive)

@example {[
(* prints "7.71e+1" *)
Expand All @@ -106,7 +106,7 @@ external toExponentialWithPrecision : float -> digits:int -> string = "toExponen

{b Returns} a `string` representing the given value in fixed-point notation (usually)

@raise RangeError if digits is not in the range \`0, 20\` (inclusive)
@raise RangeError if digits is not in the range [0, 20] (inclusive)

@example {[
(* prints "12346" (note the rounding) *)
Expand All @@ -123,13 +123,13 @@ external toFixed : float -> string = "toFixed" [@@bs.send]
(** Formats a `float` using fixed point notation

{b digits} specifies how many digits should appear after the decimal point. The
value must be in the range \`0, 20\` (inclusive). Defaults to `0`.
value must be in the range [0, 20] (inclusive). Defaults to `0`.

{b Returns} a `string` representing the given value in fixed-point notation (usually)

The output will be rounded or padded with zeroes if necessary.

@raise RangeError if digits is not in the range \`0, 20\` (inclusive)
@raise RangeError if digits is not in the range [0, 20] (inclusive)

@example {[
(* prints "12345.7" (note the rounding) *)
Expand Down Expand Up @@ -212,11 +212,11 @@ external toString : float -> string = "toString" [@@bs.send]
(** Formats a `float` as a string

{b radix} specifies the radix base to use for the formatted number. The
value must be in the range \`2, 36\` (inclusive).
value must be in the range [2, 36] (inclusive).

{b Returns} a `string` representing the given value in fixed-point (usually)

@raise RangeError if radix is not in the range \`2, 36\` (inclusive)
@raise RangeError if radix is not in the range [2, 36] (inclusive)

@example {[
(* prints "110" *)
Expand Down
10 changes: 5 additions & 5 deletions jscomp/others/js_int.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

{b Returns} a `string` representing the given value in exponential notation

@raise RangeError if digits is not in the range \`0, 20\` (inclusive)
@raise RangeError if digits is not in the range [0, 20] (inclusive)

@example {[
(* prints "7.7e+1" *)
Expand All @@ -49,13 +49,13 @@ external toExponential : int -> string = "toExponential" [@@bs.send]
(** Formats an `int` using exponential (scientific) notation

{b digits} specifies how many digits should appear after the decimal point. The
value must be in the range \`0, 20\` (inclusive).
value must be in the range [0, 20] (inclusive).

{b Returns} a `string` representing the given value in exponential notation

The output will be rounded or padded with zeroes if necessary.

@raise RangeError if digits is not in the range \`0, 20\` (inclusive)
@raise RangeError if digits is not in the range [0, 20] (inclusive)

@example {[
(* prints "7.70e+1" *)
Expand Down Expand Up @@ -135,11 +135,11 @@ external toString : int -> string = "toString" [@@bs.send]
(** Formats an `int` as a string

{b radix} specifies the radix base to use for the formatted number. The
value must be in the range \`2, 36\` (inclusive).
value must be in the range [2, 36] (inclusive).

{b Returns} a `string` representing the given value in fixed-point (usually)

@raise RangeError if radix is not in the range \`2, 36\` (inclusive)
@raise RangeError if radix is not in the range [2, 36] (inclusive)

@example {[
(* prints "110" *)
Expand Down
4 changes: 2 additions & 2 deletions jscomp/others/js_math.ml
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ external pow_int : base:int -> exp:int -> int = "pow" [@@bs.val] [@@bs.scope "Ma
(** base to the power of the exponent *)
external pow_float : base:float -> exp:float -> float = "pow" [@@bs.val] [@@bs.scope "Math"]

(** random number in \[0,1) *)
(** random number in [0,1) *)
external random : unit -> float = "random" [@@bs.val] [@@bs.scope "Math"]

(** random number in \[min,max) *)
(** random number in [min,max) *)
let random_int min max =
floor ((random ()) *. (Js_int.toFloat (max - min))) + min

Expand Down
2 changes: 1 addition & 1 deletion jscomp/others/js_obj.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(** Provides functions for inspecting and maniplating native JavaScript objects
*)

(** `empty ()` returns the empty object [\{\}] *)
(** `empty ()` returns the empty object `{}` *)
external empty : unit -> < .. > = "" [@@bs.obj]

(** `assign target source` copies properties from `source` to `target`
Expand Down
8 changes: 4 additions & 4 deletions jscomp/others/js_re.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
(** Provides bindings for JavaScript Regular Expressions

{4 Syntax sugar}
ReScript provides a bit of syntax sugar for regex literals: `\[%re "/foo/g"\]`
ReScript provides a bit of syntax sugar for regex literals: `[%re "/foo/g"]`
will evaluate to a {! t} that can be passed around and used like usual.

{b Note:} This is not an immutable API. A RegExp object with the `global` ("g")
flag set will modify the {! lastIndex} property when the RegExp object is used,
and subsequent uses will ocntinue the search from the previous {! lastIndex}.

@example {[
let maybeMatches = "banana" |> Js.String.match_ \[%re "/na+/g"\]
let maybeMatches = "banana" |> Js.String.match_ [%re "/na+/g"]
]}

@see
Expand Down Expand Up @@ -69,14 +69,14 @@ external input : result -> string = "input" [@@bs.get]

(** Constructs a RegExp object ({! t}) from a string

Regex literals (`\[%re "/.../"\]`) should generally be preferred, but
Regex literals (`[%re "/.../"]`) should generally be preferred, but
`fromString` is very useful when you need to insert a string into a regex.

@example {[
(* A function that extracts the content of the first element with the given tag *)

let contentOf tag xmlString =
Js.Re.fromString ("<" ^ tag ^ ">(.*?)<\\/" ^ tag ^">")
Js.Re.fromString ("<" ^ tag ^ ">(.*?)<\/" ^ tag ^">")
|> Js.Re.exec xmlString
|> function
| Some result -> Js.Nullable.toOption (Js.Re.captures result).(1)
Expand Down
28 changes: 14 additions & 14 deletions jscomp/others/js_string.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ external make : 'a -> t = "String" [@@bs.val]
external fromCharCode : int -> t = "String.fromCharCode" [@@bs.val]

external fromCharCodeMany : int array -> t = "String.fromCharCode" [@@bs.val] [@@bs.splice]
(** `fromCharCodeMany \[|n1;n2;n3|\]` creates a string from the characters corresponding to the given numbers, using the same rules as `fromCharCode`.
(** `fromCharCodeMany [|n1;n2;n3|]` creates a string from the characters corresponding to the given numbers, using the same rules as `fromCharCode`.

@example {[
fromCharCodeMany([|0xd55c, 0xae00, 33|]) = {js|한글!|js};;
Expand All @@ -70,7 +70,7 @@ external fromCharCodeMany : int array -> t = "String.fromCharCode" [@@bs.val] [@
*)
external fromCodePoint : int -> t = "String.fromCodePoint" [@@bs.val] (** ES2015 *)

(** `fromCharCodeMany \[|n1;n2;n3|\]` creates a string from the characters corresponding to the given code point numbers, using the same rules as `fromCodePoint`.
(** `fromCharCodeMany [|n1;n2;n3|]` creates a string from the characters corresponding to the given code point numbers, using the same rules as `fromCodePoint`.

@example {[
fromCodePointMany([|0xd55c; 0xae00; 0x1f63a|]) = {js|한글😺|js}
Expand Down Expand Up @@ -100,7 +100,7 @@ external length : t -> int = "length" [@@bs.get]
*)
external get : t -> int -> t = "" [@@bs.get_index]

(** `charAt n s` gets the character at index `n` within string `s`. If `n` is negative or greater than the length of `s`, returns the empty string. If the string contains characters outside the range [\u0000-\uffff], it will return the first 16-bit value at that position in the string.
(** `charAt n s` gets the character at index `n` within string `s`. If `n` is negative or greater than the length of `s`, returns the empty string. If the string contains characters outside the range `\u0000-\uffff`, it will return the first 16-bit value at that position in the string.

@example {[
charAt 0, "Reason" = "R"
Expand Down Expand Up @@ -270,7 +270,7 @@ external localeCompare : t -> float = "localeCompare" [@@bs.send.pipe: t]
@example {[
match [%re "/b`aeiou`t/"] "The better bats" = Some [|"bet"|]
match [%re "/b`aeiou`t/g"] "The better bats" = Some [|"bet";"bat"|]
match [%re "/(\\d+)-(\\d+)-(\\d+)/"] "Today is 2018-04-05." =
match [%re "/(\d+)-(\d+)-(\d+)/"] "Today is 2018-04-05." =
Some [|"2018-04-05"; "2018"; "04"; "05"|]
match [%re "/b`aeiou`g/"] "The large container." = None
]}
Expand All @@ -280,7 +280,7 @@ external match_ : Js_re.t -> t option array option = "match" [@@bs.send.pipe: t]

(** `normalize str` returns the normalized Unicode string using Normalization Form Canonical (NFC) Composition.

Consider the character `ã`, which can be represented as the single codepoint [\u00e3] or the combination of a lower case letter A [\u0061] and a combining tilde [\u0303]. Normalization ensures that both can be stored in an equivalent binary representation.
Consider the character `ã`, which can be represented as the single codepoint `\u00e3` or the combination of a lower case letter A `\u0061` and a combining tilde `\u0303`. Normalization ensures that both can be stored in an equivalent binary representation.

@see <https://www.unicode.org/reports/tr15/tr15-45.html> Unicode technical report for details
*)
Expand Down Expand Up @@ -329,7 +329,7 @@ have been replaced by `replacement`.

@example {[
replaceByRe [%re "/`aeiou`/g"] "x" "vowels be gone" = "vxwxls bx gxnx"
replaceByRe [%re "/(\\w+) (\\w+)/"] "$2, $1" "Juan Fulano" = "Fulano, Juan"
replaceByRe [%re "/(\w+) (\w+)/"] "$2, $1" "Juan Fulano" = "Fulano, Juan"
]}
*)
external replaceByRe : Js_re.t -> t -> t = "replace" [@@bs.send.pipe: t]
Expand Down Expand Up @@ -361,7 +361,7 @@ the offset at which the match begins, and the whole string being matched.

@example {[
let str = "increment 23"
let re = [%re "/increment (\\d+)/g"]
let re = [%re "/increment (\d+)/g"]
let matchFn matchPart p1 offset wholeString =
wholeString ^ " is " ^ (string_of_int ((int_of_string p1) + 1))

Expand All @@ -381,7 +381,7 @@ the offset at which the match begins, and the whole string being matched.

@example {[
let str = "7 times 6"
let re = [%re "/(\\d+) times (\\d+)/"]
let re = [%re "/(\d+) times (\d+)/"]
let matchFn matchPart p1 p2 offset wholeString =
string_of_int ((int_of_string p1) * (int_of_string p2))

Expand All @@ -406,8 +406,8 @@ external unsafeReplaceBy3 : Js_re.t -> (t -> t -> t -> t -> int -> t -> t [@bs.u
(** `search regexp str` returns the starting position of the first match of `regexp` in the given `str`, or -1 if there is no match.

@example {[
search [%re "/\\d+/"] "testing 1 2 3" = 8;;
search [%re "/\\d+/"] "no numbers" = -1;;
search [%re "/\d+/"] "testing 1 2 3" = 8;;
search [%re "/\d+/"] "no numbers" = -1;;
]}
*)
external search : Js_re.t -> int = "search" [@@bs.send.pipe: t]
Expand Down Expand Up @@ -478,7 +478,7 @@ external splitLimited : t -> int -> t array = "split" [@@bs.send.pipe: t]
array of the resulting substrings.

@example {[
splitByRe [%re "/\\s*[,;]\\s*/"] "art; bed , cog ;dad" = [|Some "art"; Some "bed"; Some "cog"; Some "dad"|];;
splitByRe [%re "/\s*[,;]\s*/"] "art; bed , cog ;dad" = [|Some "art"; Some "bed"; Some "cog"; Some "dad"|];;
splitByRe [%re "/[,;]/"] "has:no:match" = [|Some "has:no:match"|];;
splitByRe [%re "/(#)(:)?/"] "a#b#:c" = [|Some "a"; Some "#"; None; Some "b"; Some "#"; Some ":"; Some "c"|];;
]};
Expand All @@ -490,9 +490,9 @@ external splitByRe : Js_re.t -> t option array = "split" [@@bs.send.pipe: t]
array of the first `n` resulting substrings. If `n` is negative or greater than the number of substrings, the array will contain all the substrings.

@example {[
splitByReAtMost [%re "/\\s*:\\s*/"] ~limit: 3 "one: two: three: four" = [|Some "one"; Some "two"; Some "three"|];;
splitByReAtMost [%re "/\\s*:\\s*/"] ~limit: 0 "one: two: three: four" = [| |];;
splitByReAtMost [%re "/\\s*:\\s*/"] ~limit: 8 "one: two: three: four" = [|Some "one"; Some "two"; Some "three"; Some "four"|];;
splitByReAtMost [%re "/\s*:\s*/"] ~limit: 3 "one: two: three: four" = [|Some "one"; Some "two"; Some "three"|];;
splitByReAtMost [%re "/\s*:\s*/"] ~limit: 0 "one: two: three: four" = [| |];;
splitByReAtMost [%re "/\s*:\s*/"] ~limit: 8 "one: two: three: four" = [|Some "one"; Some "two"; Some "three"; Some "four"|];;
splitByReAtMost [%re "/(#)(:)?/"] ~limit:3 "a#b#:c" = [|Some "a"; Some "#"; None|];;
]};
*)
Expand Down
28 changes: 14 additions & 14 deletions jscomp/others/js_string2.ml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ external make : 'a -> t = "String" [@@bs.val]
external fromCharCode : int -> t = "String.fromCharCode" [@@bs.val]

external fromCharCodeMany : int array -> t = "String.fromCharCode" [@@bs.val] [@@bs.splice]
(** `fromCharCodeMany \[|n1;n2;n3|\]` creates a string from the characters corresponding to the given numbers, using the same rules as `fromCharCode`.
(** `fromCharCodeMany [|n1;n2;n3|]` creates a string from the characters corresponding to the given numbers, using the same rules as `fromCharCode`.

@example {[
fromCharCodeMany([|0xd55c, 0xae00, 33|]) = {js|한글!|js};;
Expand All @@ -68,7 +68,7 @@ external fromCharCodeMany : int array -> t = "String.fromCharCode" [@@bs.val] [@
*)
external fromCodePoint : int -> t = "String.fromCodePoint" [@@bs.val] (** ES2015 *)

(** `fromCharCodeMany \[|n1;n2;n3|\]` creates a string from the characters corresponding to the given code point numbers, using the same rules as `fromCodePoint`.
(** `fromCharCodeMany [|n1;n2;n3|]` creates a string from the characters corresponding to the given code point numbers, using the same rules as `fromCodePoint`.

@example {[
fromCodePointMany([|0xd55c; 0xae00; 0x1f63a|]) = {js|한글😺|js}
Expand Down Expand Up @@ -98,7 +98,7 @@ external length : t -> int = "length" [@@bs.get]
*)
external get : t -> int -> t = "" [@@bs.get_index]

(** `charAt n s` gets the character at index `n` within string `s`. If `n` is negative or greater than the length of `s`, returns the empty string. If the string contains characters outside the range [\u0000-\uffff], it will return the first 16-bit value at that position in the string.
(** `charAt n s` gets the character at index `n` within string `s`. If `n` is negative or greater than the length of `s`, returns the empty string. If the string contains characters outside the range `\u0000-\uffff`, it will return the first 16-bit value at that position in the string.

@example {[
charAt "Reason" 0 = "R"
Expand Down Expand Up @@ -268,7 +268,7 @@ external localeCompare : t -> t -> float = "localeCompare" [@@bs.send]
@example {[
match "The better bats" [%re "/b`aeiou`t/"] = Some [|"bet"|]
match "The better bats" [%re "/b`aeiou`t/g"] = Some [|"bet";"bat"|]
match "Today is 2018-04-05." [%re "/(\\d+)-(\\d+)-(\\d+)/"] = Some [|"2018-04-05"; "2018"; "04"; "05"|]
match "Today is 2018-04-05." [%re "/(\d+)-(\d+)-(\d+)/"] = Some [|"2018-04-05"; "2018"; "04"; "05"|]
match "The large container." [%re "/b`aeiou`g/"] = None
]}

Expand All @@ -277,7 +277,7 @@ external match_ : t -> Js_re.t -> t option array option = "match" [@@bs.send] [@

(** `normalize str` returns the normalized Unicode string using Normalization Form Canonical (NFC) Composition.

Consider the character `ã`, which can be represented as the single codepoint [\u00e3] or the combination of a lower case letter A [\u0061] and a combining tilde [\u0303]. Normalization ensures that both can be stored in an equivalent binary representation.
Consider the character `ã`, which can be represented as the single codepoint `\u00e3` or the combination of a lower case letter A `\u0061` and a combining tilde `\u0303`. Normalization ensures that both can be stored in an equivalent binary representation.

@see <https://www.unicode.org/reports/tr15/tr15-45.html> Unicode technical report for details
*)
Expand Down Expand Up @@ -326,7 +326,7 @@ have been replaced by `replacement`.

@example {[
replaceByRe "vowels be gone" [%re "/`aeiou`/g"] "x" = "vxwxls bx gxnx"
replaceByRe "Juan Fulano" [%re "/(\\w+) (\\w+)/"] "$2, $1" = "Fulano, Juan"
replaceByRe "Juan Fulano" [%re "/(\w+) (\w+)/"] "$2, $1" = "Fulano, Juan"
]}
*)
external replaceByRe : t -> Js_re.t -> t -> t = "replace" [@@bs.send]
Expand Down Expand Up @@ -358,7 +358,7 @@ the offset at which the match begins, and the whole string being matched.

@example {[
let str = "increment 23"
let re = [%re "/increment (\\d+)/g"]
let re = [%re "/increment (\d+)/g"]
let matchFn matchPart p1 offset wholeString =
wholeString ^ " is " ^ (string_of_int ((int_of_string p1) + 1))

Expand All @@ -378,7 +378,7 @@ the offset at which the match begins, and the whole string being matched.

@example {[
let str = "7 times 6"
let re = [%re "/(\\d+) times (\\d+)/"]
let re = [%re "/(\d+) times (\d+)/"]
let matchFn matchPart p1 p2 offset wholeString =
string_of_int ((int_of_string p1) * (int_of_string p2))

Expand All @@ -403,8 +403,8 @@ external unsafeReplaceBy3 : t -> Js_re.t -> (t -> t -> t -> t -> int -> t -> t [
(** `search regexp str` returns the starting position of the first match of `regexp` in the given `str`, or -1 if there is no match.

@example {[
search "testing 1 2 3" [%re "/\\d+/"] = 8;;
search "no numbers" [%re "/\\d+/"] = -1;;
search "testing 1 2 3" [%re "/\d+/"] = 8;;
search "no numbers" [%re "/\d+/"] = -1;;
]}
*)
external search : t -> Js_re.t -> int = "search" [@@bs.send]
Expand Down Expand Up @@ -469,7 +469,7 @@ external splitAtMost: t -> t -> limit:int -> t array = "split" [@@bs.send]
array of the resulting substrings.

@example {[
splitByRe "art; bed , cog ;dad" [%re "/\\s*[,;]\\s*/"] = [|"art"; "bed"; "cog"; "dad"|];;
splitByRe "art; bed , cog ;dad" [%re "/\s*[,;]\s*/"] = [|"art"; "bed"; "cog"; "dad"|];;
splitByRe "has:no:match" [%re "/[,;]/"] = [|"has:no:match"|];;
]};
*)
Expand All @@ -480,9 +480,9 @@ external splitByRe : t -> Js_re.t -> t option array = "split" [@@bs.send]
array of the first `n` resulting substrings. If `n` is negative or greater than the number of substrings, the array will contain all the substrings.

@example {[
splitByReAtMost "one: two: three: four" [%re "/\\s*:\\s*/"] ~limit: 3 = [|"one"; "two"; "three"|];;
splitByReAtMost "one: two: three: four" [%re "/\\s*:\\s*/"] ~limit: 0 = [| |];;
splitByReAtMost "one: two: three: four" [%re "/\\s*:\\s*/"] ~limit: 8 = [|"one"; "two"; "three"; "four"|];;
splitByReAtMost "one: two: three: four" [%re "/\s*:\s*/"] ~limit: 3 = [|"one"; "two"; "three"|];;
splitByReAtMost "one: two: three: four" [%re "/\s*:\s*/"] ~limit: 0 = [| |];;
splitByReAtMost "one: two: three: four" [%re "/\s*:\s*/"] ~limit: 8 = [|"one"; "two"; "three"; "four"|];;
]};
*)
external splitByReAtMost : t -> Js_re.t -> limit:int -> t option array = "split" [@@bs.send]
Expand Down