Skip to content

Commit

Permalink
Add docs with vitepress and genji (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini committed Sep 30, 2024
1 parent f07ffff commit 07bf5c7
Show file tree
Hide file tree
Showing 12 changed files with 1,602 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ node_modules
**/target
src/wasm
dist
**/*-actual.txt
**/*-actual.txt
cache
33 changes: 33 additions & 0 deletions docs/.vitepress/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {defineConfig} from "vitepress";
import config from "genji-theme-vitepress/config";

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: "Charming Cell",
description: "The creative coding language for ASCII Art",
extends: config,
themeConfig: {
nav: [
{text: "Home", link: "/"},
{text: "Examples", link: "https://observablehq.com/d/18b3d6f3affff5bb"},
],
sidebar: [
{
text: "Introduction",
items: [
{text: "What is Cell?", link: "/what-is-cell"},
{text: "Getting started", link: "/get-started"},
],
},
{
text: "Features",
items: [
{text: "Sketches", link: "/features/sketches"},
{text: "Shapes", link: "/features/shapes"},
],
},
{text: "API Index", link: "/api-index"},
],
socialLinks: [{icon: "github", link: "https://github.com/charming-art/cell"}],
},
});
18 changes: 18 additions & 0 deletions docs/.vitepress/theme/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// .vitepress/theme/index.js
import DefaultTheme from "vitepress/theme";
import Layout from "genji-theme-vitepress";
import {h} from "vue";
import * as Cell from "../../../dist/es/index.js";

// More props: https://genji-md.dev/reference/props
const props = {
Theme: DefaultTheme,
library: {
Cell,
},
};

export default {
extends: DefaultTheme,
Layout: () => h(Layout, props),
};
19 changes: 19 additions & 0 deletions docs/api-index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# API Index

## Methods

- render
- wide

## Context

- stroke
- point
- cols
- rows

## Options

- width
- height
- mode
1 change: 1 addition & 0 deletions docs/features/shapes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Shapes
1 change: 1 addition & 0 deletions docs/features/sketches.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Sketches
7 changes: 7 additions & 0 deletions docs/get-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Getting Started

> WIP
```bash
npm install @charming-art/cell
```
27 changes: 27 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
# https://vitepress.dev/reference/default-theme-home-page
layout: home

hero:
name: "Charming Cell"
text: "The creative coding language for ASCII Art"
tagline: Create expressive ASCII Art in a minute
actions:
- theme: brand
text: Get Started
link: /get-started
- theme: alt
text: What is Cell?
link: /what-is-cell
- theme: alt
text: Examples
link: https://observablehq.com/d/18b3d6f3affff5bb

features:
- title: Concise
details: In the style of P5.js
- title: Fast
details: A software rasterizer written in Rust and compiled to WASM
- title: Amusing
details: Life is not just about work, right?
---
17 changes: 17 additions & 0 deletions docs/what-is-cell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# What is Cell?

```js eval
Cell.render((ctx) => ({
mode: "double",
width: 520,
height: 520,
setup() {
for (let t = 0; t <= Math.PI * 2; t += Math.PI / 120) {
const x = ctx.cols() / 2 + 12 * Math.cos(t) * Math.cos(t * 3);
const y = ctx.rows() / 2 + 12 * Math.sin(t) * Math.cos(t * 3);
ctx.stroke(Cell.wide("🌟"));
ctx.point(x, y);
}
},
}));
```
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
"build:js": "rm -rf dist && rollup -c",
"build:rust": "rm -rf ./src/wasm && wasm-pack build ./rust --out-dir ../src/wasm --out-name index --target web",
"preview": "npm run build && vite preview",
"prepublishOnly": "npm run build"
"prepublishOnly": "npm run build",
"docs:dev": "vitepress dev docs",
"docs:build": "npm run build && vitepress build docs",
"docs:preview": "vitepress preview docs"
},
"sideEffects": false,
"devDependencies": {
Expand All @@ -44,9 +47,11 @@
"@rollup/plugin-wasm": "^6.1.3",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"genji-theme-vitepress": "^0.2.6",
"prettier": "^2.8.8",
"rollup": "^3.26.0",
"vite": "^4.3.9",
"vitepress": "^1.3.4",
"vitest": "^0.32.1",
"wasm-pack": "^0.13.0"
},
Expand All @@ -60,4 +65,4 @@
"publishConfig": {
"access": "public"
}
}
}
Loading

0 comments on commit 07bf5c7

Please sign in to comment.