Skip to content

Sync v12 core docs #991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,177 changes: 700 additions & 477 deletions data/api/v12.0.0/belt.json

Large diffs are not rendered by default.

5,646 changes: 1,611 additions & 4,035 deletions data/api/v12.0.0/js.json

Large diffs are not rendered by default.

10,339 changes: 6,124 additions & 4,215 deletions data/api/v12.0.0/core.json → data/api/v12.0.0/stdlib.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/api/v12.0.0/toc_tree.json

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions pages/docs/manual/v12.0.0/api.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Overview

## ReScript Core
## Stdlib

[Core](api/core) is ReScript's new standard library. It replaces the complete `Js` module as well as some of the more frequently used modules from `Belt` and is recommended to use with uncurried mode.
[Stdlib](api/stdlib) is ReScript's new standard library. It replaces the complete `Js` module as well as some of the more frequently used modules from `Belt` and is recommended to use with uncurried mode.

In ReScript 11, it is shipped as a separate npm package `@rescript/core` that is added to your project as per the [installation instructions](/docs/manual/next/installation). In future ReScript versions, it will be included with the `rescript` npm package itself.
In ReScript 11, it was shipped as a separate npm package `@rescript/core`.

Since Rescript 12, it is now included with the `rescript` npm package itself.

## Additional Libraries

ReScript ships with these two additional modules in its standard library:

- [Belt](api/belt): immutable collections and extra helpers not available in [Core](api/core).
- [Dom](api/dom): Dom related types and modules. Contains our standardized types used by various userland DOM bindings.
- [Belt](api/belt): immutable collections and extra helpers not available in JavaScript / [Stdlib](api/stdlib).
- [Dom](api/dom): Dom related types and modules. Contains our standardized types used by various userland DOM bindings.

## Legacy Modules

The [Js](api/js) module is superseded by [Stdlib](api/stdlib).
28 changes: 19 additions & 9 deletions src/ApiDocs.res
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module RightSidebar = {
}
let title = `${Option.isSome(deprecatedIcon) ? "Deprecated " : ""}` ++ name
let result =
<li className="my-3">
<li className="my-3" key={href}>
<a
title
className="flex items-center w-full font-normal text-14 text-gray-40 leading-tight hover:text-gray-80"
Expand Down Expand Up @@ -125,12 +125,12 @@ module SidebarTree = {
switch hasChildren {
| true =>
let open_ =
node.path->Array.join("/") ===
href ===
moduleRoute
->Array.slice(~start=0, ~end=Array.length(moduleRoute) - 1)
->Array.join("/")

<details key={node.name} open_>
<details key={href} open_>
<summary className={summaryClassName ++ classNameActive}>
<Next.Link className={"inline-block w-10/12"} href>
{node.name->React.string}
Expand All @@ -148,7 +148,7 @@ module SidebarTree = {
}}
</details>
| false =>
<li className={"list-none mt-1 leading-4"}>
<li className={"list-none mt-1 leading-4"} key={href}>
<summary className={summaryClassName ++ classNameActive}>
<Next.Link className={"block"} href> {node.name->React.string} </Next.Link>
</summary>
Expand All @@ -172,6 +172,15 @@ module SidebarTree = {
ReactEvent.Form.preventDefault(evt)
let version = (evt->ReactEvent.Form.target)["value"]
let url = Url.parse(router.asPath)
switch url.pagepath[1] {
| Some("core") | Some("stdlib") =>
if version < "v12.0.0" {
url.pagepath[1] = "core"
} else {
url.pagepath[1] = "stdlib"
}
| _ => ()
}

let targetUrl =
"/" ++
Expand All @@ -184,9 +193,10 @@ module SidebarTree = {
<VersionSelect
onChange
version
availableVersions=Constants.coreVersions
availableVersions=Constants.stdlibVersions
nextVersion=?Constants.nextVersion
/>

| None => React.null
}}
</div>
Expand Down Expand Up @@ -309,21 +319,21 @@ let default = (props: props) => {
| Value({name, signature, docstrings, deprecated}) =>
let code = String.replaceRegExp(signature, /\\n/g, "\n")
let slugPrefix = "value-" ++ name
<>
<React.Fragment key={slugPrefix}>
<H2 id=slugPrefix> {name->React.string} </H2>
<DeprecatedMessage deprecated />
<CodeExample code lang="rescript" />
<DocstringsStylize docstrings slugPrefix />
</>
</React.Fragment>
| Type({name, signature, docstrings, deprecated}) =>
let code = String.replaceRegExp(signature, /\\n/g, "\n")
let slugPrefix = "type-" ++ name
<>
<React.Fragment key={slugPrefix}>
<H2 id=slugPrefix> {name->React.string} </H2>
<DeprecatedMessage deprecated />
<CodeExample code lang="rescript" />
<DocstringsStylize docstrings slugPrefix />
</>
</React.Fragment>
}
})

Expand Down
3 changes: 2 additions & 1 deletion src/bindings/Node.res
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module Buffer = {
}

module ChildProcess = {
type options = {maxBuffer?: float}
@module("child_process")
external execSync: string => Buffer.t = "execSync"
external execSync: (string, ~options: options=?) => Buffer.t = "execSync"
}
3 changes: 2 additions & 1 deletion src/common/Constants.res
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ let nextVersion =
? None
: Some(versions.next, versions.next->Semver.tryGetMajorString)

let coreVersions = [latestVersion]
let stdlibVersions =
versions.latest === "v11.0.0" ? [latestVersion] : [("v11.0.0", "v11"), latestVersion]

let allReactVersions = [("latest", "v0.12.0"), ("v0.11.0", "v0.11.0"), ("v0.10.0", "v0.10.0")]

Expand Down
5 changes: 4 additions & 1 deletion src/components/VersionSelect.res
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ let make = (
<>
<SectionHeader value=Constants.dropdownLabelNext />
<option className="py-4" key=value value> {React.string(label)} </option>
<SectionHeader value=Constants.dropdownLabelReleased />
{switch availableVersions {
| [] => React.null
| _ => <SectionHeader value=Constants.dropdownLabelReleased />
}}
</>
}}
{React.array(children)}
Expand Down
6 changes: 5 additions & 1 deletion src/layouts/ApiOverviewLayout.res
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ let makeCategories: string => array<Sidebar.Category.t> = version => [
name: "",
items: [
{name: "Overview", href: `/docs/manual/${version}/api`},
{name: "Core", href: `/docs/manual/${version}/api/core`},
if version >= "v12.0.0" {
{name: "Stdlib", href: `/docs/manual/${version}/api/stdlib`}
} else {
{name: "Core", href: `/docs/manual/${version}/api/core`}
},
],
},
{
Expand Down