Skip to content

Commit

Permalink
docs: create sub-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
manzt committed Aug 13, 2023
1 parent 4426417 commit 63486ae
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 125 deletions.
56 changes: 56 additions & 0 deletions docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
@@ -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 <a style='text-decoration:underline;' href='https://github.com/manzt/zarrita.js/blob/main/LICENSE'>MIT License</a>.",
copyright: `Copyright 2020–${new Date().getUTCFullYear()} Trevor Manz`,
},
},
markdown: {
config(md) {
md.use(tabsMarkdownPlugin);
},
},
});
38 changes: 0 additions & 38 deletions docs/.vitepress/config.mts

This file was deleted.

6 changes: 3 additions & 3 deletions docs/.vitepress/theme/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
Empty file added docs/core.md
Empty file.
70 changes: 70 additions & 0 deletions docs/get-started.md
Original file line number Diff line number Diff line change
@@ -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<Int32Array>
// {
// 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<Int32Array>
const region = await get(arr, [null, zarr.slice(6)]); // ndarray.Ndarray<Int32Array>
```

25 changes: 21 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
---
Empty file added docs/indexing.md
Empty file.
Empty file added docs/ndarray.md
Empty file.
4 changes: 4 additions & 0 deletions docs/public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 8 additions & 80 deletions docs/guide/get-started.md → docs/recipes.md
Original file line number Diff line number Diff line change
@@ -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<Int32Array>
// {
// 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<Int32Array>
const region = await get(arr, [null, zarr.slice(6)]); // ndarray.Ndarray<Int32Array>
```

## Recipes

### Open an Array
## Open an Array

```js
import * as zarr from "@zarrita/core";
Expand All @@ -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";
Expand All @@ -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";
Expand All @@ -111,7 +39,7 @@ const node = await zarr.open(store);
node; // zarr.Array<DataType, FetchStore> | 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";
Expand All @@ -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.

Expand All @@ -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`.

Expand All @@ -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`.

Expand Down
Empty file added docs/storage.md
Empty file.
File renamed without changes.

0 comments on commit 63486ae

Please sign in to comment.