diff --git a/docs/.vitepress/config.mjs b/docs/.vitepress/config.mjs new file mode 100644 index 00000000..29fd426a --- /dev/null +++ b/docs/.vitepress/config.mjs @@ -0,0 +1,56 @@ +import { defineConfig } from "vitepress"; +import { tabsMarkdownPlugin } from "vitepress-plugin-tabs"; + +// https://vitepress.dev/reference/site-config +export default defineConfig({ + title: "zarrita.js", + base: "/zarrita.js/", + description: "Zarr building blocks for JavaScript", + head: [ + ["link", { rel: "icon", type: "image/svg+xml", href: "/logo.svg" }], + ], + themeConfig: { + logo: "/logo.svg", + // https://vitepress.dev/reference/default-theme-config + nav: [ + { text: "Home", link: "/" }, + { text: "Guide", link: "/what-is-zarrita" }, + ], + sidebar: [ + { + text: "Introduction", + items: [ + { text: "What is zarrita.js?", link: "/what-is-zarrita" }, + { text: "Get Started", link: "/get-started" }, + { text: "Recipes", link: "/recipes" }, + ], + }, + { + text: "API Reference", + collapsed: false, + items: [ + { text: "@zarrita/core", link: "/core" }, + { text: "@zarrita/storage", link: "/storage" }, + { text: "@zarrita/indexing", link: "/indexing" }, + { text: "@zarrita/ndarray", link: "/ndarray" }, + ], + }, + ], + socialLinks: [ + { icon: "github", link: "https://github.com/manzt/zarrita.js" }, + ], + search: { + provider: "local", + }, + footer: { + message: + "Released under the MIT License.", + copyright: `Copyright 2020–${new Date().getUTCFullYear()} Trevor Manz`, + }, + }, + markdown: { + config(md) { + md.use(tabsMarkdownPlugin); + }, + }, +}); diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts deleted file mode 100644 index 9d2c6b53..00000000 --- a/docs/.vitepress/config.mts +++ /dev/null @@ -1,38 +0,0 @@ -import { defineConfig } from "vitepress"; -import { tabsMarkdownPlugin } from "vitepress-plugin-tabs"; - -// https://vitepress.dev/reference/site-config -export default defineConfig({ - title: "zarrita.js", - description: "Zarr building blocks for JavaScript", - themeConfig: { - // https://vitepress.dev/reference/default-theme-config - nav: [ - { text: "Home", link: "/" }, - { text: "Guide", link: "/guide/what-is-zarrita" }, - ], - sidebar: { - "/guide/": { base: "/guide/", items: sidebarGuide() }, - }, - socialLinks: [ - { icon: "github", link: "https://github.com/manzt/zarrita.js" }, - ], - }, - markdown: { - config(md) { - md.use(tabsMarkdownPlugin); - }, - }, -}); - -function sidebarGuide() { - return [ - { - text: "Introduction", - items: [ - { text: "What is zarrita.js?", link: "what-is-zarrita" }, - { text: "Get Started", link: "get-started" }, - ], - }, - ]; -} diff --git a/docs/.vitepress/theme/style.css b/docs/.vitepress/theme/style.css index 50ef578c..c7b50bc2 100644 --- a/docs/.vitepress/theme/style.css +++ b/docs/.vitepress/theme/style.css @@ -12,9 +12,9 @@ --vp-c-brand-light: #f9a8d4; --vp-c-brand-lighter: #fbcfe8; --vp-c-brand-lightest: #fce7f3; - --vp-c-brand-dark: #be185d; - --vp-c-brand-darker: #831843; - --vp-c-brand-dimm: #500724; + --vp-c-brand-dark: #b45309; + --vp-c-brand-darker: #92400e; + --vp-c-brand-dimm: #451a03; } /** diff --git a/docs/core.md b/docs/core.md new file mode 100644 index 00000000..e69de29b diff --git a/docs/get-started.md b/docs/get-started.md new file mode 100644 index 00000000..eb13b10f --- /dev/null +++ b/docs/get-started.md @@ -0,0 +1,70 @@ +# Getting Started + +## Open an Array + +```js +import * as zarr from "@zarrita/core"; +import { FetchStore } from "@zarrita/storage"; + +const store = new FetchStore("http://localhost:8080/data.zarr"); +const arr = await zarr.open.v2(store, { kind: "array" }); +``` + +## Read a chunk + +```js +const chunk = await arr.get_chunk([0, 0]); +// { +// data: Int32Array(10) [ +// 0, 1, 2, 3, 4, +// 10, 11, 12, 13, 14, +// ], +// shape: [ 2, 5 ], +// } +``` + +## Read entire dataset + +```js +import { get } from "@zarrita/indexing"; + +const full = await get(arr); // ndarray.Ndarray +// { +// data: Int32Array(50) [ +// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, +// 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, +// 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, +// 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, +// 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, +// ], +// shape: [ 5, 10 ], +// stride: [ 10, 1 ] +// } +``` + +## Read a selection + +```js +const region = await get(arr, [null, zarr.slice(6)]); +// { +// data: Int32Array(30) [ +// 0, 1, 2, 3, 4, 5, +// 10, 11, 12, 13, 14, 15, +// 20, 21, 22, 23, 24, 25, +// 30, 31, 32, 33, 34, 35, +// 40, 41, 42, 43, 44, 45, +// ], +// shape: [ 5, 6 ], +// stride: [ 6, 1 ] +// } +``` + +## Read as a `scijs/ndarray` + +```js +import { get } from "@zarrita/ndarray"; + +const full = await get(arr); // ndarray.Ndarray +const region = await get(arr, [null, zarr.slice(6)]); // ndarray.Ndarray +``` + diff --git a/docs/index.md b/docs/index.md index c3a7ffec..c109eacf 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,14 +2,17 @@ # https://vitepress.dev/reference/default-theme-home-page layout: home +title: zarrita.js +titleTemplate: A JavaScript toolkit for Zarr + hero: - name: "zarrita.js" - # text: "" - tagline: Zarr building blocks for JavaScript + name: zarrita.js + # text: A JavaScript toolkit for Zarr + tagline: A JavaScript toolkit for working with chunked, compressed, n-dimensional arrays actions: - theme: brand text: Get Started - link: /guide/get-started + link: /get-started - theme: alt text: View on GitHub link: https://github.com/manzt/zarrita.js @@ -27,4 +30,18 @@ features: - title: Type safe icon: 🦺 details: Built in TypeScript, offering rich type information. + + - title: "@zarrita/core" + details: Open arrays and groups + link: /core + # linkText: + - title: "@zarrita/storage" + details: Pick a storage backend + link: /storage + - title: "@zarrita/indexing" + details: Slice and index arrays + link: /indexing + - title: "@zarrita/ndarray" + details: Load arrays with scijs/ndarray + link: /ndarray --- diff --git a/docs/indexing.md b/docs/indexing.md new file mode 100644 index 00000000..e69de29b diff --git a/docs/ndarray.md b/docs/ndarray.md new file mode 100644 index 00000000..e69de29b diff --git a/docs/public/logo.svg b/docs/public/logo.svg new file mode 100644 index 00000000..26b20a30 --- /dev/null +++ b/docs/public/logo.svg @@ -0,0 +1,4 @@ + + 🐙 + + diff --git a/docs/guide/get-started.md b/docs/recipes.md similarity index 54% rename from docs/guide/get-started.md rename to docs/recipes.md index 36b062dc..48ecca57 100644 --- a/docs/guide/get-started.md +++ b/docs/recipes.md @@ -1,78 +1,6 @@ -# Getting Started +# Recipes -## Quick Start - -### Open an Array - -```js -import * as zarr from "@zarrita/core"; -import { FetchStore } from "@zarrita/storage"; - -const store = new FetchStore("http://localhost:8080/data.zarr"); -const arr = await zarr.open.v2(store, { kind: "array" }); -``` - -### Read a chunk - -```js -const chunk = await arr.get_chunk([0, 0]); -// { -// data: Int32Array(10) [ -// 0, 1, 2, 3, 4, -// 10, 11, 12, 13, 14, -// ], -// shape: [ 2, 5 ], -// } -``` - -### Read entire dataset - -```js -import { get } from "@zarrita/indexing"; - -const full = await get(arr); // ndarray.Ndarray -// { -// data: Int32Array(50) [ -// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -// 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, -// 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, -// 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -// 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, -// ], -// shape: [ 5, 10 ], -// stride: [ 10, 1 ] -// } -``` - -### Read a selection - -```js -const region = await get(arr, [null, zarr.slice(6)]); -// { -// data: Int32Array(30) [ -// 0, 1, 2, 3, 4, 5, -// 10, 11, 12, 13, 14, 15, -// 20, 21, 22, 23, 24, 25, -// 30, 31, 32, 33, 34, 35, -// 40, 41, 42, 43, 44, 45, -// ], -// shape: [ 5, 6 ], -// stride: [ 6, 1 ] -// } -``` - -### Read as a `scijs/ndarray` - -```js -import { get } from "@zarrita/ndarray"; - -const full = await get(arr); // ndarray.Ndarray -const region = await get(arr, [null, zarr.slice(6)]); // ndarray.Ndarray -``` - -## Recipes - -### Open an Array +## Open an Array ```js import * as zarr from "@zarrita/core"; @@ -87,7 +15,7 @@ arr.chunk_shape; // [2, 5] arr.dtype; // "int32" ``` -### Open a Group +## Open a Group ```js import * as zarr from "@zarrita/core"; @@ -99,7 +27,7 @@ const group = await zarr.open(store, { kind: "group" }); group; // zarr.Group ``` -### Open a Group or an Array +## Open a Group or an Array ```js import * as zarr from "@zarrita/core"; @@ -111,7 +39,7 @@ const node = await zarr.open(store); node; // zarr.Array | zarr.Group ``` -### Open a Group or an Array from another Node +## Open a Group or an Array from another Node ```js import * as zarr from "@zarrita/core"; @@ -123,7 +51,7 @@ const node = await zarr.open(store); const arr = await zarr.open(node.resolve("path/to/foo"), { kind: "array" }); ``` -### Open Array or Group with strict version +## Open Array or Group with strict version You can enforce version with `open.v2` or `open.v3` respectively. @@ -135,7 +63,7 @@ const store = new FetchStore("http://localhost:8080/data.zarr"); const arr = await zarr.open.v2(store, { kind: "array" }); ``` -### Create an Array (v3) +## Create an Array (v3) Requires the `store` to implement `Writeable`. @@ -152,7 +80,7 @@ const arr = await zarr.create(store, { arr; // zarr.Array<"int32", FileSystemStore> ``` -### Create an Group (v3) +## Create an Group (v3) Requires the `store` to implement `Writeable`. diff --git a/docs/storage.md b/docs/storage.md new file mode 100644 index 00000000..e69de29b diff --git a/docs/guide/what-is-zarrita.md b/docs/what-is-zarrita.md similarity index 100% rename from docs/guide/what-is-zarrita.md rename to docs/what-is-zarrita.md