Skip to content

Commit 7fe04fb

Browse files
committed
fix docstrings examples
1 parent 3c4f07d commit 7fe04fb

12 files changed

+194
-187
lines changed

src/Core__Console.resi

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ external assert2: (bool, 'a, 'b) => unit = "console.assert"
4040
4141
```rescript
4242
Console.assert3(false, "Hello", "World", "ReScript")
43-
Console.assert3(n == 42, "One", 2, #3)
43+
Console.assert3(42 == 42, "One", 2, #3)
4444
```
4545
*/
4646
@val
@@ -52,8 +52,9 @@ external assert3: (bool, 'a, 'b, 'c) => unit = "console.assert"
5252
## Examples
5353
5454
```rescript
55+
let value = 42
5556
Console.assert4(false, "Hello", "World", "ReScript", "!!!")
56-
Console.assert4(m == 42, [1, 2], (3, 4), [#5, #6], #"polyvar")
57+
Console.assert4(value == 42, [1, 2], (3, 4), [#5, #6], #"polyvar")
5758
```
5859
*/
5960
@val
@@ -65,8 +66,9 @@ external assert4: (bool, 'a, 'b, 'c, 'd) => unit = "console.assert"
6566
## Examples
6667
6768
```rescript
69+
let value = 42
6870
Console.assert5(false, "Hello", "World", "JS", '!', '!')
69-
Console.assert5(n == 42, [1, 2], (3, 4), [#5, #6], #"polyvar", {"name": "ReScript"})
71+
Console.assert5(value == 42, [1, 2], (3, 4), [#5, #6], #"polyvar", {"name": "ReScript"})
7072
```
7173
*/
7274
@val
@@ -78,8 +80,9 @@ external assert5: (bool, 'a, 'b, 'c, 'd, 'e) => unit = "console.assert"
7880
## Examples
7981
8082
```rescript
83+
let value = 42
8184
Console.assert6(false, "Hello", "World", "JS", '!', '!', '?')
82-
Console.assert6(n == 42, [1, 2], (3, 4), [#5, #6], #"polyvar", {"name": "ReScript"}, 42)
85+
Console.assert6(value == 42, [1, 2], (3, 4), [#5, #6], #"polyvar", {"name": "ReScript"}, 42)
8386
```
8487
*/
8588
@val
@@ -91,8 +94,9 @@ external assert6: (bool, 'a, 'b, 'c, 'd, 'e, 'f) => unit = "console.assert"
9194
## Examples
9295
9396
```rescript
97+
let value = 42
9498
Console.assertMany(false, ["Hello", "World"])
95-
Console.assertMany(n == 42, [1, 2, 3])
99+
Console.assertMany(value == 42, [1, 2, 3])
96100
```
97101
*/
98102
@val
@@ -249,7 +253,7 @@ on MDN.
249253
## Examples
250254
251255
```rescript
252-
Console.dir({"language": "rescript", "version": 10.1.2})
256+
Console.dir({"language": "rescript", "version": "10.1.2"})
253257
```
254258
*/
255259
@val
@@ -325,7 +329,7 @@ external error4: ('a, 'b, 'c, 'd) => unit = "console.error"
325329
## Examples
326330
327331
```rescript
328-
Console.error5('e', 'r, 'r', 'o', 'r')
332+
Console.error5('e', 'r', 'r', 'o', 'r')
329333
Console.error5(1, #second, #third, ("fourth"), 'c')
330334
```
331335
*/
@@ -597,7 +601,7 @@ on MDN.
597601
## Examples
598602
599603
```rescript
600-
Console.table({"language": "rescript", "version": 10.1.2})
604+
Console.table({"language": "rescript", "version": "10.1.2"})
601605
```
602606
*/
603607
@val

src/Core__Error.resi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ See [`Error.prototype.stack`](https://developer.mozilla.org/en-US/docs/Web/JavaS
2828
2929
## Example
3030
```rescript
31-
Console.log(someError->Error.stack) // Logs `stack` if it exists on `someError`
31+
let error = Error.make("error")
32+
Console.log(error->Error.stack) // Logs `stack` if it exists on `someError`
3233
```
3334
*/
3435
@get

src/Core__Float.resi

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ See [`parseFloat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refer
153153
```rescript
154154
Float.parseFloat("1.0") // 1.0
155155
Float.parseFloat(" 3.14 ") // 3.14
156-
Float.parseFloat(3.0) // 3.0
156+
Float.parseFloat("3.0") // 3.0
157157
Float.parseFloat("3.14some non-digit characters") // 3.14
158158
Float.parseFloat("error")->Float.isNaN // true
159159
```
@@ -190,10 +190,10 @@ See [`parseInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referen
190190
## Examples
191191
192192
```rescript
193-
Float.parseInt("10.0", ~radix=2) // 2.0
194-
Float.parseInt("15 * 3", ~radix=10) // 15.0
195-
Float.parseInt("12", ~radix=13) // 15.0
196-
Float.parseInt("17", ~radix=40)->Float.isNaN // true
193+
Float.parseIntWithRadix("10.0", ~radix=2) // 2.0
194+
Float.parseIntWithRadix("15 * 3", ~radix=10) // 15.0
195+
Float.parseIntWithRadix("12", ~radix=13) // 15.0
196+
Float.parseIntWithRadix("17", ~radix=40)->Float.isNaN // true
197197
```
198198
*/
199199
@val
@@ -258,8 +258,8 @@ See [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/R
258258
## Examples
259259
260260
```rescript
261-
Float.toFixed(300.0, ~digits=4) // "300.0000"
262-
Float.toFixed(300.0, ~digits=1) // "300.0"
261+
Float.toFixedWithPrecision(300.0, ~digits=4) // "300.0000"
262+
Float.toFixedWithPrecision(300.0, ~digits=1) // "300.0"
263263
```
264264
265265
## Exceptions
@@ -286,15 +286,15 @@ Float.toPrecision(1.0) // "1"
286286
external toPrecision: float => string = "toPrecision"
287287

288288
/**
289-
`toPrecision(v, ~digits)` return a `string` representing the giver value with
289+
`toPrecisionWithPrecision(v, ~digits)` return a `string` representing the giver value with
290290
precision. `digits` specifies the number of significant digits.
291291
See [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.
292292
293293
## Examples
294294
295295
```rescript
296-
Float.toPrecision(100.0, ~digits=2) // "1.0e+2"
297-
Float.toPrecision(1.0) // "1.0"
296+
Float.toPrecisionWithPrecision(100.0, ~digits=2) // "1.0e+2"
297+
Float.toPrecisionWithPrecision(1.0, ~digits=1) // "1"
298298
```
299299
300300
## Exceptions
@@ -329,8 +329,8 @@ See [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/
329329
## Examples
330330
331331
```rescript
332-
Float.toString(6.0, ~radix=2) // "110"
333-
Float.toString(3735928559.0, ~radix=16) // "deadbeef"
332+
Float.toStringWithRadix(6.0, ~radix=2) // "110"
333+
Float.toStringWithRadix(3735928559.0, ~radix=16) // "deadbeef"
334334
Float.toStringWithRadix(123456.0, ~radix=36) // "2n9c"
335335
```
336336
@@ -350,10 +350,10 @@ See [`Number.toLocaleString`](https://developer.mozilla.org/en-US/docs/Web/JavaS
350350
351351
```rescript
352352
// If the application uses English as the default language
353-
Int.toLocaleString(1000.0) // "1,000"
353+
Float.toLocaleString(1000.0) // "1,000"
354354
355355
// If the application uses Portuguese Brazil as the default language
356-
Int.toLocaleString(1000.0) // "1.000"
356+
Float.toLocaleString(1000.0) // "1.000"
357357
```
358358
*/
359359
@send
@@ -404,7 +404,7 @@ external fromInt: int => float = "%identity"
404404
## Examples
405405
406406
```rescript
407-
Int.mod(7.0, 4.0) == 3
407+
Float.mod(7.0, 4.0) == 3
408408
```
409409
*/
410410
external mod: (float, float) => float = "?fmod_float"
@@ -417,10 +417,10 @@ if `max` < `min` returns `min`.
417417
## Examples
418418
419419
```rescript
420-
Int.clamp(4.2) == 4.2
421-
Int.clamp(4.2, ~min=4.3) == 4.3
422-
Int.clamp(4.2, ~max=4.1) == 4.1
423-
Int.clamp(4.2, ~min=4.3, ~max=4.1) == 4.3
420+
Float.clamp(4.2) == 4.2
421+
Float.clamp(4.2, ~min=4.3) == 4.3
422+
Float.clamp(4.2, ~max=4.1) == 4.1
423+
Float.clamp(4.2, ~min=4.3, ~max=4.1) == 4.3
424424
```
425425
*/
426426
let clamp: (~min: float=?, ~max: float=?, float) => float

src/Core__Int.resi

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ on MDN.
121121
## Examples
122122
123123
```rescript
124-
Int.toFixed(300, ~digits=4) // "300.0000"
125-
Int.toFixed(300, ~digits=1) // "300.0"
124+
Int.toFixedWithPrecision(300, ~digits=4) // "300.0000"
125+
Int.toFixedWithPrecision(300, ~digits=1) // "300.0"
126126
```
127127
128128
## Exceptions
@@ -148,14 +148,14 @@ Int.toPrecision(1) // "1"
148148
external toPrecision: int => string = "toPrecision"
149149

150150
/**
151-
`toPrecision(n, ~digits)` return a `string` representing the giver value with
151+
`toPrecisionWithPrecision(n, ~digits)` return a `string` representing the giver value with
152152
precision. `digits` specifies the number of significant digits. See [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN.
153153
154154
## Examples
155155
156156
```rescript
157-
Int.toPrecision(100, ~digits=2) // "1.0e+2"
158-
Int.toPrecision(1) // "1.0"
157+
Int.toPrecisionWithPrecision(100, ~digits=2) // "1.0e+2"
158+
Int.toPrecisionWithPrecision(1) // "1.0"
159159
```
160160
161161
## Exceptions
@@ -192,8 +192,8 @@ on MDN.
192192
## Examples
193193
194194
```rescript
195-
Int.toString(6, ~radix=2) // "110"
196-
Int.toString(3735928559, ~radix=16) // "deadbeef"
195+
Int.toStringWithRadix(6, ~radix=2) // "110"
196+
Int.toStringWithRadix(373592855, ~radix=16) // "16449317"
197197
Int.toStringWithRadix(123456, ~radix=36) // "2n9c"
198198
```
199199

src/Core__JSON.resi

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ try {
2929
let _ = JSON.parseExn("")
3030
// error
3131
} catch {
32-
| Exn.Error(obj) => Console.log("error")
32+
| Exn.Error(_) => Console.log("error")
3333
}
3434
```
3535
@@ -50,7 +50,7 @@ It returns a JSON type.
5050
5151
## Examples
5252
```rescript
53-
let reviver = (key, value) => {
53+
let reviver = (_, value) => {
5454
let valueType = JSON.Classify.classify(value)
5555
5656
switch valueType {
@@ -145,7 +145,7 @@ let json =
145145
("someNumber", JSON.Encode.int(42)),
146146
])->JSON.Encode.object
147147
148-
let replacer = (key, value) => {
148+
let replacer = (_, value) => {
149149
let decodedValue = value->JSON.Decode.string
150150
151151
switch decodedValue {
@@ -162,7 +162,7 @@ JSON.stringifyWithReplacer(json, replacer)
162162
external stringifyWithReplacer: (t, (string, t) => t) => string = "JSON.stringify"
163163

164164
/**
165-
`stringifyWithReplacerAndIndent(json, replacer, indentation)`
165+
`stringifyWithReplacerAndIndent(json, replacer, indentation)`
166166
167167
Converts a JSON object to a JSON string. The output will be indented.
168168
The replacer describes how the value should be transformed. It is a function which receives a key and a value.
@@ -177,7 +177,7 @@ let json =
177177
("someNumber", JSON.Encode.int(42)),
178178
])->JSON.Encode.object
179179
180-
let replacer = (key, value) => {
180+
let replacer = (_, value) => {
181181
let decodedValue = value->JSON.Decode.string
182182
183183
switch decodedValue {
@@ -188,10 +188,10 @@ let replacer = (key, value) => {
188188
189189
JSON.stringifyWithReplacerAndIndent(json, replacer, 2)
190190
// {
191-
"foo": "BAR",
192-
"hello": "WORLD",
193-
"someNumber": 42
194-
}
191+
// "foo": "BAR",
192+
// "hello": "WORLD",
193+
// "someNumber": 42
194+
// }
195195
```
196196
*/
197197
@val
@@ -321,7 +321,7 @@ BigInt.fromInt(0)->JSON.stringifyAny
321321
external stringifyAnyWithIndent: ('a, @as(json`null`) _, int) => option<string> = "JSON.stringify"
322322

323323
/**
324-
`stringifyAnyWithReplacer(json, replacer)`
324+
`stringifyAnyWithReplacer(json, replacer)`
325325
326326
Converts any type to a JSON string.
327327
The replacer describes how the value should be transformed. It is a function which receives a key and a value.
@@ -337,7 +337,7 @@ let dict = Dict.fromArray([
337337
("someNumber", JSON.Encode.int(42)),
338338
])
339339
340-
let replacer = (key, value) => {
340+
let replacer = (_, value) => {
341341
let decodedValue = value->JSON.Decode.string
342342
343343
switch decodedValue {
@@ -382,7 +382,7 @@ let dict = Dict.fromArray([
382382
("someNumber", JSON.Encode.int(42)),
383383
])
384384
385-
let replacer = (key, value) => {
385+
let replacer = (_, value) => {
386386
let decodedValue = value->JSON.Decode.string
387387
388388
switch decodedValue {

src/Core__List.resi

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -645,15 +645,11 @@ zero for all `list1` and `list2`.
645645
## Examples
646646
647647
```rescript
648-
List.compare(list{3}, list{3, 7}, (a, b) => compare(a, b)) /* (-1.) */
649-
650-
List.compare(list{5, 3}, list{5}, (a, b) => compare(a, b)) /* 1. */
651-
652-
List.compare(list{1, 3, 5}, list{1, 4, 2}, (a, b) => compare(a, b)) /* (-1.) */
653-
654-
List.compare(list{1, 3, 5}, list{1, 2, 3}, (a, b) => compare(a, b)) /* 1. */
655-
656-
List.compare(list{1, 3, 5}, list{1, 3, 5}, (a, b) => compare(a, b)) /* 0. */
648+
List.compare(list{3}, list{3, 7}, (a, b) => Int.compare(a, b)) // -1.
649+
List.compare(list{5, 3}, list{5}, (a, b) => Int.compare(a, b)) // 1.
650+
List.compare(list{1, 3, 5}, list{1, 4, 2}, (a, b) => Int.compare(a, b)) // -1.
651+
List.compare(list{1, 3, 5}, list{1, 2, 3}, (a, b) => Int.compare(a, b)) // 1.
652+
List.compare(list{1, 3, 5}, list{1, 3, 5}, (a, b) => Int.compare(a, b)) // 0.
657653
```
658654
659655
**Please note:** The total ordering of List is different from Array,

0 commit comments

Comments
 (0)