Skip to content

Commit 3ae96e2

Browse files
committed
Markdown docstrings (Rescript 11)
1 parent 27c626f commit 3ae96e2

18 files changed

Lines changed: 458 additions & 528 deletions

src/Tablecloth.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module Int = TableclothInt
1313
/** Functions for working with floating point numbers. */
1414
module Float = TableclothFloat
1515

16-
/** Interfaces for use with container types like {!Array} or {!List} */
16+
/** Interfaces for use with container types like [Array](Array.mdx#) or [List](List.mdx#) */
1717
module Container = TableclothContainer
1818

1919
/** A fixed lenfth collection of values */

src/TableclothArray.resi

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
Has constant time (O(1)) [get](#get), [set](#set) and [length](#length) operations.
44
55
Arrays have a fixed length, if you want to be able to add an arbitrary number of elements maybe you want a [List](List.mdx#)}.
6+
You can create an `array` in Rescript with the `[1, 2, 3]` syntax.
67
*/
78
type t<'a> = array<'a>
89

9-
/** # Create
10-
11-
You can create an `array` in Rescript with the `[1, 2, 3]` syntax.
12-
*/
1310
/** Create an array with only one element.
1411
1512
## Examples
@@ -92,7 +89,6 @@ let fromList: list<'a> => t<'a>
9289
*/
9390
let clone: t<'a> => t<'a>
9491

95-
/** # Basic operations */
9692
/** Get the element at the specified index.
9793
9894
The first element has index number 0.
@@ -124,7 +120,7 @@ let get: (t<'a>, int) => 'a
124120

125121
/** Returns, as an [Option](Option.mdx#), the element at index number `n` of array `a`.
126122
127-
Returns `None` if `n` is outside the range `0` to [(Array.length(a) - 1)].
123+
Returns `None` if `n` is outside the range `0` to `Array.length(a) - 1`.
128124
129125
## Examples
130126
@@ -251,7 +247,6 @@ let reverse: t<'a> => unit
251247
*/
252248
let sort: (t<'a>, ~compare: ('a, 'a) => int) => unit
253249

254-
/** # Query */
255250
/** Check if an array is empty.
256251
257252
## Examples
@@ -336,7 +331,7 @@ let find: (t<'a>, ~f: 'a => bool) => option<'a>
336331
*/
337332
let findIndex: (t<'a>, ~f: (int, 'a) => bool) => option<(int, 'a)>
338333

339-
/** Test if an array contains the specified element using the provided [equal] to test for equality.
334+
/** Test if an array contains the specified element using the provided `equal` to test for equality.
340335
341336
## Examples
342337
@@ -408,7 +403,6 @@ let extent: (t<'a>, ~compare: ('a, 'a) => int) => option<('a, 'a)>
408403
*/
409404
let sum: (t<'a>, module(TableclothContainer.Sum with type t = 'a)) => 'a
410405

411-
/** # Transform */
412406
/** Create a new array which is the result of applying a function `f` to every element.
413407
414408
## Examples
@@ -560,7 +554,7 @@ let flatten: t<t<'a>> => t<'a>
560554
561555
If one array is longer, the extra elements are dropped.
562556
563-
The same as [Array.map2(~f=Tuple2.make)]
557+
The same as `Array.map2(~f=Tuple2.make)`
564558
565559
## Examples
566560
@@ -605,7 +599,6 @@ let map2: (t<'a>, t<'b>, ~f: ('a, 'b) => 'c) => t<'c>
605599
*/
606600
let map3: (t<'a>, t<'b>, t<'c>, ~f: ('a, 'b, 'c) => 'd) => t<'d>
607601

608-
/** # Deconstruct */
609602
/** Split an array into a [Tuple2](Tuple2.mdx#) of arrays. Values which `f` returns true for will end up in [Tuple2.first](Tuple2.mdx#first).
610603
611604
## Examples
@@ -664,7 +657,6 @@ let splitWhen: (t<'a>, ~f: 'a => bool) => (t<'a>, t<'a>)
664657
*/
665658
let unzip: t<('a, 'b)> => (t<'a>, t<'b>)
666659

667-
/** # Iterate */
668660
/** Iterates over the elements of invokes `f` for each element.
669661
670662
## Examples
@@ -749,7 +741,6 @@ let chunksOf: (t<'a>, ~size: int) => t<t<'a>>
749741
*/
750742
let sliding: (~step: int=?, t<'a>, ~size: int) => t<t<'a>>
751743

752-
/** # Convert */
753744
/** Converts an array of strings into a [String](String.mdx#), placing `sep` between each string in the result.
754745
755746
## Examples
@@ -803,7 +794,15 @@ let toList: t<'a> => list<'a>
803794
*/
804795
let toIndexedList: t<'a> => list<(int, 'a)>
805796

806-
/** Test two arrays for equality using the provided function to test pairs of elements. */
797+
/** Test two arrays for equality using the provided function to test pairs of elements.
798+
799+
## Examples
800+
801+
```rescript
802+
Array.equal(["cat", "dog"], ["cat", "dog"], String.equal) === true
803+
Array.equal(["cat", "dog"], ["parrot", "dog"], String.equal) === false
804+
```
805+
*/
807806
let equal: (t<'a>, t<'a>, ('a, 'a) => bool) => bool
808807

809808
/** Compare two arrays using the provided `f` function to compare pairs of elements.

src/TableclothBool.resi

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
*/
2121
type t = bool
2222

23-
/** # Create */
24-
/** Convert an {!Int} into a {!Bool}.
23+
/** Convert an [Int](Int.mdx#) into a [Bool](Bool.mdx#).
2524
2625
## Examples
2726
@@ -34,7 +33,7 @@ type t = bool
3433
*/
3534
let fromInt: int => option<bool>
3635

37-
/** Convert a [String](String.mdx#) into a {!Bool}.
36+
/** Convert a [String](String.mdx#) into a [Bool](Bool.mdx#).
3837
3938
## Examples
4039
@@ -50,7 +49,6 @@ let fromInt: int => option<bool>
5049
*/
5150
let fromString: string => option<bool>
5251

53-
/** # Basic operations */
5452
/** The exclusive or operator.
5553
5654
Returns `true` if *exactly one* of its operands is `true`.
@@ -66,7 +64,7 @@ let fromString: string => option<bool>
6664
*/
6765
let xor: (bool, bool) => bool
6866

69-
/** Negate a [bool].
67+
/** Negate a `bool`.
7068
7169
## Examples
7270
@@ -77,7 +75,7 @@ let xor: (bool, bool) => bool
7775
*/
7876
let not: t => bool
7977

80-
/** The logical conjunction [AND] operator.
78+
/** The logical conjunction `AND` operator.
8179
8280
Returns `true` if *both* of its operands are `true`.
8381
If the 'left' operand evaluates to `false`, the 'right' operand is not evaluated.
@@ -93,8 +91,7 @@ let not: t => bool
9391
*/
9492
let and_: (bool, bool) => bool
9593

96-
/** # Convert */
97-
/** Convert a [bool] to a [String](String.mdx#)
94+
/** Convert a `bool` to a [String](String.mdx#)
9895
9996
## Examples
10097
@@ -105,7 +102,7 @@ let and_: (bool, bool) => bool
105102
*/
106103
let toString: bool => string
107104

108-
/** Convert a [bool] to an {!Int}.
105+
/** Convert a `bool` to an [Int](Int.mdx#).
109106
110107
## Examples
111108
@@ -116,8 +113,7 @@ let toString: bool => string
116113
*/
117114
let toInt: bool => int
118115

119-
/** {1 Compare} */
120-
/** Test for the equality of two [bool] values.
116+
/** Test for the equality of two `bool` values.
121117
122118
## Examples
123119
@@ -129,7 +125,7 @@ let toInt: bool => int
129125
*/
130126
let equal: (bool, bool) => bool
131127

132-
/** Compare two [bool] values.
128+
/** Compare two `bool` values.
133129
134130
## Examples
135131

src/TableclothChar.resi

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,15 @@
1010
*not Unicode*.
1111
1212
Note that in Rescript source code you can include only the characters from 0-127 range.
13-
Full list of available characters is available {{: https://www.w3schools.com/charsets/ref_html_ascii.asp } here}.
13+
Full list of available characters is available [here](https://www.w3schools.com/charsets/ref_html_ascii.asp).
1414
1515
Characters from 128-255 range can still be handled, but only as codes.
1616
*/
1717
type t = char
1818

19-
/** # Create
19+
/** Convert an ASCII [code point](https://en.wikipedia.org/wiki/Code_point) to a character.
2020
21-
You can also create a {!Char} using single quotes:
22-
23-
```rescript
24-
let char = 'c'
25-
```
26-
*/
27-
/** Convert an ASCII {{: https://en.wikipedia.org/wiki/Code_point } code point } to a character.
28-
29-
The full range of extended ASCII is from `0` to [255].
21+
The full range of extended ASCII is from `0` to `255`.
3022
For numbers outside that range, you get `None`.
3123
3224
## Examples
@@ -42,7 +34,7 @@ let fromCode: int => option<char>
4234

4335
/** Converts a string to character.
4436
45-
Returns `None` when the [string] isn't of length one.
37+
Returns `None` when the `string` isn't of length one.
4638
4739
## Examples
4840
@@ -131,9 +123,9 @@ let isDigit: char => bool
131123
*/
132124
let isAlphanumeric: char => bool
133125

134-
/** Detect if a character is a {{: https://en.wikipedia.org/wiki/ASCII#Printable_characters } printable } character
126+
/** Detect if a character is a [printable](https://en.wikipedia.org/wiki/ASCII#Printable_characters) character
135127
136-
A Printable character has a {!Char.toCode} in the range 32 to 127, inclusive ([' '] to ['~']).
128+
A Printable character has a [Char.toCode](Char.mdx#toCode) in the range 32 to 127, inclusive (`' '` to `'~'`).
137129
138130
## Examples
139131
@@ -148,12 +140,12 @@ let isAlphanumeric: char => bool
148140
let isPrintable: char => bool
149141

150142
/** Detect one of the following characters:
151-
- ['\t'] (tab)
152-
- ['\n'] (newline)
153-
- ['\011'] (vertical tab)
154-
- ['\012'] (form feed)
155-
- ['\r'] (carriage return)
156-
- [' '] (space)
143+
- `'\t'` (tab)
144+
- `'\n'` (newline)
145+
- `'\011'` (vertical tab)
146+
- `'\012'` (form feed)
147+
- `'\r'` (carriage return)
148+
- `' '` (space)
157149
158150
## Examples
159151
@@ -190,7 +182,7 @@ let toLowercase: char => char
190182
*/
191183
let toUppercase: char => char
192184

193-
/** Convert [char] to the corresponding ASCII {{: https://en.wikipedia.org/wiki/Code_point } code point}.
185+
/** Convert `char` to the corresponding ASCII [code point](https://en.wikipedia.org/wiki/Code_point).
194186
195187
## Examples
196188
@@ -201,7 +193,7 @@ let toUppercase: char => char
201193
*/
202194
let toCode: char => int
203195

204-
/** Convert a character into a [string].
196+
/** Convert a character into a `string`.
205197
206198
## Examples
207199
@@ -213,28 +205,28 @@ let toCode: char => int
213205
*/
214206
let toString: char => string
215207

216-
/** Converts a digit character to its corresponding {!Int}.
208+
/** Converts a digit character to its corresponding [Int](Int.mdx#).
217209
218210
Returns `None` when the character isn't a digit.
219211
220212
## Examples
221213
222214
```rescript
223-
Char.toDigit("7") == Some(7)
224-
Char.toDigit("0") == Some(0)
225-
Char.toDigit("A") == None
226-
Char.toDigit("") == None
215+
Char.toDigit('7') == Some(7)
216+
Char.toDigit('0') == Some(0)
217+
Char.toDigit('A') == None
218+
Char.toDigit('') == None
227219
```
228220
*/
229221
let toDigit: char => option<int>
230222

231-
/** Test two {!Char}s for equality */
223+
/** Test two [Char](Char.mdx#)s for equality */
232224
let equal: (t, t) => bool
233225

234-
/** Compare two {!Char}s */
226+
/** Compare two [Char](Char.mdx#)s */
235227
let compare: (t, t) => int
236228

237-
/** The unique identity for {!Comparator} */
229+
/** The unique identity for [Comparator](Comparator.mdx#) */
238230
type identity
239231

240232
let comparator: TableclothComparator.t<t, identity>

src/TableclothComparator.resi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/** Comparator provide a way for custom data structures to be used with {!Map}s and {!Set}s.
1+
/** Comparator provide a way for custom data structures to be used with [Map](Map.mdx#)s and [Set](Set.mdx#)s.
22
3-
Say we have a module [Book] which we want to be able to create a {!Set} of
3+
Say we have a module [Book] which we want to be able to create a [Set](Set.mdx#) of
44
55
```rescript
66
module Book = {
@@ -13,9 +13,9 @@
1313
}
1414
```
1515
16-
First we need to make our module conform to the {!S} signature.
16+
First we need to make our module conform to the [S](#S) signature.
1717
18-
This can be done by using the {!Make} functor.
18+
This can be done by using the [Make](Make.mdx#) functor.
1919
2020
```rescript
2121
module Book = {
@@ -44,19 +44,19 @@
4444
```
4545
*/
4646
module type T = {
47-
/** T represents the input for the {!Make} functor. */
47+
/** T represents the input for the [Make](Make.mdx#) functor. */
4848
type t
4949

5050
let compare: (t, t) => int
5151
}
5252

5353
type t<'a, 'identity>
5454

55-
/** This just is an alias for {!t}. */
55+
/** This just is an alias for [t](#t). */
5656
type comparator<'a, 'identity> = t<'a, 'identity>
5757

5858
module type S = {
59-
/** The output type of {!Make}. */
59+
/** The output type of [Make](Make.mdx#). */
6060
type t
6161

6262
type identity
@@ -65,11 +65,11 @@ module type S = {
6565
}
6666

6767
@ocaml.doc(
68-
" A type alias that is useful typing functions which accept first class modules like {!Map.empty} or {!Set.fromArray}. "
68+
" A type alias that is useful typing functions which accept first class modules like [Map.empty](Map.mdx#empty) or [Set.fromArray](Set.mdx#fromArray). "
6969
)
7070
type s<'a, 'identity> = module(S with type identity = 'identity and type t = 'a)
7171

72-
/** Create a new comparator by providing a module which satisifies {!T}.
72+
/** Create a new comparator by providing a module which satisifies [T](#T).
7373
7474
## Examples
7575

src/TableclothContainer.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
module type Sum = {
55
/** Modules which conform to this signature can be used with functions like
6-
{!Array.sum} or {!List.sum}.
6+
[Array.sum](Array.mdx#sum) or [List.sum](List.mdx#sum).
77
*/
88
type t
99

0 commit comments

Comments
 (0)