Skip to content

Commit 40d51cb

Browse files
committed
Merge branch 'master' into new-react-docs-only
2 parents d4c8c95 + c8b7c57 commit 40d51cb

21 files changed

+131
-149
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ This is the official documentation platform for the [ReScript](https://rescript-
1313
## Setup
1414

1515
```sh
16-
# For first time clone / build
16+
# For first time clone / build (install dependencies)
1717
yarn
18-
yarn run update-index
1918

2019
# Initial build
2120
yarn bs:build
2221

22+
# Build the index data
23+
yarn run update-index
24+
2325
# In a new tab
2426
yarn dev
2527

common/Mdx.res

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,15 @@ module MdxChildren: {
4848
} = {
4949
type unknown
5050

51-
@unboxed
52-
type rec t = Any('a): t
51+
type t
5352

5453
type case =
5554
| String(string)
5655
| Element(mdxComponent)
5756
| Array(array<mdxComponent>)
5857
| Unknown(unknown)
5958

60-
let classify = (Any(v): t): case =>
59+
let classify = (v: t): case =>
6160
if %raw(`function (a) { return a instanceof Array}`)(v) {
6261
Array((Obj.magic(v): array<mdxComponent>))
6362
} else if Js.typeof(v) == "string" {

common/MetaFrontmatter.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

common/MetaFrontmatter.res

Lines changed: 0 additions & 10 deletions
This file was deleted.

compilers/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# compilers
2+
3+
This folder is needed to install additional rescript compiler versions for testing our documented source code on multiple compiler versions.
4+
5+
Our `scripts/test-examples.js` script will automatically install all package.json dependencies if it cannot find any compiler versions.

compilers/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compilers/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "compilers",
3+
"private": true,
4+
"version": "1.0.0",
5+
"main": "index.js",
6+
"license": "MIT",
7+
"dependencies": {
8+
"rescript-820": "npm:bs-platform@8.2.0"
9+
}
10+
}

components/ApiMarkdown.res

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// This file was automatically converted to ReScript from 'ApiMarkdown.re'
2-
// Check the output and make sure to delete the original file
3-
open Util.ReactStuff
4-
51
/*
62
This module is intended for the ODOC like documentation layout.
73
It hides the h2 tags and does

components/Button.res

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
open Util.ReactStuff
2-
31
@react.component
42
let make = (~children) =>
53
<button

components/CodeMirror.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/CodeMirror.res

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ let useWindowWidth: unit => int = %raw(
5858
}
5959
return null;
6060
}
61-
` // Empty array ensures that effect is only run on mount and unmount
61+
`
6262
)
6363

6464
/* The module for interacting with the imperative CodeMirror API */
@@ -112,7 +112,7 @@ module CM = {
112112
@bs.send
113113
external setGutterMarker: (t, int, string, Dom.element) => unit = "setGutterMarker"
114114

115-
@bs.send external clearGutter: (t, string) => unit = ""
115+
@bs.send external clearGutter: (t, string) => unit = "clearGutter"
116116

117117
type markPos = {
118118
line: int,
@@ -211,7 +211,8 @@ module Error = {
211211

212212
module GutterMarker = {
213213
// Note: this is not a React component
214-
let make = (~rowCol: (int, int), ~kind: Error.kind, ~wrapper: Dom.element, ()): Dom.element => { // row, col
214+
let make = (~rowCol: (int, int), ~kind: Error.kind, ()): Dom.element => {
215+
// row, col
215216
open DomUtil
216217

217218
let marker = createElement("div")
@@ -269,7 +270,7 @@ let updateErrors = (~state: state, ~onMarkerFocus=?, ~onMarkerFocusLeave=?, ~cm:
269270
open DomUtil
270271
open Error
271272

272-
let marker = GutterMarker.make(~rowCol=(e.row, e.column), ~kind=e.kind, ~wrapper, ())
273+
let marker = GutterMarker.make(~rowCol=(e.row, e.column), ~kind=e.kind, ())
273274

274275
wrapper->appendChild(marker)
275276

@@ -361,13 +362,13 @@ let make = // props relevant for the react wrapper
361362
~lineWrapping=false,
362363
): React.element => {
363364
let inputElement = React.useRef(Js.Nullable.null)
364-
let cmRef: React.Ref.t<option<CM.t>> = React.useRef(None)
365+
let cmRef: React.ref<option<CM.t>> = React.useRef(None)
365366
let cmStateRef = React.useRef({marked: []})
366367

367368
let windowWidth = useWindowWidth()
368369

369370
React.useEffect0(() =>
370-
switch inputElement->React.Ref.current->Js.Nullable.toOption {
371+
switch inputElement.current->Js.Nullable.toOption {
371372
| Some(input) =>
372373
let options = CM.Options.t(
373374
~theme="material",
@@ -399,14 +400,14 @@ let make = // props relevant for the react wrapper
399400
// so we need to set the initial value imperatively
400401
cm->CM.setValue(value)
401402

402-
React.Ref.setCurrent(cmRef, Some(cm))
403+
cmRef.current = Some(cm)
403404

404405
let cleanup = () => {
405406
/* Js.log2("cleanup", options->CM.Options.mode); */
406407

407408
// This will destroy the CM instance
408409
cm->CM.toTextArea
409-
React.Ref.setCurrent(cmRef, None)
410+
cmRef.current = None
410411
}
411412

412413
Some(cleanup)
@@ -428,12 +429,12 @@ let make = // props relevant for the react wrapper
428429
By checking if the local state of the CM instance is different
429430
to the input value, we can sync up both states accordingly
430431
*/
431-
switch cmRef->React.Ref.current {
432+
switch cmRef.current {
432433
| Some(cm) =>
433434
if CM.getValue(cm) === value {
434435
()
435436
} else {
436-
let state = cmStateRef->React.Ref.current
437+
let state = cmStateRef.current
437438
cm->CM.operation(() =>
438439
updateErrors(~onMarkerFocus?, ~onMarkerFocusLeave?, ~state, ~cm, errors)
439440
)
@@ -454,8 +455,8 @@ let make = // props relevant for the react wrapper
454455
})->Js.Array2.joinWith(";")
455456

456457
React.useEffect1(() => {
457-
let state = cmStateRef->React.Ref.current
458-
switch cmRef->React.Ref.current {
458+
let state = cmStateRef.current
459+
switch cmRef.current {
459460
| Some(cm) =>
460461
cm->CM.operation(() =>
461462
updateErrors(~onMarkerFocus?, ~onMarkerFocusLeave?, ~state, ~cm, errors)
@@ -470,7 +471,7 @@ let make = // props relevant for the react wrapper
470471
a codemirror instance, or the window has been resized.
471472
*/
472473
React.useEffect2(() => {
473-
switch cmRef->React.Ref.current {
474+
switch cmRef.current {
474475
| Some(cm) => cm->CM.refresh
475476
| None => ()
476477
}

components/DocSearch.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/DocSearch.res

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,21 @@ let make = () => {
3737
let (state, setState) = React.useState(_ => Inactive)
3838

3939
let focusInput = () =>
40-
React.Ref.current(inputRef)->Js.Nullable.toOption->Belt.Option.forEach(el => el->focus)
40+
inputRef.current->Js.Nullable.toOption->Belt.Option.forEach(el => el->focus)
4141

4242
let clearInput = () =>
43-
React.Ref.current(inputRef)->Js.Nullable.toOption->Belt.Option.forEach(el => el->value(""))
43+
inputRef.current->Js.Nullable.toOption->Belt.Option.forEach(el => el->value(""))
4444

45-
let blurInput = () =>
46-
React.Ref.current(inputRef)->Js.Nullable.toOption->Belt.Option.forEach(el => el->blur)
45+
let blurInput = () => inputRef.current->Js.Nullable.toOption->Belt.Option.forEach(el => el->blur)
4746

48-
let onClick = evt => {
47+
let onClick = _ => {
4948
/* ReactEvent.Mouse.preventDefault(evt); */
5049
setState(_ => Active)
5150
clearInput()
5251
focusInput()
5352
}
5453

55-
let onBlur = evt => {
54+
let onBlur = _ => {
5655
/* ReactEvent.Focus.preventDefault(evt); */
5756
/* ReactEvent.Focus.stopPropagation(evt); */
5857
clearInput()
@@ -113,21 +112,21 @@ module Textbox = {
113112
let (state, setState) = React.useState(_ => Inactive)
114113

115114
let focusInput = () =>
116-
React.Ref.current(inputRef)->Js.Nullable.toOption->Belt.Option.forEach(el => el->focus)
115+
inputRef.current->Js.Nullable.toOption->Belt.Option.forEach(el => el->focus)
117116

118-
let clearInput = () =>
119-
React.Ref.current(inputRef)->Js.Nullable.toOption->Belt.Option.forEach(el => el->value(""))
117+
let _clearInput = () =>
118+
inputRef.current->Js.Nullable.toOption->Belt.Option.forEach(el => el->value(""))
120119

121120
let blurInput = () =>
122-
React.Ref.current(inputRef)->Js.Nullable.toOption->Belt.Option.forEach(el => el->blur)
121+
inputRef.current->Js.Nullable.toOption->Belt.Option.forEach(el => el->blur)
123122

124-
let onClick = evt => {
123+
let onClick = _ => {
125124
/* ReactEvent.Mouse.preventDefault(evt); */
126125
setState(_ => Active)
127126
focusInput()
128127
}
129128

130-
let onBlur = evt =>
129+
let onBlur = _ =>
131130
/* ReactEvent.Focus.preventDefault(evt); */
132131
/* ReactEvent.Focus.stopPropagation(evt); */
133132
setState(_ => Inactive)

components/Navigation.res

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ let linkOrActiveDocsSubroute = (~route) => {
3232
}
3333

3434
let githubHref = "https://github.com/reason-association/rescript-lang.org#rescript-langorg"
35-
let twitterHref = "https://twitter.com/rescriptlang"
35+
//let twitterHref = "https://twitter.com/rescriptlang"
3636
let discourseHref = "https://forum.rescript-lang.org"
3737

3838
module CollapsibleLink = {
@@ -43,11 +43,11 @@ module CollapsibleLink = {
4343
| Closed
4444

4545
@react.component
46-
let make = (
46+
let _make = (
4747
~title: string,
4848
~onStateChange: (~id: string, state) => unit,
4949
~allowHover=true,
50-
~allowInteraction=true,
50+
/* ~allowInteraction=true, */
5151
~id: string,
5252
~state: state,
5353
~active=false,
@@ -165,7 +165,7 @@ let useWindowWidth: unit => option<int> = %raw(
165165
}
166166
return null;
167167
}
168-
` // Empty array ensures that effect is only run on mount and unmount
168+
`
169169
)
170170

171171
type collapsible = {
@@ -175,10 +175,12 @@ type collapsible = {
175175
state: CollapsibleLink.state,
176176
}
177177

178+
@@warning("-60")
178179
module SubNav = {
180+
@@warning("-60")
179181
module DocsLinks = {
180182
@react.component
181-
let make = (~route: string) => {
183+
let _make = (~route: string) => {
182184
let reTheme = ColorTheme.toCN(#Reason)
183185
let jsTheme = ColorTheme.toCN(#Js)
184186

@@ -346,7 +348,7 @@ let make = (~fixed=true, ~overlayState: (bool, (bool => bool) => unit)) => {
346348

347349
let route = router.route
348350

349-
let (collapsibles, setCollapsibles) = React.useState(_ => [/* { */
351+
let (_collapsibles, setCollapsibles) = React.useState(_ => [/* { */
350352
/* title: "Docs", */
351353
/* href: "/docs", */
352354
/* children: route => { */
@@ -374,7 +376,7 @@ let make = (~fixed=true, ~overlayState: (bool, (bool => bool) => unit)) => {
374376
let windowWidth = useWindowWidth()
375377

376378
// Don't allow hover behavior for collapsibles if mobile navigation is on
377-
let allowHover = switch windowWidth {
379+
let _allowHover = switch windowWidth {
378380
| Some(width) => width > 576 // Value noted in tailwind config
379381
| None => true
380382
}

0 commit comments

Comments
 (0)