Skip to content

Commit e31f40c

Browse files
authored
Sync v12 core docs (#991)
* WIP sync stdlib docs (Js does not work for now) * rename core to stdlib for >= v12 * fix doc generation for v12 * fix version selector for core/stdlib * add missing react keys * update stdlib.json * remove unused flag * fix selector for non core/stdlib modules * revert gendocs.res since it'll be moved to rescript monorepo * fix iterator docstrings
1 parent a2551ae commit e31f40c

File tree

10 files changed

+8479
-8746
lines changed

10 files changed

+8479
-8746
lines changed

data/api/v12.0.0/belt.json

Lines changed: 700 additions & 477 deletions
Large diffs are not rendered by default.

data/api/v12.0.0/js.json

Lines changed: 1611 additions & 4035 deletions
Large diffs are not rendered by default.

data/api/v12.0.0/core.json renamed to data/api/v12.0.0/stdlib.json

Lines changed: 6124 additions & 4215 deletions
Large diffs are not rendered by default.

data/api/v12.0.0/toc_tree.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

pages/docs/manual/v12.0.0/api.mdx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
# Overview
22

3-
## ReScript Core
3+
## Stdlib
44

5-
[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.
5+
[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.
66

7-
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.
7+
In ReScript 11, it was shipped as a separate npm package `@rescript/core`.
8+
9+
Since Rescript 12, it is now included with the `rescript` npm package itself.
810

911
## Additional Libraries
1012

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

13-
- [Belt](api/belt): immutable collections and extra helpers not available in [Core](api/core).
14-
- [Dom](api/dom): Dom related types and modules. Contains our standardized types used by various userland DOM bindings.
15+
- [Belt](api/belt): immutable collections and extra helpers not available in JavaScript / [Stdlib](api/stdlib).
16+
- [Dom](api/dom): Dom related types and modules. Contains our standardized types used by various userland DOM bindings.
17+
18+
## Legacy Modules
19+
20+
The [Js](api/js) module is superseded by [Stdlib](api/stdlib).

src/ApiDocs.res

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module RightSidebar = {
6262
}
6363
let title = `${Option.isSome(deprecatedIcon) ? "Deprecated " : ""}` ++ name
6464
let result =
65-
<li className="my-3">
65+
<li className="my-3" key={href}>
6666
<a
6767
title
6868
className="flex items-center w-full font-normal text-14 text-gray-40 leading-tight hover:text-gray-80"
@@ -125,12 +125,12 @@ module SidebarTree = {
125125
switch hasChildren {
126126
| true =>
127127
let open_ =
128-
node.path->Array.join("/") ===
128+
href ===
129129
moduleRoute
130130
->Array.slice(~start=0, ~end=Array.length(moduleRoute) - 1)
131131
->Array.join("/")
132132

133-
<details key={node.name} open_>
133+
<details key={href} open_>
134134
<summary className={summaryClassName ++ classNameActive}>
135135
<Next.Link className={"inline-block w-10/12"} href>
136136
{node.name->React.string}
@@ -148,7 +148,7 @@ module SidebarTree = {
148148
}}
149149
</details>
150150
| false =>
151-
<li className={"list-none mt-1 leading-4"}>
151+
<li className={"list-none mt-1 leading-4"} key={href}>
152152
<summary className={summaryClassName ++ classNameActive}>
153153
<Next.Link className={"block"} href> {node.name->React.string} </Next.Link>
154154
</summary>
@@ -172,6 +172,15 @@ module SidebarTree = {
172172
ReactEvent.Form.preventDefault(evt)
173173
let version = (evt->ReactEvent.Form.target)["value"]
174174
let url = Url.parse(router.asPath)
175+
switch url.pagepath[1] {
176+
| Some("core") | Some("stdlib") =>
177+
if version < "v12.0.0" {
178+
url.pagepath[1] = "core"
179+
} else {
180+
url.pagepath[1] = "stdlib"
181+
}
182+
| _ => ()
183+
}
175184

176185
let targetUrl =
177186
"/" ++
@@ -184,9 +193,10 @@ module SidebarTree = {
184193
<VersionSelect
185194
onChange
186195
version
187-
availableVersions=Constants.coreVersions
196+
availableVersions=Constants.stdlibVersions
188197
nextVersion=?Constants.nextVersion
189198
/>
199+
190200
| None => React.null
191201
}}
192202
</div>
@@ -309,21 +319,21 @@ let default = (props: props) => {
309319
| Value({name, signature, docstrings, deprecated}) =>
310320
let code = String.replaceRegExp(signature, /\\n/g, "\n")
311321
let slugPrefix = "value-" ++ name
312-
<>
322+
<React.Fragment key={slugPrefix}>
313323
<H2 id=slugPrefix> {name->React.string} </H2>
314324
<DeprecatedMessage deprecated />
315325
<CodeExample code lang="rescript" />
316326
<DocstringsStylize docstrings slugPrefix />
317-
</>
327+
</React.Fragment>
318328
| Type({name, signature, docstrings, deprecated}) =>
319329
let code = String.replaceRegExp(signature, /\\n/g, "\n")
320330
let slugPrefix = "type-" ++ name
321-
<>
331+
<React.Fragment key={slugPrefix}>
322332
<H2 id=slugPrefix> {name->React.string} </H2>
323333
<DeprecatedMessage deprecated />
324334
<CodeExample code lang="rescript" />
325335
<DocstringsStylize docstrings slugPrefix />
326-
</>
336+
</React.Fragment>
327337
}
328338
})
329339

src/bindings/Node.res

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module Buffer = {
3535
}
3636

3737
module ChildProcess = {
38+
type options = {maxBuffer?: float}
3839
@module("child_process")
39-
external execSync: string => Buffer.t = "execSync"
40+
external execSync: (string, ~options: options=?) => Buffer.t = "execSync"
4041
}

src/common/Constants.res

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ let nextVersion =
2525
? None
2626
: Some(versions.next, versions.next->Semver.tryGetMajorString)
2727

28-
let coreVersions = [latestVersion]
28+
let stdlibVersions =
29+
versions.latest === "v11.0.0" ? [latestVersion] : [("v11.0.0", "v11"), latestVersion]
2930

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

src/components/VersionSelect.res

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ let make = (
2626
<>
2727
<SectionHeader value=Constants.dropdownLabelNext />
2828
<option className="py-4" key=value value> {React.string(label)} </option>
29-
<SectionHeader value=Constants.dropdownLabelReleased />
29+
{switch availableVersions {
30+
| [] => React.null
31+
| _ => <SectionHeader value=Constants.dropdownLabelReleased />
32+
}}
3033
</>
3134
}}
3235
{React.array(children)}

src/layouts/ApiOverviewLayout.res

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ let makeCategories: string => array<Sidebar.Category.t> = version => [
55
name: "",
66
items: [
77
{name: "Overview", href: `/docs/manual/${version}/api`},
8-
{name: "Core", href: `/docs/manual/${version}/api/core`},
8+
if version >= "v12.0.0" {
9+
{name: "Stdlib", href: `/docs/manual/${version}/api/stdlib`}
10+
} else {
11+
{name: "Core", href: `/docs/manual/${version}/api/core`}
12+
},
913
],
1014
},
1115
{

0 commit comments

Comments
 (0)