From c316eddbca5ca1defd5015bf49709902f11449a0 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Mon, 30 Jun 2025 16:03:06 -0300 Subject: [PATCH 1/4] [refactor]: unify api docs layout --- src/common/App.res | 36 +- src/layouts/ApiOverviewLayout.res | 57 ++-- src/layouts/ApiOverviewLayout.resi | 2 +- src/layouts/ApiOverviewLayout10_0_0.res | 38 --- src/layouts/ApiOverviewLayout10_0_0.resi | 4 - src/layouts/ApiOverviewLayout8_0_0.res | 46 --- src/layouts/ApiOverviewLayout8_0_0.resi | 4 - src/layouts/ApiOverviewLayout9_0_0.res | 46 --- src/layouts/ApiOverviewLayout9_0_0.resi | 4 - src/layouts/ApiOverviewLayoutLegacy.res | 406 +++++++++++++++++++++++ src/layouts/ApiOverviewLayoutLegacy.resi | 6 + src/layouts/BeltDocsLayout10_0_0.res | 152 --------- src/layouts/BeltDocsLayout10_0_0.resi | 9 - src/layouts/BeltDocsLayout8_0_0.res | 184 ---------- src/layouts/BeltDocsLayout8_0_0.resi | 9 - src/layouts/BeltDocsLayout9_0_0.res | 152 --------- src/layouts/DomDocsLayout10_0_0.res | 88 ----- src/layouts/DomDocsLayout10_0_0.resi | 9 - src/layouts/DomDocsLayout8_0_0.res | 93 ------ src/layouts/DomDocsLayout8_0_0.resi | 9 - src/layouts/DomDocsLayout9_0_0.res | 93 ------ src/layouts/DomDocsLayout9_0_0.resi | 8 - src/layouts/JsDocsLayout10_0_0.res | 196 ----------- src/layouts/JsDocsLayout10_0_0.resi | 9 - src/layouts/JsDocsLayout8_0_0.res | 206 ------------ src/layouts/JsDocsLayout8_0_0.resi | 9 - src/layouts/JsDocsLayout9_0_0.res | 206 ------------ 27 files changed, 454 insertions(+), 1627 deletions(-) delete mode 100644 src/layouts/ApiOverviewLayout10_0_0.res delete mode 100644 src/layouts/ApiOverviewLayout10_0_0.resi delete mode 100644 src/layouts/ApiOverviewLayout8_0_0.res delete mode 100644 src/layouts/ApiOverviewLayout8_0_0.resi delete mode 100644 src/layouts/ApiOverviewLayout9_0_0.res delete mode 100644 src/layouts/ApiOverviewLayout9_0_0.resi create mode 100644 src/layouts/ApiOverviewLayoutLegacy.res create mode 100644 src/layouts/ApiOverviewLayoutLegacy.resi delete mode 100644 src/layouts/BeltDocsLayout10_0_0.res delete mode 100644 src/layouts/BeltDocsLayout10_0_0.resi delete mode 100644 src/layouts/BeltDocsLayout8_0_0.res delete mode 100644 src/layouts/BeltDocsLayout8_0_0.resi delete mode 100644 src/layouts/BeltDocsLayout9_0_0.res delete mode 100644 src/layouts/DomDocsLayout10_0_0.res delete mode 100644 src/layouts/DomDocsLayout10_0_0.resi delete mode 100644 src/layouts/DomDocsLayout8_0_0.res delete mode 100644 src/layouts/DomDocsLayout8_0_0.resi delete mode 100644 src/layouts/DomDocsLayout9_0_0.res delete mode 100644 src/layouts/DomDocsLayout9_0_0.resi delete mode 100644 src/layouts/JsDocsLayout10_0_0.res delete mode 100644 src/layouts/JsDocsLayout10_0_0.resi delete mode 100644 src/layouts/JsDocsLayout8_0_0.res delete mode 100644 src/layouts/JsDocsLayout8_0_0.resi delete mode 100644 src/layouts/JsDocsLayout9_0_0.res diff --git a/src/common/App.res b/src/common/App.res index 78dfde1f5..e609801aa 100644 --- a/src/common/App.res +++ b/src/common/App.res @@ -59,41 +59,13 @@ let make = (props: props): React.element => { switch pagepath[0] { | Some("api") => switch url->Url.getVersionString { - | ("v11.0.0" | "v12.0.0") as version => + | "v11.0.0" | "v12.0.0" => switch (Array.length(pagepath), pagepath[1]) { - | (1, _) => content + | (1, _) => content | _ => content } - | "v8.0.0" => - switch (Array.length(pagepath), pagepath[1]) { - | (1, _) => content - | (2, Some("js")) => content - | (2, Some("belt")) => content - | (_, Some("js")) => content - | (_, Some("belt")) => content - | (_, Some("dom")) => content - | _ => React.null - } - | "v9.0.0" => - switch (Array.length(pagepath), pagepath[1]) { - | (1, _) => content - | (2, Some("js")) => content - | (2, Some("belt")) => content - | (_, Some("js")) => content - | (_, Some("belt")) => content - | (_, Some("dom")) => content - | _ => React.null - } - | "v10.0.0" => - switch (Array.length(pagepath), pagepath[1]) { - | (1, _) => content - | (2, Some("js")) => content - | (2, Some("belt")) => content - | (_, Some("js")) => content - | (_, Some("belt")) => content - | (_, Some("dom")) => content - | _ => React.null - } + | "v8.0.0" | "v9.0.0" | "v10.0.0" => + content | _ => content } | _ => diff --git a/src/layouts/ApiOverviewLayout.res b/src/layouts/ApiOverviewLayout.res index ab5b4225a..dc689ec0b 100644 --- a/src/layouts/ApiOverviewLayout.res +++ b/src/layouts/ApiOverviewLayout.res @@ -1,32 +1,49 @@ module Sidebar = SidebarLayout.Sidebar -let makeCategories: string => array = version => [ - { - name: "Overview", - items: [ - {name: "Introduction", href: `/docs/manual/${version}/api`}, - if version >= "v12.0.0" { - {name: "Stdlib", href: `/docs/manual/${version}/api/stdlib`} - } else { - {name: "Core", href: `/docs/manual/${version}/api/core`} +let makeCategories: Url.t => array = url => { + switch url.version { + | Version("v12.0.0" | "v11.0.0") | Latest | Next => + let version = Url.getVersionString(url) + [ + { + name: "Overview", + items: [ + {name: "Introduction", href: `/docs/manual/${version}/api`}, + if version >= "v12.0.0" { + {name: "Stdlib", href: `/docs/manual/${version}/api/stdlib`} + } else { + {name: "Core", href: `/docs/manual/${version}/api/core`} + }, + ], }, - ], - }, - { - name: "Additional Libraries", - items: [ - {name: "Belt", href: `/docs/manual/${version}/api/belt`}, - {name: "Dom", href: `/docs/manual/${version}/api/dom`}, - ], - }, -] + { + name: "Additional Libraries", + items: [ + {name: "Belt", href: `/docs/manual/${version}/api/belt`}, + {name: "Dom", href: `/docs/manual/${version}/api/dom`}, + ], + }, + ] + | _ => throw(Failure(`Invalid version ${url->Url.getVersionString}`)) + } +} /* Used for API docs (structured data) */ module Docs = { @react.component let make = (~version, ~components=ApiMarkdown.default, ~children) => { + let router = Next.Router.useRouter() + let route = router.route + let categories = makeCategories(version) + let versionStr = Url.getVersionString(version) - children + + {switch version.version { + | Version("v9.0.0" | "v8.0.0") => + | _ => React.null + }} + children + } } diff --git a/src/layouts/ApiOverviewLayout.resi b/src/layouts/ApiOverviewLayout.resi index d1c469d45..42406d13c 100644 --- a/src/layouts/ApiOverviewLayout.resi +++ b/src/layouts/ApiOverviewLayout.resi @@ -1,7 +1,7 @@ module Docs: { @react.component let make: ( - ~version: string, + ~version: Url.t, ~components: MarkdownComponents.t=?, ~children: React.element, ) => React.element diff --git a/src/layouts/ApiOverviewLayout10_0_0.res b/src/layouts/ApiOverviewLayout10_0_0.res deleted file mode 100644 index 1d43ca425..000000000 --- a/src/layouts/ApiOverviewLayout10_0_0.res +++ /dev/null @@ -1,38 +0,0 @@ -module Sidebar = SidebarLayout.Sidebar - -let categories: array = [ - { - name: "Introduction", - items: [{name: "Overview", href: "/docs/manual/v10.0.0/api"}], - }, - { - name: "Modules", - items: [ - {name: "Js Module", href: "/docs/manual/v10.0.0/api/js"}, - {name: "Belt Stdlib", href: "/docs/manual/v10.0.0/api/belt"}, - {name: "Dom Module", href: "/docs/manual/v10.0.0/api/dom"}, - ], - }, -] - -/* Used for API docs (structured data) */ -module Docs = { - @react.component - let make = (~components=ApiMarkdown.default, ~children) => { - let title = "API" - let version = "v10.0.0" - - children - } -} - -/* - This layout is used for structured prose text with proper H2 headings. - We cannot really use the same layout as with the Docs module, since they - have different semantic styling and do things such as hiding the text - of H2 nodes. - */ -/* module Prose = { */ -/* @react.component */ -/* let make = (~children) => children */ -/* } */ diff --git a/src/layouts/ApiOverviewLayout10_0_0.resi b/src/layouts/ApiOverviewLayout10_0_0.resi deleted file mode 100644 index 44164d31e..000000000 --- a/src/layouts/ApiOverviewLayout10_0_0.resi +++ /dev/null @@ -1,4 +0,0 @@ -module Docs: { - @react.component - let make: (~components: MarkdownComponents.t=?, ~children: React.element) => React.element -} diff --git a/src/layouts/ApiOverviewLayout8_0_0.res b/src/layouts/ApiOverviewLayout8_0_0.res deleted file mode 100644 index 2cdf8cf71..000000000 --- a/src/layouts/ApiOverviewLayout8_0_0.res +++ /dev/null @@ -1,46 +0,0 @@ -module Sidebar = SidebarLayout.Sidebar - -let categories: array = [ - { - name: "Introduction", - items: [{name: "Overview", href: "/docs/manual/v8.0.0/api"}], - }, - { - name: "Modules", - items: [ - {name: "Js Module", href: "/docs/manual/v8.0.0/api/js"}, - {name: "Belt Stdlib", href: "/docs/manual/v8.0.0/api/belt"}, - {name: "Dom Module", href: "/docs/manual/v8.0.0/api/dom"}, - ], - }, -] - -/* Used for API docs (structured data) */ -module Docs = { - @react.component - let make = (~components=ApiMarkdown.default, ~children) => { - let router = Next.Router.useRouter() - let route = router.route - - let title = "API" - let version = "v8.0.0" - - let warnBanner = - - - warnBanner - children - - } -} - -/* - This layout is used for structured prose text with proper H2 headings. - We cannot really use the same layout as with the Docs module, since they - have different semantic styling and do things such as hiding the text - of H2 nodes. - */ -/* module Prose = { */ -/* @react.component */ -/* let make = (~children) => children */ -/* } */ diff --git a/src/layouts/ApiOverviewLayout8_0_0.resi b/src/layouts/ApiOverviewLayout8_0_0.resi deleted file mode 100644 index 44164d31e..000000000 --- a/src/layouts/ApiOverviewLayout8_0_0.resi +++ /dev/null @@ -1,4 +0,0 @@ -module Docs: { - @react.component - let make: (~components: MarkdownComponents.t=?, ~children: React.element) => React.element -} diff --git a/src/layouts/ApiOverviewLayout9_0_0.res b/src/layouts/ApiOverviewLayout9_0_0.res deleted file mode 100644 index 8c229de4d..000000000 --- a/src/layouts/ApiOverviewLayout9_0_0.res +++ /dev/null @@ -1,46 +0,0 @@ -module Sidebar = SidebarLayout.Sidebar - -let categories: array = [ - { - name: "Introduction", - items: [{name: "Overview", href: "/docs/manual/v9.0.0/api"}], - }, - { - name: "Modules", - items: [ - {name: "Js Module", href: "/docs/manual/v9.0.0/api/js"}, - {name: "Belt Stdlib", href: "/docs/manual/v9.0.0/api/belt"}, - {name: "Dom Module", href: "/docs/manual/v9.0.0/api/dom"}, - ], - }, -] - -/* Used for API docs (structured data) */ -module Docs = { - @react.component - let make = (~components=ApiMarkdown.default, ~children) => { - let router = Next.Router.useRouter() - let route = router.route - - let title = "API" - let version = "v9.0.0" - - let warnBanner = - - - warnBanner - children - - } -} - -/* - This layout is used for structured prose text with proper H2 headings. - We cannot really use the same layout as with the Docs module, since they - have different semantic styling and do things such as hiding the text - of H2 nodes. - */ -/* module Prose = { */ -/* @react.component */ -/* let make = (~children) => children */ -/* } */ diff --git a/src/layouts/ApiOverviewLayout9_0_0.resi b/src/layouts/ApiOverviewLayout9_0_0.resi deleted file mode 100644 index 44164d31e..000000000 --- a/src/layouts/ApiOverviewLayout9_0_0.resi +++ /dev/null @@ -1,4 +0,0 @@ -module Docs: { - @react.component - let make: (~components: MarkdownComponents.t=?, ~children: React.element) => React.element -} diff --git a/src/layouts/ApiOverviewLayoutLegacy.res b/src/layouts/ApiOverviewLayoutLegacy.res new file mode 100644 index 000000000..719583ae4 --- /dev/null +++ b/src/layouts/ApiOverviewLayoutLegacy.res @@ -0,0 +1,406 @@ +type indexData = dict<{"moduleName": string, "headers": array<{"name": string, "href": string}>}> + +@module("index_data/v800_belt_api_index.json") +external belt_v8_data: indexData = "default" + +@module("index_data/v900_belt_api_index.json") +external belt_v9_data: indexData = "default" + +@module("index_data/v1000_belt_api_index.json") +external belt_v10_data: indexData = "default" + +@module("index_data/v800_js_api_index.json") +external js_v8_data: indexData = "default" + +@module("index_data/v900_js_api_index.json") +external js_v9_data: indexData = "default" + +@module("index_data/v1000_belt_api_index.json") +external js_v10_data: indexData = "default" + +@module("index_data/v800_dom_api_index.json") +external dom_v8_data: indexData = "default" + +@module("index_data/v900_dom_api_index.json") +external dom_v9_data: indexData = "default" + +@module("index_data/v1000_dom_api_index.json") +external dom_v10_data: indexData = "default" + +let indexData = dict{ + "belt": dict{ + "v8.0.0": belt_v8_data, + "v9.0.0": belt_v9_data, + "v10.0.0": belt_v10_data, + }, + "js": dict{ + "v8.0.0": js_v8_data, + "v9.0.0": js_v9_data, + "v10.0.0": js_v10_data, + }, + "dom": dict{ + "v8.0.0": dom_v8_data, + "v9.0.0": dom_v9_data, + "v10.0.0": dom_v10_data, + }, +} + +module Category = SidebarLayout.Sidebar.Category +module NavItem = SidebarLayout.Sidebar.NavItem + +module BeltDocs = { + let overviewNavs = [ + { + open NavItem + {name: "Introduction", href: "/docs/manual//api/belt"} + }, + ] + + let setNavs = [ + { + open NavItem + {name: "HashSet", href: "/docs/manual//api/belt/hash-set"} + }, + {name: "HashSetInt", href: "/docs/manual//api/belt/hash-set-int"}, + {name: "HashSetString", href: "/docs/manual//api/belt/hash-set-string"}, + {name: "Set", href: "/docs/manual//api/belt/set"}, + {name: "SetDict", href: "/docs/manual//api/belt/set-dict"}, + {name: "SetInt", href: "/docs/manual//api/belt/set-int"}, + {name: "SetString", href: "/docs/manual//api/belt/set-string"}, + ] + + let mapNavs = [ + { + open NavItem + {name: "HashMap", href: "/docs/manual//api/belt/hash-map"} + }, + {name: "HashMapInt", href: "/docs/manual//api/belt/hash-map-int"}, + {name: "HashMapString", href: "/docs/manual//api/belt/hash-map-string"}, + {name: "Map", href: "/docs/manual//api/belt/map"}, + {name: "MapDict", href: "/docs/manual//api/belt/map-dict"}, + {name: "MapInt", href: "/docs/manual//api/belt/map-int"}, + {name: "MapString", href: "/docs/manual//api/belt/map-string"}, + ] + + let mutableCollectionsNavs = [ + { + open NavItem + {name: "MutableMap", href: "/docs/manual//api/belt/mutable-map"} + }, + {name: "MutableMapInt", href: "/docs/manual//api/belt/mutable-map-int"}, + {name: "MutableMapString", href: "/docs/manual//api/belt/mutable-map-string"}, + {name: "MutableQueue", href: "/docs/manual//api/belt/mutable-queue"}, + {name: "MutableSet", href: "/docs/manual//api/belt/mutable-set"}, + {name: "MutableSetInt", href: "/docs/manual//api/belt/mutable-set-int"}, + {name: "MutableSetString", href: "/docs/manual//api/belt/mutable-set-string"}, + {name: "MutableStack", href: "/docs/manual//api/belt/mutable-stack"}, + ] + + let basicNavs = [ + { + open NavItem + {name: "Array", href: "/docs/manual//api/belt/array"} + }, + {name: "List", href: "/docs/manual//api/belt/list"}, + {name: "Float", href: "/docs/manual//api/belt/float"}, + {name: "Int", href: "/docs/manual//api/belt/int"}, + {name: "Range", href: "/docs/manual//api/belt/range"}, + {name: "Id", href: "/docs/manual//api/belt/id"}, + {name: "Option", href: "/docs/manual//api/belt/option"}, + {name: "Result", href: "/docs/manual//api/belt/result"}, + ] + + let sortNavs = [ + { + open NavItem + {name: "SortArray", href: "/docs/manual//api/belt/sort-array"} + }, + {name: "SortArrayInt", href: "/docs/manual//api/belt/sort-array-int"}, + {name: "SortArrayString", href: "/docs/manual//api/belt/sort-array-string"}, + ] + + let utilityNavs = [ + { + open NavItem + {name: "Debug", href: "/docs/manual//api/belt/debug"} + }, + ] + + let categories = [ + { + open Category + {name: "Overview", items: overviewNavs} + }, + {name: "Basics", items: basicNavs}, + {name: "Set", items: setNavs}, + {name: "Map", items: mapNavs}, + {name: "Mutable Collections", items: mutableCollectionsNavs}, + {name: "Sort Collections", items: sortNavs}, + {name: "Utilities", items: utilityNavs}, + ] +} + +module DomDocs = { + let overviewNavs = [ + { + open NavItem + {name: "Dom", href: "/docs/manual//api/dom"} + }, + ] + + let moduleNavs = [ + { + open NavItem + {name: "Storage", href: "/docs/manual//api/dom/storage"} + }, + { + open NavItem + {name: "Storage2", href: "/docs/manual//api/dom/storage2"} + }, + ] + + let categories = [ + { + open Category + {name: "Overview", items: overviewNavs} + }, + {name: "Submodules", items: moduleNavs}, + ] +} + +module JsDocs = { + let overviewNavs = [ + { + open NavItem + {name: "JS", href: "/docs/manual//api/js"} + }, + ] + + let apiNavs = [ + { + open NavItem + {name: "Array2", href: "/docs/manual//api/js/array-2"} + }, + {name: "Array", href: "/docs/manual//api/js/array"}, + {name: "Console", href: "/docs/manual//api/js/console"}, + {name: "Date", href: "/docs/manual//api/js/date"}, + {name: "Dict", href: "/docs/manual//api/js/dict"}, + {name: "Exn", href: "/docs/manual//api/js/exn"}, + {name: "Float", href: "/docs/manual//api/js/float"}, + {name: "Global", href: "/docs/manual//api/js/global"}, + {name: "Int", href: "/docs/manual//api/js/int"}, + {name: "Json", href: "/docs/manual//api/js/json"}, + {name: "List", href: "/docs/manual//api/js/list"}, + {name: "Math", href: "/docs/manual//api/js/math"}, + {name: "NullUndefined", href: "/docs/manual//api/js/null-undefined"}, + {name: "Null", href: "/docs/manual//api/js/null"}, + {name: "Nullable", href: "/docs/manual//api/js/nullable"}, + {name: "Obj", href: "/docs/manual//api/js/obj"}, + {name: "Option", href: "/docs/manual//api/js/option"}, + {name: "Promise", href: "/docs/manual//api/js/promise"}, + {name: "Re", href: "/docs/manual//api/js/re"}, + {name: "Result", href: "/docs/manual//api/js/result"}, + {name: "String2", href: "/docs/manual//api/js/string-2"}, + {name: "String", href: "/docs/manual//api/js/string"}, + { + name: "TypedArrayArrayBuffer", + href: "/docs/manual//api/js/typed-array_array-buffer", + }, + {name: "TypedArrayDataView", href: "/docs/manual//api/js/typed-array_data-view"}, + { + name: "TypedArrayFloat32Array", + href: "/docs/manual//api/js/typed-array_float-32-array", + }, + { + name: "TypedArrayFloat64Array", + href: "/docs/manual//api/js/typed-array_float-64-array", + }, + { + name: "TypedArrayInt8Array", + href: "/docs/manual//api/js/typed-array_int-8-array", + }, + { + name: "TypedArrayInt16Array", + href: "/docs/manual//api/js/typed-array_int-16-array", + }, + { + name: "TypedArrayInt32Array", + href: "/docs/manual//api/js/typed-array_int-32-array", + }, + {name: "TypedArrayTypeS", href: "/docs/manual//api/js/typed-array_type-s"}, + { + name: "TypedArrayUint8Array", + href: "/docs/manual//api/js/typed-array_uint-8-array", + }, + { + name: "TypedArrayUint8ClampedArray", + href: "/docs/manual//api/js/typed-array_uint-8-clamped-array", + }, + { + name: "TypedArrayUint16Array", + href: "/docs/manual//api/js/typed-array_uint-16-array", + }, + { + name: "TypedArrayUint32Array", + href: "/docs/manual//api/js/typed-array_uint-32-array", + }, + { + name: "TypedArray2ArrayBuffer", + href: "/docs/manual//api/js/typed-array-2_array-buffer", + }, + { + name: "TypedArray2DataView", + href: "/docs/manual//api/js/typed-array-2_data-view", + }, + { + name: "TypedArray2Float32Array", + href: "/docs/manual//api/js/typed-array-2_float-32-array", + }, + { + name: "TypedArray2Float64Array", + href: "/docs/manual//api/js/typed-array-2_float-64-array", + }, + { + name: "TypedArray2Int8Array", + href: "/docs/manual//api/js/typed-array-2_int-8-array", + }, + { + name: "TypedArray2Int16Array", + href: "/docs/manual//api/js/typed-array-2_int-16-array", + }, + { + name: "TypedArray2Int32Array", + href: "/docs/manual//api/js/typed-array-2_int-32-array", + }, + { + name: "TypedArray2Uint8Array", + href: "/docs/manual//api/js/typed-array-2_uint-8-array", + }, + { + name: "TypedArray2Uint8ClampedArray", + href: "/docs/manual//api/js/typed-array-2_uint-8-clamped-array", + }, + { + name: "TypedArray2Uint16Array", + href: "/docs/manual//api/js/typed-array-2_uint-16-array", + }, + { + name: "TypedArray2Uint32Array", + href: "/docs/manual//api/js/typed-array-2_uint-32-array", + }, + {name: "TypedArray2", href: "/docs/manual//api/js/typed-array-2"}, + {name: "TypedArray", href: "/docs/manual//api/js/typed-array"}, + {name: "Types", href: "/docs/manual//api/js/types"}, + {name: "Undefined", href: "/docs/manual//api/js/undefined"}, + {name: "Vector", href: "/docs/manual//api/js/vector"}, + ] + + let categories = [ + { + open Category + {name: "Overview", items: overviewNavs} + }, + {name: "Submodules", items: apiNavs}, + ] +} + +module type Docs = { + let categories: array +} + +let makeCategories = (module_: module(Docs), version) => { + let module(Docs) = module_ + Docs.categories->Array.map(({name, items}) => { + let items = items->Array.map(item => { + ...item, + href: item.href->String.replace("", version), + }) + {Category.name, items} + }) +} + +let moduleCategories = (moduleName, version) => { + switch moduleName { + | "belt" => makeCategories(module(BeltDocs), version) + | "js" => makeCategories(module(JsDocs), version) + | "dom" => makeCategories(module(DomDocs), version) + | _ => [] + } +} + +@react.component +let make = (~components=ApiMarkdown.default, ~version: Url.t, ~children) => { + let router = Next.Router.useRouter() + let route = router.route + let versionStr = version->Url.getVersionString + + let warnBanner = + + switch version.pagepath->Array.get(1) { + | None => + let title = "API" + let categories: array = [ + { + name: "Introduction", + items: [{name: "Overview", href: `/docs/manual/${versionStr}/api`}], + }, + { + name: "Modules", + items: [ + {name: "Js Module", href: `/docs/manual/${versionStr}/api/js`}, + {name: "Belt Stdlib", href: `/docs/manual/${versionStr}/api/belt`}, + {name: "Dom Module", href: `/docs/manual/${versionStr}/api/dom`}, + ], + }, + ] + + warnBanner + children + + | Some(moduleName) => + let indexData = switch Dict.get(indexData, moduleName) { + | Some(moduleData) => + Dict.get(moduleData, version->Url.getVersionString)->Option.getOrThrow( + ~message=`Not found data for ${moduleName} version ${versionStr}`, + ) + | None => throw(Failure(`Not found index data for module: ${moduleName}`)) + } + + // Gather data for the CollapsibleSection + let headers = { + open Option + Dict.get(indexData, route) + ->map(data => data["headers"]->Array.map(header => (header["name"], "#" ++ header["href"]))) + ->getOr([]) + } + + let prefix = { + open Url + {name: "API", href: "/docs/manual/" ++ (versionStr ++ "/api")} + } + + let breadcrumbs = ApiLayout.makeBreadcrumbs(~prefix, route) + + let activeToc = { + open SidebarLayout.Toc + { + title: moduleName, + entries: Array.map(headers, ((name, href)) => {header: name, href}), + } + } + + let categories = moduleCategories(moduleName, versionStr) + + let title = switch moduleName { + | "belt" => "Belt Stdlib" + | "js" => "Js Stdlib" + | "dom" => "Dom Stdlib" + | _ => assert(false) + } + + + warnBanner + children + + } +} diff --git a/src/layouts/ApiOverviewLayoutLegacy.resi b/src/layouts/ApiOverviewLayoutLegacy.resi new file mode 100644 index 000000000..85faa3f7a --- /dev/null +++ b/src/layouts/ApiOverviewLayoutLegacy.resi @@ -0,0 +1,6 @@ +@react.component +let make: ( + ~components: MarkdownComponents.t=?, + ~version: Url.t, + ~children: React.element, +) => React.element diff --git a/src/layouts/BeltDocsLayout10_0_0.res b/src/layouts/BeltDocsLayout10_0_0.res deleted file mode 100644 index 1a3e94d6a..000000000 --- a/src/layouts/BeltDocsLayout10_0_0.res +++ /dev/null @@ -1,152 +0,0 @@ -// Structure defined by `scripts/extract-indices.js` -@module("index_data/v1000_belt_api_index.json") -external indexData: Dict.t<{ - "moduleName": string, - "headers": array<{ - "name": string, - "href": string, - }>, -}> = "default" - -module Category = SidebarLayout.Sidebar.Category -module NavItem = SidebarLayout.Sidebar.NavItem - -let overviewNavs = [ - { - open NavItem - {name: "Introduction", href: "/docs/manual/v10.0.0/api/belt"} - }, -] - -let setNavs = [ - { - open NavItem - {name: "HashSet", href: "/docs/manual/v10.0.0/api/belt/hash-set"} - }, - {name: "HashSetInt", href: "/docs/manual/v10.0.0/api/belt/hash-set-int"}, - {name: "HashSetString", href: "/docs/manual/v10.0.0/api/belt/hash-set-string"}, - {name: "Set", href: "/docs/manual/v10.0.0/api/belt/set"}, - {name: "SetDict", href: "/docs/manual/v10.0.0/api/belt/set-dict"}, - {name: "SetInt", href: "/docs/manual/v10.0.0/api/belt/set-int"}, - {name: "SetString", href: "/docs/manual/v10.0.0/api/belt/set-string"}, -] - -let mapNavs = [ - { - open NavItem - {name: "HashMap", href: "/docs/manual/v10.0.0/api/belt/hash-map"} - }, - {name: "HashMapInt", href: "/docs/manual/v10.0.0/api/belt/hash-map-int"}, - {name: "HashMapString", href: "/docs/manual/v10.0.0/api/belt/hash-map-string"}, - {name: "Map", href: "/docs/manual/v10.0.0/api/belt/map"}, - {name: "MapDict", href: "/docs/manual/v10.0.0/api/belt/map-dict"}, - {name: "MapInt", href: "/docs/manual/v10.0.0/api/belt/map-int"}, - {name: "MapString", href: "/docs/manual/v10.0.0/api/belt/map-string"}, -] - -let mutableCollectionsNavs = [ - { - open NavItem - {name: "MutableMap", href: "/docs/manual/v10.0.0/api/belt/mutable-map"} - }, - {name: "MutableMapInt", href: "/docs/manual/v10.0.0/api/belt/mutable-map-int"}, - {name: "MutableMapString", href: "/docs/manual/v10.0.0/api/belt/mutable-map-string"}, - {name: "MutableQueue", href: "/docs/manual/v10.0.0/api/belt/mutable-queue"}, - {name: "MutableSet", href: "/docs/manual/v10.0.0/api/belt/mutable-set"}, - {name: "MutableSetInt", href: "/docs/manual/v10.0.0/api/belt/mutable-set-int"}, - {name: "MutableSetString", href: "/docs/manual/v10.0.0/api/belt/mutable-set-string"}, - {name: "MutableStack", href: "/docs/manual/v10.0.0/api/belt/mutable-stack"}, -] - -let basicNavs = [ - { - open NavItem - {name: "Array", href: "/docs/manual/v10.0.0/api/belt/array"} - }, - {name: "List", href: "/docs/manual/v10.0.0/api/belt/list"}, - {name: "Float", href: "/docs/manual/v10.0.0/api/belt/float"}, - {name: "Int", href: "/docs/manual/v10.0.0/api/belt/int"}, - {name: "Range", href: "/docs/manual/v10.0.0/api/belt/range"}, - {name: "Id", href: "/docs/manual/v10.0.0/api/belt/id"}, - {name: "Option", href: "/docs/manual/v10.0.0/api/belt/option"}, - {name: "Result", href: "/docs/manual/v10.0.0/api/belt/result"}, -] - -let sortNavs = [ - { - open NavItem - {name: "SortArray", href: "/docs/manual/v10.0.0/api/belt/sort-array"} - }, - {name: "SortArrayInt", href: "/docs/manual/v10.0.0/api/belt/sort-array-int"}, - {name: "SortArrayString", href: "/docs/manual/v10.0.0/api/belt/sort-array-string"}, -] - -let utilityNavs = [ - { - open NavItem - {name: "Debug", href: "/docs/manual/v10.0.0/api/belt/debug"} - }, -] - -let categories = [ - { - open Category - {name: "Overview", items: overviewNavs} - }, - {name: "Basics", items: basicNavs}, - {name: "Set", items: setNavs}, - {name: "Map", items: mapNavs}, - {name: "Mutable Collections", items: mutableCollectionsNavs}, - {name: "Sort Collections", items: sortNavs}, - {name: "Utilities", items: utilityNavs}, -] - -module Docs = { - @react.component - let make = (~components=ApiMarkdown.default, ~children) => { - let router = Next.Router.useRouter() - let route = router.route - - // Gather data for the CollapsibleSection - let headers = { - open Option - Dict.get(indexData, route) - ->map(data => data["headers"]->Array.map(header => (header["name"], "#" ++ header["href"]))) - ->getOr([]) - } - - let moduleName = { - open Option - Dict.get(indexData, route)->map(data => data["moduleName"])->getOr("?") - } - - let url = route->Url.parse - - let version = url->Url.getVersionString - - let prefix = { - open Url - {name: "API", href: "/docs/manual/" ++ (version ++ "/api")} - } - - let breadcrumbs = ApiLayout.makeBreadcrumbs(~prefix, route) - - let activeToc = { - open SidebarLayout.Toc - { - title: moduleName, - entries: Array.map(headers, ((name, href)) => {header: name, href}), - } - } - - let title = "Belt Stdlib" - let version = "v10.0.0" - - children - } -} - -module Prose = { - @react.component - let make = (~children) => children -} diff --git a/src/layouts/BeltDocsLayout10_0_0.resi b/src/layouts/BeltDocsLayout10_0_0.resi deleted file mode 100644 index 8e4b9eb04..000000000 --- a/src/layouts/BeltDocsLayout10_0_0.resi +++ /dev/null @@ -1,9 +0,0 @@ -module Docs: { - @react.component - let make: (~components: MarkdownComponents.t=?, ~children: React.element) => React.element -} - -module Prose: { - @react.component - let make: (~children: React.element) => React.element -} diff --git a/src/layouts/BeltDocsLayout8_0_0.res b/src/layouts/BeltDocsLayout8_0_0.res deleted file mode 100644 index 614adad86..000000000 --- a/src/layouts/BeltDocsLayout8_0_0.res +++ /dev/null @@ -1,184 +0,0 @@ -// Structure defined by `scripts/extract-indices.js` -@module("index_data/v800_belt_api_index.json") -external indexData: Dict.t<{ - "moduleName": string, - "headers": array<{ - "name": string, - "href": string, - }>, -}> = "default" - -module Category = SidebarLayout.Sidebar.Category -module NavItem = SidebarLayout.Sidebar.NavItem - -let overviewNavs = [ - { - open NavItem - {name: "Introduction", href: "/docs/manual/v8.0.0/api/belt"} - }, -] - -let setNavs = [ - { - open NavItem - {name: "HashSet", href: "/docs/manual/v8.0.0/api/belt/hash-set"} - }, - {name: "HashSetInt", href: "/docs/manual/v8.0.0/api/belt/hash-set-int"}, - { - name: "HashSetString", - href: "/docs/manual/v8.0.0/api/belt/hash-set-string", - }, - {name: "Set", href: "/docs/manual/v8.0.0/api/belt/set"}, - {name: "SetDict", href: "/docs/manual/v8.0.0/api/belt/set-dict"}, - {name: "SetInt", href: "/docs/manual/v8.0.0/api/belt/set-int"}, - {name: "SetString", href: "/docs/manual/v8.0.0/api/belt/set-string"}, -] - -let mapNavs = [ - { - open NavItem - {name: "HashMap", href: "/docs/manual/v8.0.0/api/belt/hash-map"} - }, - {name: "HashMapInt", href: "/docs/manual/v8.0.0/api/belt/hash-map-int"}, - { - name: "HashMapString", - href: "/docs/manual/v8.0.0/api/belt/hash-map-string", - }, - {name: "Map", href: "/docs/manual/v8.0.0/api/belt/map"}, - {name: "MapDict", href: "/docs/manual/v8.0.0/api/belt/map-dict"}, - {name: "MapInt", href: "/docs/manual/v8.0.0/api/belt/map-int"}, - {name: "MapString", href: "/docs/manual/v8.0.0/api/belt/map-string"}, -] - -let mutableCollectionsNavs = [ - { - open NavItem - { - name: "MutableMap", - href: "/docs/manual/v8.0.0/api/belt/mutable-map", - } - }, - { - name: "MutableMapInt", - href: "/docs/manual/v8.0.0/api/belt/mutable-map-int", - }, - { - name: "MutableMapString", - href: "/docs/manual/v8.0.0/api/belt/mutable-map-string", - }, - {name: "MutableQueue", href: "/docs/manual/v8.0.0/api/belt/mutable-queue"}, - {name: "MutableSet", href: "/docs/manual/v8.0.0/api/belt/mutable-set"}, - { - name: "MutableSetInt", - href: "/docs/manual/v8.0.0/api/belt/mutable-set-int", - }, - { - name: "MutableSetString", - href: "/docs/manual/v8.0.0/api/belt/mutable-set-string", - }, - {name: "MutableStack", href: "/docs/manual/v8.0.0/api/belt/mutable-stack"}, -] - -let basicNavs = [ - { - open NavItem - {name: "Array", href: "/docs/manual/v8.0.0/api/belt/array"} - }, - {name: "List", href: "/docs/manual/v8.0.0/api/belt/list"}, - {name: "Float", href: "/docs/manual/v8.0.0/api/belt/float"}, - {name: "Int", href: "/docs/manual/v8.0.0/api/belt/int"}, - {name: "Range", href: "/docs/manual/v8.0.0/api/belt/range"}, - {name: "Id", href: "/docs/manual/v8.0.0/api/belt/id"}, - {name: "Option", href: "/docs/manual/v8.0.0/api/belt/option"}, - {name: "Result", href: "/docs/manual/v8.0.0/api/belt/result"}, -] - -let sortNavs = [ - { - open NavItem - { - name: "SortArray", - href: "/docs/manual/v8.0.0/api/belt/sort-array", - } - }, - {name: "SortArrayInt", href: "/docs/manual/v8.0.0/api/belt/sort-array-int"}, - { - name: "SortArrayString", - href: "/docs/manual/v8.0.0/api/belt/sort-array-string", - }, -] - -let utilityNavs = [ - { - open NavItem - {name: "Debug", href: "/docs/manual/v8.0.0/api/belt/debug"} - }, -] - -let categories = [ - { - open Category - {name: "Overview", items: overviewNavs} - }, - {name: "Basics", items: basicNavs}, - {name: "Set", items: setNavs}, - {name: "Map", items: mapNavs}, - {name: "Mutable Collections", items: mutableCollectionsNavs}, - {name: "Sort Collections", items: sortNavs}, - {name: "Utilities", items: utilityNavs}, -] - -module Docs = { - @react.component - let make = (~components=ApiMarkdown.default, ~children) => { - let router = Next.Router.useRouter() - let route = router.route - - // Gather data for the CollapsibleSection - let headers = { - open Option - Dict.get(indexData, route) - ->map(data => data["headers"]->Array.map(header => (header["name"], "#" ++ header["href"]))) - ->getOr([]) - } - - let moduleName = { - open Option - Dict.get(indexData, route)->map(data => data["moduleName"])->getOr("?") - } - - let url = route->Url.parse - - let version = url->Url.getVersionString - - let prefix = { - open Url - {name: "API", href: "/docs/manual/" ++ (version ++ "/api")} - } - - let breadcrumbs = ApiLayout.makeBreadcrumbs(~prefix, route) - - let activeToc = { - open SidebarLayout.Toc - { - title: moduleName, - entries: Array.map(headers, ((name, href)) => {header: name, href}), - } - } - - let title = "Belt Stdlib" - let version = "v8.0.0" - - let warnBanner = - - - warnBanner - children - - } -} - -module Prose = { - @react.component - let make = (~children) => children -} diff --git a/src/layouts/BeltDocsLayout8_0_0.resi b/src/layouts/BeltDocsLayout8_0_0.resi deleted file mode 100644 index 8e4b9eb04..000000000 --- a/src/layouts/BeltDocsLayout8_0_0.resi +++ /dev/null @@ -1,9 +0,0 @@ -module Docs: { - @react.component - let make: (~components: MarkdownComponents.t=?, ~children: React.element) => React.element -} - -module Prose: { - @react.component - let make: (~children: React.element) => React.element -} diff --git a/src/layouts/BeltDocsLayout9_0_0.res b/src/layouts/BeltDocsLayout9_0_0.res deleted file mode 100644 index c40eb5a4c..000000000 --- a/src/layouts/BeltDocsLayout9_0_0.res +++ /dev/null @@ -1,152 +0,0 @@ -// Structure defined by `scripts/extract-indices.js` -@module("index_data/v900_belt_api_index.json") -external indexData: Dict.t<{ - "moduleName": string, - "headers": array<{ - "name": string, - "href": string, - }>, -}> = "default" - -module Category = SidebarLayout.Sidebar.Category -module NavItem = SidebarLayout.Sidebar.NavItem - -let overviewNavs = [ - { - open NavItem - {name: "Introduction", href: "/docs/manual/v9.0.0/api/belt"} - }, -] - -let setNavs = [ - { - open NavItem - {name: "HashSet", href: "/docs/manual/v9.0.0/api/belt/hash-set"} - }, - {name: "HashSetInt", href: "/docs/manual/v9.0.0/api/belt/hash-set-int"}, - {name: "HashSetString", href: "/docs/manual/v9.0.0/api/belt/hash-set-string"}, - {name: "Set", href: "/docs/manual/v9.0.0/api/belt/set"}, - {name: "SetDict", href: "/docs/manual/v9.0.0/api/belt/set-dict"}, - {name: "SetInt", href: "/docs/manual/v9.0.0/api/belt/set-int"}, - {name: "SetString", href: "/docs/manual/v9.0.0/api/belt/set-string"}, -] - -let mapNavs = [ - { - open NavItem - {name: "HashMap", href: "/docs/manual/v9.0.0/api/belt/hash-map"} - }, - {name: "HashMapInt", href: "/docs/manual/v9.0.0/api/belt/hash-map-int"}, - {name: "HashMapString", href: "/docs/manual/v9.0.0/api/belt/hash-map-string"}, - {name: "Map", href: "/docs/manual/v9.0.0/api/belt/map"}, - {name: "MapDict", href: "/docs/manual/v9.0.0/api/belt/map-dict"}, - {name: "MapInt", href: "/docs/manual/v9.0.0/api/belt/map-int"}, - {name: "MapString", href: "/docs/manual/v9.0.0/api/belt/map-string"}, -] - -let mutableCollectionsNavs = [ - { - open NavItem - {name: "MutableMap", href: "/docs/manual/v9.0.0/api/belt/mutable-map"} - }, - {name: "MutableMapInt", href: "/docs/manual/v9.0.0/api/belt/mutable-map-int"}, - {name: "MutableMapString", href: "/docs/manual/v9.0.0/api/belt/mutable-map-string"}, - {name: "MutableQueue", href: "/docs/manual/v9.0.0/api/belt/mutable-queue"}, - {name: "MutableSet", href: "/docs/manual/v9.0.0/api/belt/mutable-set"}, - {name: "MutableSetInt", href: "/docs/manual/v9.0.0/api/belt/mutable-set-int"}, - {name: "MutableSetString", href: "/docs/manual/v9.0.0/api/belt/mutable-set-string"}, - {name: "MutableStack", href: "/docs/manual/v9.0.0/api/belt/mutable-stack"}, -] - -let basicNavs = [ - { - open NavItem - {name: "Array", href: "/docs/manual/v9.0.0/api/belt/array"} - }, - {name: "List", href: "/docs/manual/v9.0.0/api/belt/list"}, - {name: "Float", href: "/docs/manual/v9.0.0/api/belt/float"}, - {name: "Int", href: "/docs/manual/v9.0.0/api/belt/int"}, - {name: "Range", href: "/docs/manual/v9.0.0/api/belt/range"}, - {name: "Id", href: "/docs/manual/v9.0.0/api/belt/id"}, - {name: "Option", href: "/docs/manual/v9.0.0/api/belt/option"}, - {name: "Result", href: "/docs/manual/v9.0.0/api/belt/result"}, -] - -let sortNavs = [ - { - open NavItem - {name: "SortArray", href: "/docs/manual/v9.0.0/api/belt/sort-array"} - }, - {name: "SortArrayInt", href: "/docs/manual/v9.0.0/api/belt/sort-array-int"}, - {name: "SortArrayString", href: "/docs/manual/v9.0.0/api/belt/sort-array-string"}, -] - -let utilityNavs = [ - { - open NavItem - {name: "Debug", href: "/docs/manual/v9.0.0/api/belt/debug"} - }, -] - -let categories = [ - { - open Category - {name: "Overview", items: overviewNavs} - }, - {name: "Basics", items: basicNavs}, - {name: "Set", items: setNavs}, - {name: "Map", items: mapNavs}, - {name: "Mutable Collections", items: mutableCollectionsNavs}, - {name: "Sort Collections", items: sortNavs}, - {name: "Utilities", items: utilityNavs}, -] - -module Docs = { - @react.component - let make = (~components=ApiMarkdown.default, ~children) => { - let router = Next.Router.useRouter() - let route = router.route - - // Gather data for the CollapsibleSection - let headers = { - open Option - Dict.get(indexData, route) - ->map(data => data["headers"]->Array.map(header => (header["name"], "#" ++ header["href"]))) - ->getOr([]) - } - - let moduleName = { - open Option - Dict.get(indexData, route)->map(data => data["moduleName"])->getOr("?") - } - - let url = route->Url.parse - - let version = url->Url.getVersionString - - let prefix = { - open Url - {name: "API", href: "/docs/manual/" ++ (version ++ "/api")} - } - - let breadcrumbs = ApiLayout.makeBreadcrumbs(~prefix, route) - - let activeToc = { - open SidebarLayout.Toc - { - title: moduleName, - entries: Array.map(headers, ((name, href)) => {header: name, href}), - } - } - - let title = "Belt Stdlib" - let version = "latest" - - children - } -} - -module Prose = { - @react.component - let make = (~children) => children -} diff --git a/src/layouts/DomDocsLayout10_0_0.res b/src/layouts/DomDocsLayout10_0_0.res deleted file mode 100644 index 73bd5a4c0..000000000 --- a/src/layouts/DomDocsLayout10_0_0.res +++ /dev/null @@ -1,88 +0,0 @@ -// Structure defined by `scripts/extract-indices.js` -@module("index_data/v1000_dom_api_index.json") -external indexData: Dict.t<{ - "moduleName": string, - "headers": array<{ - "name": string, - "href": string, - }>, -}> = "default" - -module Category = SidebarLayout.Sidebar.Category -module NavItem = SidebarLayout.Sidebar.NavItem - -let overviewNavs = [ - { - open NavItem - {name: "Dom", href: "/docs/manual/v9.0.0/api/dom"} - }, -] - -let moduleNavs = [ - { - open NavItem - {name: "Storage", href: "/docs/manual/v9.0.0/api/dom/storage"} - }, - { - open NavItem - {name: "Storage2", href: "/docs/manual/v9.0.0/api/dom/storage2"} - }, -] - -let categories = [ - { - open Category - {name: "Overview", items: overviewNavs} - }, - {name: "Submodules", items: moduleNavs}, -] - -module Docs = { - @react.component - let make = (~components=ApiMarkdown.default, ~children) => { - let router = Next.Router.useRouter() - let route = router.route - - // Gather data for the CollapsibleSection - let headers = { - open Option - Dict.get(indexData, route) - ->map(data => data["headers"]->Array.map(header => (header["name"], "#" ++ header["href"]))) - ->getOr([]) - } - - let moduleName = { - open Option - Dict.get(indexData, route)->map(data => data["moduleName"])->getOr("?") - } - - let url = route->Url.parse - - let version = url->Url.getVersionString - - let prefix = { - open Url - {name: "API", href: "/docs/manual/" ++ (version ++ "/api")} - } - - let breadcrumbs = ApiLayout.makeBreadcrumbs(~prefix, route) - - let activeToc = { - open SidebarLayout.Toc - { - title: moduleName, - entries: Array.map(headers, ((name, href)) => {header: name, href}), - } - } - - let title = "Dom Module" - let version = "v9.0.0" - - children - } -} - -module Prose = { - @react.component - let make = (~children) => children -} diff --git a/src/layouts/DomDocsLayout10_0_0.resi b/src/layouts/DomDocsLayout10_0_0.resi deleted file mode 100644 index 8e4b9eb04..000000000 --- a/src/layouts/DomDocsLayout10_0_0.resi +++ /dev/null @@ -1,9 +0,0 @@ -module Docs: { - @react.component - let make: (~components: MarkdownComponents.t=?, ~children: React.element) => React.element -} - -module Prose: { - @react.component - let make: (~children: React.element) => React.element -} diff --git a/src/layouts/DomDocsLayout8_0_0.res b/src/layouts/DomDocsLayout8_0_0.res deleted file mode 100644 index 259dcbb88..000000000 --- a/src/layouts/DomDocsLayout8_0_0.res +++ /dev/null @@ -1,93 +0,0 @@ -// Structure defined by `scripts/extract-indices.js` -@module("index_data/v800_dom_api_index.json") -external indexData: Dict.t<{ - "moduleName": string, - "headers": array<{ - "name": string, - "href": string, - }>, -}> = "default" - -module Category = SidebarLayout.Sidebar.Category -module NavItem = SidebarLayout.Sidebar.NavItem - -let overviewNavs = [ - { - open NavItem - {name: "Dom", href: "/docs/manual/v8.0.0/api/dom"} - }, -] - -let moduleNavs = [ - { - open NavItem - {name: "Storage", href: "/docs/manual/v8.0.0/api/dom/storage"} - }, - { - open NavItem - {name: "Storage2", href: "/docs/manual/v8.0.0/api/dom/storage2"} - }, -] - -let categories = [ - { - open Category - {name: "Overview", items: overviewNavs} - }, - {name: "Submodules", items: moduleNavs}, -] - -module Docs = { - @react.component - let make = (~components=ApiMarkdown.default, ~children) => { - let router = Next.Router.useRouter() - let route = router.route - - // Gather data for the CollapsibleSection - let headers = { - open Option - Dict.get(indexData, route) - ->map(data => data["headers"]->Array.map(header => (header["name"], "#" ++ header["href"]))) - ->getOr([]) - } - - let moduleName = { - open Option - Dict.get(indexData, route)->map(data => data["moduleName"])->getOr("?") - } - - let url = route->Url.parse - - let version = url->Url.getVersionString - - let prefix = { - open Url - {name: "API", href: "/docs/manual/" ++ (version ++ "/api")} - } - - let breadcrumbs = ApiLayout.makeBreadcrumbs(~prefix, route) - - let activeToc = { - open SidebarLayout.Toc - { - title: moduleName, - entries: Array.map(headers, ((name, href)) => {header: name, href}), - } - } - - let title = "Dom Module" - let version = "v8.0.0" - - let warnBanner = - - - warnBanner - children - - } -} - -module Prose = { - @react.component - let make = (~children) => children -} diff --git a/src/layouts/DomDocsLayout8_0_0.resi b/src/layouts/DomDocsLayout8_0_0.resi deleted file mode 100644 index 8e4b9eb04..000000000 --- a/src/layouts/DomDocsLayout8_0_0.resi +++ /dev/null @@ -1,9 +0,0 @@ -module Docs: { - @react.component - let make: (~components: MarkdownComponents.t=?, ~children: React.element) => React.element -} - -module Prose: { - @react.component - let make: (~children: React.element) => React.element -} diff --git a/src/layouts/DomDocsLayout9_0_0.res b/src/layouts/DomDocsLayout9_0_0.res deleted file mode 100644 index 79827dc7d..000000000 --- a/src/layouts/DomDocsLayout9_0_0.res +++ /dev/null @@ -1,93 +0,0 @@ -// Structure defined by `scripts/extract-indices.js` -@module("index_data/v900_dom_api_index.json") -external indexData: Dict.t<{ - "moduleName": string, - "headers": array<{ - "name": string, - "href": string, - }>, -}> = "default" - -module Category = SidebarLayout.Sidebar.Category -module NavItem = SidebarLayout.Sidebar.NavItem - -let overviewNavs = [ - { - open NavItem - {name: "Dom", href: "/docs/manual/v9.0.0/api/dom"} - }, -] - -let moduleNavs = [ - { - open NavItem - {name: "Storage", href: "/docs/manual/v9.0.0/api/dom/storage"} - }, - { - open NavItem - {name: "Storage2", href: "/docs/manual/v9.0.0/api/dom/storage2"} - }, -] - -let categories = [ - { - open Category - {name: "Overview", items: overviewNavs} - }, - {name: "Submodules", items: moduleNavs}, -] - -module Docs = { - @react.component - let make = (~components=ApiMarkdown.default, ~children) => { - let router = Next.Router.useRouter() - let route = router.route - - // Gather data for the CollapsibleSection - let headers = { - open Option - Dict.get(indexData, route) - ->map(data => data["headers"]->Array.map(header => (header["name"], "#" ++ header["href"]))) - ->getOr([]) - } - - let moduleName = { - open Option - Dict.get(indexData, route)->map(data => data["moduleName"])->getOr("?") - } - - let url = route->Url.parse - - let version = url->Url.getVersionString - - let prefix = { - open Url - {name: "API", href: "/docs/manual/" ++ (version ++ "/api")} - } - - let breadcrumbs = ApiLayout.makeBreadcrumbs(~prefix, route) - - let activeToc = { - open SidebarLayout.Toc - { - title: moduleName, - entries: Array.map(headers, ((name, href)) => {header: name, href}), - } - } - - let title = "Dom Module" - let version = "v9.0.0" - - let warnBanner = - - - warnBanner - children - - } -} - -module Prose = { - @react.component - let make = (~children) => children -} diff --git a/src/layouts/DomDocsLayout9_0_0.resi b/src/layouts/DomDocsLayout9_0_0.resi deleted file mode 100644 index 3f9b2e92a..000000000 --- a/src/layouts/DomDocsLayout9_0_0.resi +++ /dev/null @@ -1,8 +0,0 @@ -module Docs: { - @react.component - let make: (~components: MarkdownComponents.t=?, ~children: React.element) => React.element -} -module Prose: { - @react.component - let make: (~children: React.element) => React.element -} diff --git a/src/layouts/JsDocsLayout10_0_0.res b/src/layouts/JsDocsLayout10_0_0.res deleted file mode 100644 index d44dbf21c..000000000 --- a/src/layouts/JsDocsLayout10_0_0.res +++ /dev/null @@ -1,196 +0,0 @@ -// Structure defined by `scripts/extract-indices.js` -@module("index_data/v1000_js_api_index.json") -external indexData: Dict.t<{ - "moduleName": string, - "headers": array<{ - "name": string, - "href": string, - }>, -}> = "default" - -module Category = SidebarLayout.Sidebar.Category -module NavItem = SidebarLayout.Sidebar.NavItem - -let overviewNavs = [ - { - open NavItem - {name: "JS", href: "/docs/manual/v10.0.0/api/js"} - }, -] - -let apiNavs = [ - { - open NavItem - {name: "Array2", href: "/docs/manual/v10.0.0/api/js/array-2"} - }, - {name: "Array", href: "/docs/manual/v10.0.0/api/js/array"}, - {name: "Console", href: "/docs/manual/v10.0.0/api/js/console"}, - {name: "Date", href: "/docs/manual/v10.0.0/api/js/date"}, - {name: "Dict", href: "/docs/manual/v10.0.0/api/js/dict"}, - {name: "Exn", href: "/docs/manual/v10.0.0/api/js/exn"}, - {name: "Float", href: "/docs/manual/v10.0.0/api/js/float"}, - {name: "Global", href: "/docs/manual/v10.0.0/api/js/global"}, - {name: "Int", href: "/docs/manual/v10.0.0/api/js/int"}, - {name: "Json", href: "/docs/manual/v10.0.0/api/js/json"}, - {name: "List", href: "/docs/manual/v10.0.0/api/js/list"}, - {name: "Math", href: "/docs/manual/v10.0.0/api/js/math"}, - {name: "NullUndefined", href: "/docs/manual/v10.0.0/api/js/null-undefined"}, - {name: "Null", href: "/docs/manual/v10.0.0/api/js/null"}, - {name: "Nullable", href: "/docs/manual/v10.0.0/api/js/nullable"}, - {name: "Obj", href: "/docs/manual/v10.0.0/api/js/obj"}, - {name: "Option", href: "/docs/manual/v10.0.0/api/js/option"}, - {name: "Promise", href: "/docs/manual/v10.0.0/api/js/promise"}, - {name: "Re", href: "/docs/manual/v10.0.0/api/js/re"}, - {name: "Result", href: "/docs/manual/v10.0.0/api/js/result"}, - {name: "String2", href: "/docs/manual/v10.0.0/api/js/string-2"}, - {name: "String", href: "/docs/manual/v10.0.0/api/js/string"}, - { - name: "TypedArrayArrayBuffer", - href: "/docs/manual/v10.0.0/api/js/typed-array_array-buffer", - }, - {name: "TypedArrayDataView", href: "/docs/manual/v10.0.0/api/js/typed-array_data-view"}, - { - name: "TypedArrayFloat32Array", - href: "/docs/manual/v10.0.0/api/js/typed-array_float-32-array", - }, - { - name: "TypedArrayFloat64Array", - href: "/docs/manual/v10.0.0/api/js/typed-array_float-64-array", - }, - { - name: "TypedArrayInt8Array", - href: "/docs/manual/v10.0.0/api/js/typed-array_int-8-array", - }, - { - name: "TypedArrayInt16Array", - href: "/docs/manual/v10.0.0/api/js/typed-array_int-16-array", - }, - { - name: "TypedArrayInt32Array", - href: "/docs/manual/v10.0.0/api/js/typed-array_int-32-array", - }, - {name: "TypedArrayTypeS", href: "/docs/manual/v10.0.0/api/js/typed-array_type-s"}, - { - name: "TypedArrayUint8Array", - href: "/docs/manual/v10.0.0/api/js/typed-array_uint-8-array", - }, - { - name: "TypedArrayUint8ClampedArray", - href: "/docs/manual/v10.0.0/api/js/typed-array_uint-8-clamped-array", - }, - { - name: "TypedArrayUint16Array", - href: "/docs/manual/v10.0.0/api/js/typed-array_uint-16-array", - }, - { - name: "TypedArrayUint32Array", - href: "/docs/manual/v10.0.0/api/js/typed-array_uint-32-array", - }, - { - name: "TypedArray2ArrayBuffer", - href: "/docs/manual/v10.0.0/api/js/typed-array-2_array-buffer", - }, - { - name: "TypedArray2DataView", - href: "/docs/manual/v10.0.0/api/js/typed-array-2_data-view", - }, - { - name: "TypedArray2Float32Array", - href: "/docs/manual/v10.0.0/api/js/typed-array-2_float-32-array", - }, - { - name: "TypedArray2Float64Array", - href: "/docs/manual/v10.0.0/api/js/typed-array-2_float-64-array", - }, - { - name: "TypedArray2Int8Array", - href: "/docs/manual/v10.0.0/api/js/typed-array-2_int-8-array", - }, - { - name: "TypedArray2Int16Array", - href: "/docs/manual/v10.0.0/api/js/typed-array-2_int-16-array", - }, - { - name: "TypedArray2Int32Array", - href: "/docs/manual/v10.0.0/api/js/typed-array-2_int-32-array", - }, - { - name: "TypedArray2Uint8Array", - href: "/docs/manual/v10.0.0/api/js/typed-array-2_uint-8-array", - }, - { - name: "TypedArray2Uint8ClampedArray", - href: "/docs/manual/v10.0.0/api/js/typed-array-2_uint-8-clamped-array", - }, - { - name: "TypedArray2Uint16Array", - href: "/docs/manual/v10.0.0/api/js/typed-array-2_uint-16-array", - }, - { - name: "TypedArray2Uint32Array", - href: "/docs/manual/v10.0.0/api/js/typed-array-2_uint-32-array", - }, - {name: "TypedArray2", href: "/docs/manual/v10.0.0/api/js/typed-array-2"}, - {name: "TypedArray", href: "/docs/manual/v10.0.0/api/js/typed-array"}, - {name: "Types", href: "/docs/manual/v10.0.0/api/js/types"}, - {name: "Undefined", href: "/docs/manual/v10.0.0/api/js/undefined"}, - {name: "Vector", href: "/docs/manual/v10.0.0/api/js/vector"}, -] - -let categories = [ - { - open Category - {name: "Overview", items: overviewNavs} - }, - {name: "Submodules", items: apiNavs}, -] - -module Docs = { - @react.component - let make = (~components=ApiMarkdown.default, ~children) => { - let router = Next.Router.useRouter() - let route = router.route - - // Gather data for the CollapsibleSection - let headers = { - open Option - Dict.get(indexData, route) - ->map(data => data["headers"]->Array.map(header => (header["name"], "#" ++ header["href"]))) - ->getOr([]) - } - - let moduleName = { - open Option - Dict.get(indexData, route)->map(data => data["moduleName"])->getOr("?") - } - - let url = route->Url.parse - - let version = url->Url.getVersionString - - let prefix = { - open Url - {name: "API", href: "/docs/manual/" ++ (version ++ "/api")} - } - - let breadcrumbs = ApiLayout.makeBreadcrumbs(~prefix, route) - - let activeToc = { - open SidebarLayout.Toc - { - title: moduleName, - entries: Array.map(headers, ((name, href)) => {header: name, href}), - } - } - - let title = "JS Module" - let version = "v10.0.0" - - children - } -} - -module Prose = { - @react.component - let make = (~children) => children -} diff --git a/src/layouts/JsDocsLayout10_0_0.resi b/src/layouts/JsDocsLayout10_0_0.resi deleted file mode 100644 index 8e4b9eb04..000000000 --- a/src/layouts/JsDocsLayout10_0_0.resi +++ /dev/null @@ -1,9 +0,0 @@ -module Docs: { - @react.component - let make: (~components: MarkdownComponents.t=?, ~children: React.element) => React.element -} - -module Prose: { - @react.component - let make: (~children: React.element) => React.element -} diff --git a/src/layouts/JsDocsLayout8_0_0.res b/src/layouts/JsDocsLayout8_0_0.res deleted file mode 100644 index 31681f9bc..000000000 --- a/src/layouts/JsDocsLayout8_0_0.res +++ /dev/null @@ -1,206 +0,0 @@ -// Structure defined by `scripts/extract-indices.js` -@module("index_data/v800_js_api_index.json") -external indexData: Dict.t<{ - "moduleName": string, - "headers": array<{ - "name": string, - "href": string, - }>, -}> = "default" - -module Category = SidebarLayout.Sidebar.Category -module NavItem = SidebarLayout.Sidebar.NavItem - -let overviewNavs = [ - { - open NavItem - {name: "JS", href: "/docs/manual/v8.0.0/api/js"} - }, -] - -let apiNavs = [ - { - open NavItem - {name: "Array2", href: "/docs/manual/v8.0.0/api/js/array-2"} - }, - {name: "Array", href: "/docs/manual/v8.0.0/api/js/array"}, - {name: "Console", href: "/docs/manual/v8.0.0/api/js/console"}, - {name: "Date", href: "/docs/manual/v8.0.0/api/js/date"}, - {name: "Dict", href: "/docs/manual/v8.0.0/api/js/dict"}, - {name: "Exn", href: "/docs/manual/v8.0.0/api/js/exn"}, - {name: "Float", href: "/docs/manual/v8.0.0/api/js/float"}, - {name: "Global", href: "/docs/manual/v8.0.0/api/js/global"}, - {name: "Int", href: "/docs/manual/v8.0.0/api/js/int"}, - {name: "Json", href: "/docs/manual/v8.0.0/api/js/json"}, - {name: "List", href: "/docs/manual/v8.0.0/api/js/list"}, - {name: "Math", href: "/docs/manual/v8.0.0/api/js/math"}, - {name: "NullUndefined", href: "/docs/manual/v8.0.0/api/js/null-undefined"}, - {name: "Null", href: "/docs/manual/v8.0.0/api/js/null"}, - {name: "Nullable", href: "/docs/manual/v8.0.0/api/js/nullable"}, - {name: "Obj", href: "/docs/manual/v8.0.0/api/js/obj"}, - {name: "Option", href: "/docs/manual/v8.0.0/api/js/option"}, - {name: "Promise", href: "/docs/manual/v8.0.0/api/js/promise"}, - {name: "Re", href: "/docs/manual/v8.0.0/api/js/re"}, - {name: "Result", href: "/docs/manual/v8.0.0/api/js/result"}, - {name: "String2", href: "/docs/manual/v8.0.0/api/js/string-2"}, - {name: "String", href: "/docs/manual/v8.0.0/api/js/string"}, - { - name: "TypedArrayArrayBuffer", - href: "/docs/manual/v8.0.0/api/js/typed-array_array-buffer", - }, - { - name: "TypedArrayDataView", - href: "/docs/manual/v8.0.0/api/js/typed-array_data-view", - }, - { - name: "TypedArrayFloat32Array", - href: "/docs/manual/v8.0.0/api/js/typed-array_float-32-array", - }, - { - name: "TypedArrayFloat64Array", - href: "/docs/manual/v8.0.0/api/js/typed-array_float-64-array", - }, - { - name: "TypedArrayInt8Array", - href: "/docs/manual/v8.0.0/api/js/typed-array_int-8-array", - }, - { - name: "TypedArrayInt16Array", - href: "/docs/manual/v8.0.0/api/js/typed-array_int-16-array", - }, - { - name: "TypedArrayInt32Array", - href: "/docs/manual/v8.0.0/api/js/typed-array_int-32-array", - }, - { - name: "TypedArrayTypeS", - href: "/docs/manual/v8.0.0/api/js/typed-array_type-s", - }, - { - name: "TypedArrayUint8Array", - href: "/docs/manual/v8.0.0/api/js/typed-array_uint-8-array", - }, - { - name: "TypedArrayUint8ClampedArray", - href: "/docs/manual/v8.0.0/api/js/typed-array_uint-8-clamped-array", - }, - { - name: "TypedArrayUint16Array", - href: "/docs/manual/v8.0.0/api/js/typed-array_uint-16-array", - }, - { - name: "TypedArrayUint32Array", - href: "/docs/manual/v8.0.0/api/js/typed-array_uint-32-array", - }, - { - name: "TypedArray2ArrayBuffer", - href: "/docs/manual/v8.0.0/api/js/typed-array-2_array-buffer", - }, - { - name: "TypedArray2DataView", - href: "/docs/manual/v8.0.0/api/js/typed-array-2_data-view", - }, - { - name: "TypedArray2Float32Array", - href: "/docs/manual/v8.0.0/api/js/typed-array-2_float-32-array", - }, - { - name: "TypedArray2Float64Array", - href: "/docs/manual/v8.0.0/api/js/typed-array-2_float-64-array", - }, - { - name: "TypedArray2Int8Array", - href: "/docs/manual/v8.0.0/api/js/typed-array-2_int-8-array", - }, - { - name: "TypedArray2Int16Array", - href: "/docs/manual/v8.0.0/api/js/typed-array-2_int-16-array", - }, - { - name: "TypedArray2Int32Array", - href: "/docs/manual/v8.0.0/api/js/typed-array-2_int-32-array", - }, - { - name: "TypedArray2Uint8Array", - href: "/docs/manual/v8.0.0/api/js/typed-array-2_uint-8-array", - }, - { - name: "TypedArray2Uint8ClampedArray", - href: "/docs/manual/v8.0.0/api/js/typed-array-2_uint-8-clamped-array", - }, - { - name: "TypedArray2Uint16Array", - href: "/docs/manual/v8.0.0/api/js/typed-array-2_uint-16-array", - }, - { - name: "TypedArray2Uint32Array", - href: "/docs/manual/v8.0.0/api/js/typed-array-2_uint-32-array", - }, - {name: "TypedArray2", href: "/docs/manual/v8.0.0/api/js/typed-array-2"}, - {name: "TypedArray", href: "/docs/manual/v8.0.0/api/js/typed-array"}, - {name: "Types", href: "/docs/manual/v8.0.0/api/js/types"}, - {name: "Undefined", href: "/docs/manual/v8.0.0/api/js/undefined"}, - {name: "Vector", href: "/docs/manual/v8.0.0/api/js/vector"}, -] - -let categories = [ - { - open Category - {name: "Overview", items: overviewNavs} - }, - {name: "Submodules", items: apiNavs}, -] - -module Docs = { - @react.component - let make = (~components=ApiMarkdown.default, ~children) => { - let router = Next.Router.useRouter() - let route = router.route - - // Gather data for the CollapsibleSection - let headers = { - open Option - Dict.get(indexData, route) - ->map(data => data["headers"]->Array.map(header => (header["name"], "#" ++ header["href"]))) - ->getOr([]) - } - - let moduleName = { - open Option - Dict.get(indexData, route)->map(data => data["moduleName"])->getOr("?") - } - - let url = route->Url.parse - - let version = url->Url.getVersionString - - let prefix = { - open Url - {name: "API", href: "/docs/manual/" ++ (version ++ "/api")} - } - - let breadcrumbs = ApiLayout.makeBreadcrumbs(~prefix, route) - let activeToc = { - open SidebarLayout.Toc - { - title: moduleName, - entries: Array.map(headers, ((name, href)) => {header: name, href}), - } - } - - let title = "JS Module" - let version = "v8.0.0" - - let warnBanner = - - - warnBanner - children - - } -} - -module Prose = { - @react.component - let make = (~children) => children -} diff --git a/src/layouts/JsDocsLayout8_0_0.resi b/src/layouts/JsDocsLayout8_0_0.resi deleted file mode 100644 index 8e4b9eb04..000000000 --- a/src/layouts/JsDocsLayout8_0_0.resi +++ /dev/null @@ -1,9 +0,0 @@ -module Docs: { - @react.component - let make: (~components: MarkdownComponents.t=?, ~children: React.element) => React.element -} - -module Prose: { - @react.component - let make: (~children: React.element) => React.element -} diff --git a/src/layouts/JsDocsLayout9_0_0.res b/src/layouts/JsDocsLayout9_0_0.res deleted file mode 100644 index cb766f6e9..000000000 --- a/src/layouts/JsDocsLayout9_0_0.res +++ /dev/null @@ -1,206 +0,0 @@ -// Structure defined by `scripts/extract-indices.js` -@module("index_data/v900_js_api_index.json") -external indexData: Dict.t<{ - "moduleName": string, - "headers": array<{ - "name": string, - "href": string, - }>, -}> = "default" - -module Category = SidebarLayout.Sidebar.Category -module NavItem = SidebarLayout.Sidebar.NavItem - -let overviewNavs = [ - { - open NavItem - {name: "JS", href: "/docs/manual/v9.0.0/api/js"} - }, -] - -let apiNavs = [ - { - open NavItem - {name: "Array2", href: "/docs/manual/v9.0.0/api/js/array-2"} - }, - {name: "Array", href: "/docs/manual/v9.0.0/api/js/array"}, - {name: "Console", href: "/docs/manual/v9.0.0/api/js/console"}, - {name: "Date", href: "/docs/manual/v9.0.0/api/js/date"}, - {name: "Dict", href: "/docs/manual/v9.0.0/api/js/dict"}, - {name: "Exn", href: "/docs/manual/v9.0.0/api/js/exn"}, - {name: "Float", href: "/docs/manual/v9.0.0/api/js/float"}, - {name: "Global", href: "/docs/manual/v9.0.0/api/js/global"}, - {name: "Int", href: "/docs/manual/v9.0.0/api/js/int"}, - {name: "Json", href: "/docs/manual/v9.0.0/api/js/json"}, - {name: "List", href: "/docs/manual/v9.0.0/api/js/list"}, - {name: "Math", href: "/docs/manual/v9.0.0/api/js/math"}, - {name: "NullUndefined", href: "/docs/manual/v9.0.0/api/js/null-undefined"}, - {name: "Null", href: "/docs/manual/v9.0.0/api/js/null"}, - {name: "Nullable", href: "/docs/manual/v9.0.0/api/js/nullable"}, - {name: "Obj", href: "/docs/manual/v9.0.0/api/js/obj"}, - {name: "Option", href: "/docs/manual/v9.0.0/api/js/option"}, - {name: "Promise", href: "/docs/manual/v9.0.0/api/js/promise"}, - {name: "Re", href: "/docs/manual/v9.0.0/api/js/re"}, - {name: "Result", href: "/docs/manual/v9.0.0/api/js/result"}, - {name: "String2", href: "/docs/manual/v9.0.0/api/js/string-2"}, - {name: "String", href: "/docs/manual/v9.0.0/api/js/string"}, - { - name: "TypedArrayArrayBuffer", - href: "/docs/manual/v9.0.0/api/js/typed-array_array-buffer", - }, - { - name: "TypedArrayDataView", - href: "/docs/manual/v9.0.0/api/js/typed-array_data-view", - }, - { - name: "TypedArrayFloat32Array", - href: "/docs/manual/v9.0.0/api/js/typed-array_float-32-array", - }, - { - name: "TypedArrayFloat64Array", - href: "/docs/manual/v9.0.0/api/js/typed-array_float-64-array", - }, - { - name: "TypedArrayInt8Array", - href: "/docs/manual/v9.0.0/api/js/typed-array_int-8-array", - }, - { - name: "TypedArrayInt16Array", - href: "/docs/manual/v9.0.0/api/js/typed-array_int-16-array", - }, - { - name: "TypedArrayInt32Array", - href: "/docs/manual/v9.0.0/api/js/typed-array_int-32-array", - }, - { - name: "TypedArrayTypeS", - href: "/docs/manual/v9.0.0/api/js/typed-array_type-s", - }, - { - name: "TypedArrayUint8Array", - href: "/docs/manual/v9.0.0/api/js/typed-array_uint-8-array", - }, - { - name: "TypedArrayUint8ClampedArray", - href: "/docs/manual/v9.0.0/api/js/typed-array_uint-8-clamped-array", - }, - { - name: "TypedArrayUint16Array", - href: "/docs/manual/v9.0.0/api/js/typed-array_uint-16-array", - }, - { - name: "TypedArrayUint32Array", - href: "/docs/manual/v9.0.0/api/js/typed-array_uint-32-array", - }, - { - name: "TypedArray2ArrayBuffer", - href: "/docs/manual/v9.0.0/api/js/typed-array-2_array-buffer", - }, - { - name: "TypedArray2DataView", - href: "/docs/manual/v9.0.0/api/js/typed-array-2_data-view", - }, - { - name: "TypedArray2Float32Array", - href: "/docs/manual/v9.0.0/api/js/typed-array-2_float-32-array", - }, - { - name: "TypedArray2Float64Array", - href: "/docs/manual/v9.0.0/api/js/typed-array-2_float-64-array", - }, - { - name: "TypedArray2Int8Array", - href: "/docs/manual/v9.0.0/api/js/typed-array-2_int-8-array", - }, - { - name: "TypedArray2Int16Array", - href: "/docs/manual/v9.0.0/api/js/typed-array-2_int-16-array", - }, - { - name: "TypedArray2Int32Array", - href: "/docs/manual/v9.0.0/api/js/typed-array-2_int-32-array", - }, - { - name: "TypedArray2Uint8Array", - href: "/docs/manual/v9.0.0/api/js/typed-array-2_uint-8-array", - }, - { - name: "TypedArray2Uint8ClampedArray", - href: "/docs/manual/v9.0.0/api/js/typed-array-2_uint-8-clamped-array", - }, - { - name: "TypedArray2Uint16Array", - href: "/docs/manual/v9.0.0/api/js/typed-array-2_uint-16-array", - }, - { - name: "TypedArray2Uint32Array", - href: "/docs/manual/v9.0.0/api/js/typed-array-2_uint-32-array", - }, - {name: "TypedArray2", href: "/docs/manual/v9.0.0/api/js/typed-array-2"}, - {name: "TypedArray", href: "/docs/manual/v9.0.0/api/js/typed-array"}, - {name: "Types", href: "/docs/manual/v9.0.0/api/js/types"}, - {name: "Undefined", href: "/docs/manual/v9.0.0/api/js/undefined"}, - {name: "Vector", href: "/docs/manual/v9.0.0/api/js/vector"}, -] - -let categories = [ - { - open Category - {name: "Overview", items: overviewNavs} - }, - {name: "Submodules", items: apiNavs}, -] - -module Docs = { - @react.component - let make = (~components=ApiMarkdown.default, ~children) => { - let router = Next.Router.useRouter() - let route = router.route - - // Gather data for the CollapsibleSection - let headers = { - open Option - Dict.get(indexData, route) - ->map(data => data["headers"]->Array.map(header => (header["name"], "#" ++ header["href"]))) - ->getOr([]) - } - - let moduleName = { - open Option - Dict.get(indexData, route)->map(data => data["moduleName"])->getOr("?") - } - - let url = route->Url.parse - - let version = url->Url.getVersionString - - let prefix = { - open Url - {name: "API", href: "/docs/manual/" ++ (version ++ "/api")} - } - - let breadcrumbs = ApiLayout.makeBreadcrumbs(~prefix, route) - let activeToc = { - open SidebarLayout.Toc - { - title: moduleName, - entries: Array.map(headers, ((name, href)) => {header: name, href}), - } - } - - let title = "JS Module" - let version = "v9.0.0" - - let warnBanner = - - - warnBanner - children - - } -} - -module Prose = { - @react.component - let make = (~children) => children -} From 1a70252415370e789ce4db9ebded9d1711582cad Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Mon, 30 Jun 2025 16:16:46 -0300 Subject: [PATCH 2/4] version as string --- src/common/App.res | 8 ++-- src/layouts/ApiOverviewLayout.res | 54 +++++++++++------------- src/layouts/ApiOverviewLayout.resi | 2 +- src/layouts/ApiOverviewLayoutLegacy.res | 12 +++--- src/layouts/ApiOverviewLayoutLegacy.resi | 2 +- 5 files changed, 37 insertions(+), 41 deletions(-) diff --git a/src/common/App.res b/src/common/App.res index e609801aa..750aaffad 100644 --- a/src/common/App.res +++ b/src/common/App.res @@ -59,13 +59,13 @@ let make = (props: props): React.element => { switch pagepath[0] { | Some("api") => switch url->Url.getVersionString { - | "v11.0.0" | "v12.0.0" => + | ("v11.0.0" | "v12.0.0") as version => switch (Array.length(pagepath), pagepath[1]) { - | (1, _) => content + | (1, _) => content | _ => content } - | "v8.0.0" | "v9.0.0" | "v10.0.0" => - content + | ("v8.0.0" | "v9.0.0" | "v10.0.0") as version => + content | _ => content } | _ => diff --git a/src/layouts/ApiOverviewLayout.res b/src/layouts/ApiOverviewLayout.res index dc689ec0b..1530a5b50 100644 --- a/src/layouts/ApiOverviewLayout.res +++ b/src/layouts/ApiOverviewLayout.res @@ -1,31 +1,26 @@ module Sidebar = SidebarLayout.Sidebar -let makeCategories: Url.t => array = url => { - switch url.version { - | Version("v12.0.0" | "v11.0.0") | Latest | Next => - let version = Url.getVersionString(url) - [ - { - name: "Overview", - items: [ - {name: "Introduction", href: `/docs/manual/${version}/api`}, - if version >= "v12.0.0" { - {name: "Stdlib", href: `/docs/manual/${version}/api/stdlib`} - } else { - {name: "Core", href: `/docs/manual/${version}/api/core`} - }, - ], - }, - { - name: "Additional Libraries", - items: [ - {name: "Belt", href: `/docs/manual/${version}/api/belt`}, - {name: "Dom", href: `/docs/manual/${version}/api/dom`}, - ], - }, - ] - | _ => throw(Failure(`Invalid version ${url->Url.getVersionString}`)) - } +let makeCategories: string => array = version => { + [ + { + name: "Overview", + items: [ + {name: "Introduction", href: `/docs/manual/${version}/api`}, + if version >= "v12.0.0" { + {name: "Stdlib", href: `/docs/manual/${version}/api/stdlib`} + } else { + {name: "Core", href: `/docs/manual/${version}/api/core`} + }, + ], + }, + { + name: "Additional Libraries", + items: [ + {name: "Belt", href: `/docs/manual/${version}/api/belt`}, + {name: "Dom", href: `/docs/manual/${version}/api/dom`}, + ], + }, + ] } /* Used for API docs (structured data) */ @@ -36,11 +31,10 @@ module Docs = { let route = router.route let categories = makeCategories(version) - let versionStr = Url.getVersionString(version) - - {switch version.version { - | Version("v9.0.0" | "v8.0.0") => + + {switch version { + | "v9.0.0" | "v8.0.0" => | _ => React.null }} children diff --git a/src/layouts/ApiOverviewLayout.resi b/src/layouts/ApiOverviewLayout.resi index 42406d13c..d1c469d45 100644 --- a/src/layouts/ApiOverviewLayout.resi +++ b/src/layouts/ApiOverviewLayout.resi @@ -1,7 +1,7 @@ module Docs: { @react.component let make: ( - ~version: Url.t, + ~version: string, ~components: MarkdownComponents.t=?, ~children: React.element, ) => React.element diff --git a/src/layouts/ApiOverviewLayoutLegacy.res b/src/layouts/ApiOverviewLayoutLegacy.res index 719583ae4..c24d3bfc8 100644 --- a/src/layouts/ApiOverviewLayoutLegacy.res +++ b/src/layouts/ApiOverviewLayoutLegacy.res @@ -329,14 +329,16 @@ let moduleCategories = (moduleName, version) => { } @react.component -let make = (~components=ApiMarkdown.default, ~version: Url.t, ~children) => { +let make = (~components=ApiMarkdown.default, ~version, ~children) => { let router = Next.Router.useRouter() let route = router.route - let versionStr = version->Url.getVersionString + let url = router.route->Url.parse + + let versionStr = version let warnBanner = - switch version.pagepath->Array.get(1) { + switch url.pagepath->Array.get(1) { | None => let title = "API" let categories: array = [ @@ -348,7 +350,7 @@ let make = (~components=ApiMarkdown.default, ~version: Url.t, ~children) => { name: "Modules", items: [ {name: "Js Module", href: `/docs/manual/${versionStr}/api/js`}, - {name: "Belt Stdlib", href: `/docs/manual/${versionStr}/api/belt`}, + {name: "Belt Module", href: `/docs/manual/${versionStr}/api/belt`}, {name: "Dom Module", href: `/docs/manual/${versionStr}/api/dom`}, ], }, @@ -360,7 +362,7 @@ let make = (~components=ApiMarkdown.default, ~version: Url.t, ~children) => { | Some(moduleName) => let indexData = switch Dict.get(indexData, moduleName) { | Some(moduleData) => - Dict.get(moduleData, version->Url.getVersionString)->Option.getOrThrow( + Dict.get(moduleData, version)->Option.getOrThrow( ~message=`Not found data for ${moduleName} version ${versionStr}`, ) | None => throw(Failure(`Not found index data for module: ${moduleName}`)) diff --git a/src/layouts/ApiOverviewLayoutLegacy.resi b/src/layouts/ApiOverviewLayoutLegacy.resi index 85faa3f7a..5a14a5123 100644 --- a/src/layouts/ApiOverviewLayoutLegacy.resi +++ b/src/layouts/ApiOverviewLayoutLegacy.resi @@ -1,6 +1,6 @@ @react.component let make: ( ~components: MarkdownComponents.t=?, - ~version: Url.t, + ~version: string, ~children: React.element, ) => React.element From 44c330017ca603cdc807345f8f011e8df5fbc61c Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Mon, 30 Jun 2025 16:20:25 -0300 Subject: [PATCH 3/4] reduce diff --- src/layouts/ApiOverviewLayout.res | 42 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/layouts/ApiOverviewLayout.res b/src/layouts/ApiOverviewLayout.res index 1530a5b50..94c21c7bb 100644 --- a/src/layouts/ApiOverviewLayout.res +++ b/src/layouts/ApiOverviewLayout.res @@ -1,27 +1,25 @@ module Sidebar = SidebarLayout.Sidebar -let makeCategories: string => array = version => { - [ - { - name: "Overview", - items: [ - {name: "Introduction", href: `/docs/manual/${version}/api`}, - if version >= "v12.0.0" { - {name: "Stdlib", href: `/docs/manual/${version}/api/stdlib`} - } else { - {name: "Core", href: `/docs/manual/${version}/api/core`} - }, - ], - }, - { - name: "Additional Libraries", - items: [ - {name: "Belt", href: `/docs/manual/${version}/api/belt`}, - {name: "Dom", href: `/docs/manual/${version}/api/dom`}, - ], - }, - ] -} +let makeCategories: string => array = version => [ + { + name: "Overview", + items: [ + {name: "Introduction", href: `/docs/manual/${version}/api`}, + if version >= "v12.0.0" { + {name: "Stdlib", href: `/docs/manual/${version}/api/stdlib`} + } else { + {name: "Core", href: `/docs/manual/${version}/api/core`} + }, + ], + }, + { + name: "Additional Libraries", + items: [ + {name: "Belt", href: `/docs/manual/${version}/api/belt`}, + {name: "Dom", href: `/docs/manual/${version}/api/dom`}, + ], + }, +] /* Used for API docs (structured data) */ module Docs = { From 1f14df0ecf498701ba4a7ce0357738d933f2b9dd Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Mon, 30 Jun 2025 16:26:08 -0300 Subject: [PATCH 4/4] remove versionStr --- src/layouts/ApiOverviewLayoutLegacy.res | 28 ++++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/layouts/ApiOverviewLayoutLegacy.res b/src/layouts/ApiOverviewLayoutLegacy.res index c24d3bfc8..4b703d18b 100644 --- a/src/layouts/ApiOverviewLayoutLegacy.res +++ b/src/layouts/ApiOverviewLayoutLegacy.res @@ -334,9 +334,7 @@ let make = (~components=ApiMarkdown.default, ~version, ~children) => { let route = router.route let url = router.route->Url.parse - let versionStr = version - - let warnBanner = + let warnBanner = switch url.pagepath->Array.get(1) { | None => @@ -344,18 +342,18 @@ let make = (~components=ApiMarkdown.default, ~version, ~children) => { let categories: array = [ { name: "Introduction", - items: [{name: "Overview", href: `/docs/manual/${versionStr}/api`}], + items: [{name: "Overview", href: `/docs/manual/${version}/api`}], }, { name: "Modules", items: [ - {name: "Js Module", href: `/docs/manual/${versionStr}/api/js`}, - {name: "Belt Module", href: `/docs/manual/${versionStr}/api/belt`}, - {name: "Dom Module", href: `/docs/manual/${versionStr}/api/dom`}, + {name: "Js Module", href: `/docs/manual/${version}/api/js`}, + {name: "Belt Module", href: `/docs/manual/${version}/api/belt`}, + {name: "Dom Module", href: `/docs/manual/${version}/api/dom`}, ], }, ] - + warnBanner children @@ -363,7 +361,7 @@ let make = (~components=ApiMarkdown.default, ~version, ~children) => { let indexData = switch Dict.get(indexData, moduleName) { | Some(moduleData) => Dict.get(moduleData, version)->Option.getOrThrow( - ~message=`Not found data for ${moduleName} version ${versionStr}`, + ~message=`Not found data for ${moduleName} version ${version}`, ) | None => throw(Failure(`Not found index data for module: ${moduleName}`)) } @@ -378,7 +376,7 @@ let make = (~components=ApiMarkdown.default, ~version, ~children) => { let prefix = { open Url - {name: "API", href: "/docs/manual/" ++ (versionStr ++ "/api")} + {name: "API", href: "/docs/manual/" ++ (version ++ "/api")} } let breadcrumbs = ApiLayout.makeBreadcrumbs(~prefix, route) @@ -391,16 +389,16 @@ let make = (~components=ApiMarkdown.default, ~version, ~children) => { } } - let categories = moduleCategories(moduleName, versionStr) + let categories = moduleCategories(moduleName, version) let title = switch moduleName { - | "belt" => "Belt Stdlib" - | "js" => "Js Stdlib" - | "dom" => "Dom Stdlib" + | "belt" => "Belt Module" + | "js" => "Js Module" + | "dom" => "Dom Module" | _ => assert(false) } - + warnBanner children