Skip to content

Commit 2c7ece0

Browse files
committed
docs: simplify constructor descriptions
Remove source-shape callouts from the constructor docs added in this PR. Rewrite constructor summaries to focus on the ReScript API surface and update the contributor documentation guidance to match.
1 parent 1f43149 commit 2c7ece0

10 files changed

Lines changed: 36 additions & 155 deletions

File tree

docs/content/docs/contributing/documentation.mdx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ It keeps the user inside the IDE and avoids context switching.
2121
The documentation for each binding should roughly follow this structure:
2222

2323
- signature
24-
- short description (tip: check MDN for inspiration)
25-
- `Source shape:` block with links for the overload-specific input types
24+
- short description focused on the ReScript side of the API
2625
- example usage
2726
- link to the MDN documentation
2827

@@ -46,18 +45,15 @@ external fetch: (window, string, ~init: requestInit=?)
4645
=> promise<response> = "fetch"
4746
````
4847

49-
Constructor overloads should use the same structure, but make the differentiating input shape explicit.
50-
Link ReScript stdlib types such as `string`, `array<'a>`, `ArrayBuffer.t`, and `DataView.t`, and link project-local records or aliases when the constructor takes one of those shapes.
48+
Constructor overloads should use the same structure, but keep the description concise and let the signature and example show the input shape.
49+
Use backticks for specific types and names.
5150
If a constructor variant has a single source input, show it as a direct unlabeled argument in both the signature and example.
5251

5352
````ReScript
5453
/*
5554
`fromArray(array<float>)`
5655
57-
The DOMMatrix() constructor creates a new DOMMatrix from an array of matrix component values.
58-
59-
Source shape:
60-
- ReScript [array](https://rescript-lang.org/docs/manual/api/stdlib/array) of numeric values accepted by MDN [DOMMatrix()](https://developer.mozilla.org/docs/Web/API/DOMMatrix/DOMMatrix).
56+
Creates a new `DOMMatrix` from an array of matrix component values.
6157
6258
```res
6359
let matrix = DOMMatrix.fromArray([1., 0., 0., 1., 0., 0.])

packages/CSSFontLoading/src/FontFace.res

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
/**
22
`fromString(~family: string, ~source: string, ~descriptors: fontFaceDescriptors=?)`
33
4-
The FontFace() constructor creates a new FontFace object from CSS source text.
5-
6-
Source shape:
7-
- `family`: ReScript [string](https://rescript-lang.org/docs/manual/primitive-types/#string) for the font family name.
8-
- `source`: ReScript [string](https://rescript-lang.org/docs/manual/primitive-types/#string) containing CSS [`@font-face` `src`](https://developer.mozilla.org/docs/Web/CSS/@font-face/src) text.
9-
- `descriptors`: local [`fontFaceDescriptors`](../#fontFaceDescriptors) values for optional constructor descriptors.
4+
Creates a new `FontFace` from CSS source text.
105
116
```res
127
let fontFace =
@@ -25,12 +20,7 @@ external fromString: (
2520
/**
2621
`fromDataView(~family: string, ~source: DataView.t, ~descriptors: fontFaceDescriptors=?)`
2722
28-
The FontFace() constructor creates a new FontFace object from DataView-backed font data.
29-
30-
Source shape:
31-
- `family`: ReScript [string](https://rescript-lang.org/docs/manual/primitive-types/#string) for the font family name.
32-
- `source`: ReScript [`DataView.t`](https://rescript-lang.org/docs/manual/api/stdlib/dataview) mapped to MDN [DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView).
33-
- `descriptors`: local [`fontFaceDescriptors`](../#fontFaceDescriptors) values for optional constructor descriptors.
23+
Creates a new `FontFace` from `DataView`-backed font data.
3424
3525
```res
3626
let fontFace =
@@ -49,12 +39,7 @@ external fromDataView: (
4939
/**
5040
`fromArrayBuffer(~family: string, ~source: ArrayBuffer.t, ~descriptors: fontFaceDescriptors=?)`
5141
52-
The FontFace() constructor creates a new FontFace object from ArrayBuffer-backed font data.
53-
54-
Source shape:
55-
- `family`: ReScript [string](https://rescript-lang.org/docs/manual/primitive-types/#string) for the font family name.
56-
- `source`: ReScript [`ArrayBuffer.t`](https://rescript-lang.org/docs/manual/api/stdlib/arraybuffer) mapped to MDN [ArrayBuffer](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer).
57-
- `descriptors`: local [`fontFaceDescriptors`](../#fontFaceDescriptors) values for optional constructor descriptors.
42+
Creates a new `FontFace` from `ArrayBuffer`-backed font data.
5843
5944
```res
6045
let fontFace =

packages/Canvas/src/Path2D.res

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ type domMatrix2DInit = WebApiDOM.Types.domMatrix2DInit
33
/**
44
`make()`
55
6-
The Path2D() constructor creates a new empty Path2D object.
7-
8-
Source shape:
9-
- no source input; this constructor creates a fresh MDN [Path2D](https://developer.mozilla.org/docs/Web/API/Path2D).
6+
Creates a new empty `Path2D`.
107
118
```res
129
let path = Path2D.make()
@@ -20,10 +17,7 @@ external make: unit => Types.path2D = "Path2D"
2017
/**
2118
`fromPath2D(path2D)`
2219
23-
The Path2D() constructor creates a new Path2D object by copying another Path2D source.
24-
25-
Source shape:
26-
- local [`Path2D.t`](#t) mapped to MDN [Path2D](https://developer.mozilla.org/docs/Web/API/Path2D).
20+
Creates a new `Path2D` by copying another `Path2D`.
2721
2822
```res
2923
let copiedPath = Path2D.fromPath2D(existingPath)
@@ -37,10 +31,7 @@ external fromPath2D: Types.path2D => Types.path2D = "Path2D"
3731
/**
3832
`fromString(string)`
3933
40-
The Path2D() constructor creates a new Path2D object from SVG path data text.
41-
42-
Source shape:
43-
- ReScript [string](https://rescript-lang.org/docs/manual/primitive-types/#string) containing SVG path data accepted by MDN [Path2D()](https://developer.mozilla.org/docs/Web/API/Path2D/Path2D).
34+
Creates a new `Path2D` from SVG path data text.
4435
4536
```res
4637
let path = Path2D.fromString("M0 0 L10 10")

packages/Canvas/src/VideoFrame.res

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ type sharedArrayBuffer = unknown
33
/**
44
`fromHTMLImageElement(~image: HTMLImageElement.t, ~init: videoFrameInit=?)`
55
6-
The VideoFrame() constructor creates a new VideoFrame from an HTMLImageElement source.
7-
8-
Source shape:
9-
- `image`: local [`HTMLImageElement.t`](../dom/html-image-element#t) mapped to MDN [HTMLImageElement](https://developer.mozilla.org/docs/Web/API/HTMLImageElement).
10-
- `init`: local [`videoFrameInit`](../dom#videoFrameInit) values for optional frame initialization.
6+
Creates a new `VideoFrame` from an `HTMLImageElement`.
117
128
```res
139
let frame = VideoFrame.fromHTMLImageElement(~image=myImageElement)
@@ -24,11 +20,7 @@ external fromHTMLImageElement: (
2420
/**
2521
`fromSVGImageElement(~image: SVGImageElement.t, ~init: videoFrameInit=?)`
2622
27-
The VideoFrame() constructor creates a new VideoFrame from an SVGImageElement source.
28-
29-
Source shape:
30-
- `image`: local [`SVGImageElement.t`](../dom/svg-image-element#t) mapped to MDN [SVGImageElement](https://developer.mozilla.org/docs/Web/API/SVGImageElement).
31-
- `init`: local [`videoFrameInit`](../dom#videoFrameInit) values for optional frame initialization.
23+
Creates a new `VideoFrame` from an `SVGImageElement`.
3224
3325
```res
3426
let frame = VideoFrame.fromSVGImageElement(~image=mySvgImageElement)
@@ -45,11 +37,7 @@ external fromSVGImageElement: (
4537
/**
4638
`fromHTMLVideoElement(~image: HTMLVideoElement.t, ~init: videoFrameInit=?)`
4739
48-
The VideoFrame() constructor creates a new VideoFrame from an HTMLVideoElement source.
49-
50-
Source shape:
51-
- `image`: local [`HTMLVideoElement.t`](../dom/html-video-element#t) mapped to MDN [HTMLVideoElement](https://developer.mozilla.org/docs/Web/API/HTMLVideoElement).
52-
- `init`: local [`videoFrameInit`](../dom#videoFrameInit) values for optional frame initialization.
40+
Creates a new `VideoFrame` from an `HTMLVideoElement`.
5341
5442
```res
5543
let frame = VideoFrame.fromHTMLVideoElement(~image=myVideoElement)
@@ -66,11 +54,7 @@ external fromHTMLVideoElement: (
6654
/**
6755
`fromHTMLCanvasElement(~image: HTMLCanvasElement.t, ~init: videoFrameInit=?)`
6856
69-
The VideoFrame() constructor creates a new VideoFrame from an HTMLCanvasElement source.
70-
71-
Source shape:
72-
- `image`: local [`HTMLCanvasElement.t`](./html-canvas-element#t) mapped to MDN [HTMLCanvasElement](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement).
73-
- `init`: local [`videoFrameInit`](../dom#videoFrameInit) values for optional frame initialization.
57+
Creates a new `VideoFrame` from an `HTMLCanvasElement`.
7458
7559
```res
7660
let frame = VideoFrame.fromHTMLCanvasElement(~image=myCanvasElement)
@@ -87,11 +71,7 @@ external fromHTMLCanvasElement: (
8771
/**
8872
`fromImageBitmap(~image: ImageBitmap.t, ~init: videoFrameInit=?)`
8973
90-
The VideoFrame() constructor creates a new VideoFrame from an ImageBitmap source.
91-
92-
Source shape:
93-
- `image`: local [`ImageBitmap.t`](./image-bitmap#t) mapped to MDN [ImageBitmap](https://developer.mozilla.org/docs/Web/API/ImageBitmap).
94-
- `init`: local [`videoFrameInit`](../dom#videoFrameInit) values for optional frame initialization.
74+
Creates a new `VideoFrame` from an `ImageBitmap`.
9575
9676
```res
9777
let frame = VideoFrame.fromImageBitmap(~image=myImageBitmap)
@@ -108,11 +88,7 @@ external fromImageBitmap: (
10888
/**
10989
`fromOffscreenCanvas(~image: OffscreenCanvas.t, ~init: videoFrameInit=?)`
11090
111-
The VideoFrame() constructor creates a new VideoFrame from an OffscreenCanvas source.
112-
113-
Source shape:
114-
- `image`: local [`OffscreenCanvas.t`](./offscreen-canvas#t) mapped to MDN [OffscreenCanvas](https://developer.mozilla.org/docs/Web/API/OffscreenCanvas).
115-
- `init`: local [`videoFrameInit`](../dom#videoFrameInit) values for optional frame initialization.
91+
Creates a new `VideoFrame` from an `OffscreenCanvas`.
11692
11793
```res
11894
let frame = VideoFrame.fromOffscreenCanvas(~image=myOffscreenCanvas)
@@ -129,11 +105,7 @@ external fromOffscreenCanvas: (
129105
/**
130106
`fromVideoFrame(~image: VideoFrame.t, ~init: videoFrameInit=?)`
131107
132-
The VideoFrame() constructor creates a new VideoFrame from an existing VideoFrame source.
133-
134-
Source shape:
135-
- `image`: local [`VideoFrame.t`](#t) mapped to MDN [VideoFrame](https://developer.mozilla.org/docs/Web/API/VideoFrame).
136-
- `init`: local [`videoFrameInit`](../dom#videoFrameInit) values for optional frame initialization.
108+
Creates a new `VideoFrame` from another `VideoFrame`.
137109
138110
```res
139111
let frame = VideoFrame.fromVideoFrame(~image=otherFrame)
@@ -150,11 +122,7 @@ external fromVideoFrame: (
150122
/**
151123
`fromArrayBuffer(~data: ArrayBuffer.t, ~init: videoFrameBufferInit)`
152124
153-
The VideoFrame() constructor creates a new VideoFrame from ArrayBuffer-backed pixel data.
154-
155-
Source shape:
156-
- `data`: ReScript [`ArrayBuffer.t`](https://rescript-lang.org/docs/manual/api/stdlib/arraybuffer) mapped to MDN [ArrayBuffer](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer).
157-
- `init`: local [`videoFrameBufferInit`](../dom#videoFrameBufferInit) values describing the buffer-backed frame layout.
125+
Creates a new `VideoFrame` from `ArrayBuffer`-backed pixel data.
158126
159127
```res
160128
let frame =
@@ -172,11 +140,7 @@ external fromArrayBuffer: (
172140
/**
173141
`fromSharedArrayBuffer(~data: sharedArrayBuffer, ~init: videoFrameBufferInit)`
174142
175-
The VideoFrame() constructor creates a new VideoFrame from SharedArrayBuffer-backed pixel data.
176-
177-
Source shape:
178-
- `data`: opaque SharedArrayBuffer-aligned data accepted by MDN [SharedArrayBuffer](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer).
179-
- `init`: local [`videoFrameBufferInit`](../dom#videoFrameBufferInit) values describing the buffer-backed frame layout.
143+
Creates a new `VideoFrame` from `SharedArrayBuffer`-backed pixel data.
180144
181145
```res
182146
let frame =
@@ -197,11 +161,7 @@ external fromSharedArrayBuffer: (
197161
/**
198162
`fromDataView(~data: DataView.t, ~init: videoFrameBufferInit)`
199163
200-
The VideoFrame() constructor creates a new VideoFrame from DataView-backed pixel data.
201-
202-
Source shape:
203-
- `data`: ReScript [`DataView.t`](https://rescript-lang.org/docs/manual/api/stdlib/dataview) mapped to MDN [DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView).
204-
- `init`: local [`videoFrameBufferInit`](../dom#videoFrameBufferInit) values describing the buffer-backed frame layout.
164+
Creates a new `VideoFrame` from `DataView`-backed pixel data.
205165
206166
```res
207167
let frame =

packages/DOM/src/DOMMatrix.res

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
/**
22
`make()`
33
4-
The DOMMatrix() constructor creates a new identity DOMMatrix.
5-
6-
Source shape:
7-
- no source input; this constructor creates a fresh MDN [DOMMatrix](https://developer.mozilla.org/docs/Web/API/DOMMatrix).
4+
Creates a new identity `DOMMatrix`.
85
96
```res
107
let matrix = DOMMatrix.make()
@@ -18,10 +15,7 @@ external make: unit => Types.domMatrix = "DOMMatrix"
1815
/**
1916
`fromString(string)`
2017
21-
The DOMMatrix() constructor creates a new DOMMatrix from a transform string.
22-
23-
Source shape:
24-
- ReScript [string](https://rescript-lang.org/docs/manual/primitive-types/#string) accepted by MDN [DOMMatrix()](https://developer.mozilla.org/docs/Web/API/DOMMatrix/DOMMatrix).
18+
Creates a new `DOMMatrix` from a transform string.
2519
2620
```res
2721
let matrix = DOMMatrix.fromString("matrix(1, 0, 0, 1, 0, 0)")
@@ -35,10 +29,7 @@ external fromString: string => Types.domMatrix = "DOMMatrix"
3529
/**
3630
`fromArray(array<float>)`
3731
38-
The DOMMatrix() constructor creates a new DOMMatrix from an array of matrix component values.
39-
40-
Source shape:
41-
- ReScript [array](https://rescript-lang.org/docs/manual/api/stdlib/array) of numeric values accepted by MDN [DOMMatrix()](https://developer.mozilla.org/docs/Web/API/DOMMatrix/DOMMatrix).
32+
Creates a new `DOMMatrix` from an array of matrix component values.
4233
4334
```res
4435
let matrix = DOMMatrix.fromArray([1., 0., 0., 1., 0., 0.])

packages/DOM/src/DOMMatrixReadOnly.res

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
/**
22
`make()`
33
4-
The DOMMatrixReadOnly() constructor creates a new identity DOMMatrixReadOnly value.
5-
6-
Source shape:
7-
- no source input; this constructor creates a fresh MDN [DOMMatrixReadOnly](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly).
4+
Creates a new identity `DOMMatrixReadOnly`.
85
96
```res
107
let matrix = DOMMatrixReadOnly.make()
@@ -18,10 +15,7 @@ external make: unit => Types.domMatrixReadOnly = "DOMMatrixReadOnly"
1815
/**
1916
`fromString(string)`
2017
21-
The DOMMatrixReadOnly() constructor creates a new DOMMatrixReadOnly value from a transform string.
22-
23-
Source shape:
24-
- ReScript [string](https://rescript-lang.org/docs/manual/primitive-types/#string) accepted by MDN [DOMMatrixReadOnly()](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/DOMMatrixReadOnly).
18+
Creates a new `DOMMatrixReadOnly` from a transform string.
2519
2620
```res
2721
let matrix = DOMMatrixReadOnly.fromString("matrix(1, 0, 0, 1, 0, 0)")
@@ -35,10 +29,7 @@ external fromString: string => Types.domMatrixReadOnly = "DOMMatrixReadOnly"
3529
/**
3630
`fromArray(array<float>)`
3731
38-
The DOMMatrixReadOnly() constructor creates a new DOMMatrixReadOnly value from an array of matrix component values.
39-
40-
Source shape:
41-
- ReScript [array](https://rescript-lang.org/docs/manual/api/stdlib/array) of numeric values accepted by MDN [DOMMatrixReadOnly()](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/DOMMatrixReadOnly).
32+
Creates a new `DOMMatrixReadOnly` from an array of matrix component values.
4233
4334
```res
4435
let matrix = DOMMatrixReadOnly.fromArray([1., 0., 0., 1., 0., 0.])

packages/File/src/ReadableStream.res

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ type t<'r> = Types.readableStream<'r>
66
/**
77
`make()`
88
9-
The ReadableStream() constructor creates a new empty ReadableStream.
10-
11-
Source shape:
12-
- no source input; this constructor creates a fresh MDN [ReadableStream](https://developer.mozilla.org/docs/Web/API/ReadableStream).
9+
Creates a new empty `ReadableStream`.
1310
1411
```res
1512
let stream: ReadableStream.t<string> = ReadableStream.make()
@@ -23,10 +20,7 @@ external make: unit => t<'t> = "ReadableStream"
2320
/**
2421
`fromUnderlyingSource(underlyingSource<'t>)`
2522
26-
The ReadableStream() constructor creates a new ReadableStream from an underlying source definition.
27-
28-
Source shape:
29-
- local [`underlyingSource<'t>`](../#underlyingSource) values accepted by MDN [ReadableStream()](https://developer.mozilla.org/docs/Web/API/ReadableStream/ReadableStream).
23+
Creates a new `ReadableStream` from an `underlyingSource`.
3024
3125
```res
3226
let stream = ReadableStream.fromUnderlyingSource(myUnderlyingSource)
@@ -40,11 +34,7 @@ external fromUnderlyingSource: Types.underlyingSource<'t> => t<'t> = "ReadableSt
4034
/**
4135
`fromUnderlyingSourceWithStrategy(~underlyingSource: underlyingSource<'t>, ~strategy: queuingStrategy<'t>)`
4236
43-
The ReadableStream() constructor creates a new ReadableStream from an underlying source definition and a queuing strategy.
44-
45-
Source shape:
46-
- local [`underlyingSource<'t>`](../#underlyingSource) values accepted by MDN [ReadableStream()](https://developer.mozilla.org/docs/Web/API/ReadableStream/ReadableStream).
47-
- local [`queuingStrategy<'t>`](../#queuingStrategy) values describing the stream queueing behavior.
37+
Creates a new `ReadableStream` from an `underlyingSource` and `queuingStrategy`.
4838
4939
```res
5040
let stream =

packages/MediaCaptureAndStreams/src/MediaStream.res

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ type t = Types.mediaStream = private {...Types.mediaStream}
33
/**
44
`make()`
55
6-
The MediaStream() constructor creates a new empty MediaStream.
7-
8-
Source shape:
9-
- no source input; this constructor creates a fresh MDN [MediaStream](https://developer.mozilla.org/docs/Web/API/MediaStream).
6+
Creates a new empty `MediaStream`.
107
118
```res
129
let stream = MediaStream.make()
@@ -20,10 +17,7 @@ external make: unit => t = "MediaStream"
2017
/**
2118
`fromMediaStream(mediaStream)`
2219
23-
The MediaStream() constructor creates a new MediaStream by copying another MediaStream source.
24-
25-
Source shape:
26-
- local [`MediaStream.t`](#t) mapped to MDN [MediaStream](https://developer.mozilla.org/docs/Web/API/MediaStream).
20+
Creates a new `MediaStream` by copying another `MediaStream`.
2721
2822
```res
2923
let copiedStream = MediaStream.fromMediaStream(existingStream)
@@ -37,10 +31,7 @@ external fromMediaStream: t => t = "MediaStream"
3731
/**
3832
`fromTracks(array<MediaStreamTrack.t>)`
3933
40-
The MediaStream() constructor creates a new MediaStream from an array of MediaStreamTrack values.
41-
42-
Source shape:
43-
- ReScript [array](https://rescript-lang.org/docs/manual/api/stdlib/array) of local [`MediaStreamTrack.t`](./media-stream-track#t) values mapped to MDN [MediaStreamTrack](https://developer.mozilla.org/docs/Web/API/MediaStreamTrack).
34+
Creates a new `MediaStream` from an array of `MediaStreamTrack.t` values.
4435
4536
```res
4637
let stream = MediaStream.fromTracks([audioTrack, videoTrack])

0 commit comments

Comments
 (0)