Documentation
Bindings may begin as generated output, but the checked-in source and its ReScript comments are maintained by hand. Generated API pages use those comments to explain how a public binding works and link to the corresponding browser API.
Structure
Section titled “Structure”The documentation for each binding should roughly follow this structure:
- signature
- short description focused on the ReScript side of the API
- example usage in the public
WebAPInamespace - links to MDN and any relevant source type
For example, the public WebAPI.Fetch.fetch function can be documented in its source module:
/*`fetch(string, init)`
Starts the process of fetching a resource from the network,returning a promise that is fulfilled once the response is available.
```reslet response = await WebAPI.Fetch.fetch("https://rescript-lang.org")```
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/fetch)*/external fetch: (string, ~init: Request.requestInit=?) => promise<Response.t> = "fetch"Keep overload examples specific to their argument shape. Constructor documentation uses
semantic names such as make, fromString, and fromArray rather than numbered overloads:
/*`fromArray(array<float>)`
Creates a new `DOMMatrix` from an array of matrix component values.
```reslet matrix = WebAPI.DOMMatrix.fromArray([1., 0., 0., 1., 0., 0.])```
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMMatrix)*/@newexternal fromArray: array<float> => DOM.domMatrix = "DOMMatrix"When an input is a public alias, link to its owner module. Do not link an internal type holder unless it has a valid public owner target; prefer public aliases or inferred types. See the API module structure guide for the current module layout.
Keep examples that are not runtime-safe as compile-only fixtures. Put browser-dependent behavior
checks in the browserRuntime fixture category and run them with the native Chromium suite. See
the testing guide for fixture categories and commands.