Skip to content

Commit 6dd6465

Browse files
authored
Pretty docstrings (#6417)
* add metatag rescript codeblocks * remove deprecated attr to js_promise.res * remove deprecated attr from docstrings * update * remove deprecated comments * add header * dedent comments * fixes * fixes * last edits * update js_math.ml * update CHANGELOG.md * more polish * update CHANGELOG.md * restore release.ninja * restore release.ninja * [skip ci]: update CHANGELOG.md
1 parent 377b99b commit 6dd6465

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+5897
-4535
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222
- GenType: now emits full suffix on JS import path to be compatible with `.res.js`. https://github.com/rescript-lang/rescript-compiler/pull/6541
2323

24+
#### :nail_care: Polish
25+
26+
- Format docstrings. https://github.com/rescript-lang/rescript-compiler/pull/6417
27+
2428
# 11.0.0-rc.8
2529

2630
#### :rocket: New Feature

jscomp/others/belt.res

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ Belt provides:
4040
4141
To use modules from Belt, either refer to them by their fully qualified name (`Belt.List`, `Belt.Array` etc.) or open the `Belt` module by putting
4242
43-
```
43+
## Examples
44+
45+
```rescript
4446
open Belt
4547
```
4648
@@ -49,7 +51,9 @@ at the top of your source files. After opening Belt this way, `Array` will refer
4951
If you want to open Belt globally for all files in your project instead, you can put
5052
5153
```json
52-
"bsc-flags": ["-open Belt"],
54+
{
55+
"bsc-flags": ["-open Belt"]
56+
}
5357
```
5458
5559
into your `bsconfig.json`.
@@ -58,7 +62,9 @@ into your `bsconfig.json`.
5862
5963
Example usage:
6064
61-
```
65+
## Examples
66+
67+
```rescript
6268
let someNumbers = [1, 1, 4, 2, 3, 6, 3, 4, 2]
6369
6470
let greaterThan2UniqueAndSorted =
@@ -81,7 +87,9 @@ available:
8187
8288
E.g.:
8389
84-
```
90+
## Examples
91+
92+
```rescript
8593
let forEach: (t<'a>, 'a => unit) => unit
8694
8795
let forEachU: (t<'a>, (. 'a) => unit) => unit
@@ -91,7 +99,9 @@ The uncurried version will be faster in some cases, but for simplicity we recomm
9199
92100
The two versions can be invoked as follows:
93101
94-
```
102+
## Examples
103+
104+
```rescript
95105
["a", "b", "c"]->Belt.Array.forEach(x => Js.log(x))
96106
97107
["a", "b", "c"]->Belt.Array.forEachU((. x) => Js.log(x))
@@ -104,16 +114,18 @@ For collections types like set or map, Belt provides both a generic module as we
104114
For example, Belt has the following set modules:
105115
106116
- [Belt.Set](belt/set)
107-
- [Belt.Set.Int](belt/set-int)
108-
- [Belt.Set.String](belt/set-string)
117+
- [Belt.Set.Int](belt/set/int)
118+
- [Belt.Set.String](belt/set/string)
109119
110120
## Implementation Details
111121
112122
### Array access runtime safety
113123
114124
One common confusion comes from the way Belt handles array access. It differs from than the default standard library's.
115125
116-
```
126+
## Examples
127+
128+
```rescript
117129
let letters = ["a", "b", "c"]
118130
let a = letters[0] // a == "a"
119131
let capitalA = Js.String.toUpperCase(a)
@@ -122,7 +134,9 @@ let k = letters[10] // Raises an exception! The 10th index doesn't exist.
122134
123135
Because Belt avoids exceptions and returns `options` instead, this code behaves differently:
124136
125-
```
137+
## Examples
138+
139+
```rescript
126140
open Belt
127141
let letters = ["a", "b", "c"]
128142
let a = letters[0] // a == Some("a")
@@ -138,7 +152,9 @@ Although we've fixed the problem where `k` raises an exception, we now have a ty
138152
139153
Fortunately, this is easy to fix:
140154
141-
```res example
155+
## Examples
156+
157+
```rescript
142158
open Belt
143159
let letters = ["a", "b", "c"]
144160
let a = letters[0]
@@ -161,7 +177,9 @@ When we create a collection library for a custom data type we need a way to prov
161177
162178
We use a phantom type to solve the problem:
163179
164-
```
180+
## Examples
181+
182+
```rescript
165183
module Comparable1 =
166184
Belt.Id.MakeComparable(
167185
{
@@ -193,7 +211,9 @@ let mySet2 = Belt.Set.make(~id=module(Comparable2))
193211
194212
Here, the compiler would infer `mySet1` and `mySet2` having different type, so e.g. a `merge` operation that tries to merge these two sets will correctly fail.
195213
196-
```
214+
## Examples
215+
216+
```rescript
197217
let mySet1: t<(int, int), Comparable1.identity>
198218
let mySet2: t<(int, int), Comparable2.identity>
199219
```

0 commit comments

Comments
 (0)