Skip to content

Commit c8ade25

Browse files
committed
first commit
0 parents  commit c8ade25

File tree

25 files changed

+2517
-0
lines changed

25 files changed

+2517
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- docs/**
9+
- README.md
10+
11+
permissions:
12+
contents: write
13+
pages: write
14+
id-token: write
15+
16+
concurrency:
17+
group: "pages"
18+
cancel-in-progress: false
19+
20+
jobs:
21+
deploy:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- uses: actions/setup-node@v3
29+
with:
30+
registry-url: https://registry.npmjs.org/
31+
node-version: 18
32+
33+
- uses: pnpm/action-setup@v2
34+
name: Install pnpm
35+
id: pnpm-install
36+
with:
37+
version: 8
38+
run_install: false
39+
40+
- name: Get pnpm store directory
41+
id: pnpm-cache
42+
shell: bash
43+
run: |
44+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
45+
- uses: actions/cache@v3
46+
name: Setup pnpm cache
47+
with:
48+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
49+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
50+
restore-keys: |
51+
${{ runner.os }}-pnpm-store-
52+
- name: Install dependencies
53+
run: pnpm install
54+
55+
- name: Build
56+
run: pnpm docs:build
57+
58+
# - name: Set CNAME
59+
# shell: bash
60+
# run: |
61+
# echo "mathscript.js.org" > docs/.vitepress/dist/CNAME
62+
63+
- name: Deploy
64+
uses: peaceiris/actions-gh-pages@v3
65+
with:
66+
github_token: ${{ secrets.GITHUB_TOKEN }}
67+
publish_dir: docs/.vitepress/dist

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
logs
2+
*.log*
3+
pnpm-debug.log*
4+
5+
node_modules
6+
dist
7+
8+
.vscode/*
9+
!.vscode/extensions.json
10+
.idea
11+
.DS_Store
12+
.eslintcache
13+
*.env*
14+
15+
docs/.vitepress/dist
16+
docs/.vitepress/cache

docs/.vitepress/config.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { defineConfig } from 'vitepress';
2+
3+
// https://vitepress.dev/reference/site-config
4+
export default defineConfig({
5+
base: '/',
6+
lang: 'en-US',
7+
title: 'MathFlow',
8+
description:
9+
'A lightweight and expressive scripting language designed for mathematical expressions and calculations.',
10+
head: [['link', { rel: 'icon', href: '/logo.svg' }]],
11+
themeConfig: {
12+
// https://vitepress.dev/reference/default-theme-config
13+
logo: '/logo.svg',
14+
siteTitle: 'MathFlow',
15+
search: {
16+
provider: 'local'
17+
},
18+
nav: [
19+
{ text: 'Home', link: '/' },
20+
{ text: 'Guide', link: '/guide/' },
21+
{ text: 'Playground', link: '/playground/' },
22+
{ text: 'Demo', link: 'https://mathflow.github.io/demo' },
23+
{
24+
text: 'About',
25+
items: [
26+
{ text: 'Team', link: '/about/team' },
27+
{ text: 'History', link: '/about/history' },
28+
{ text: 'Code of Conduct', link: '/about/coc' }
29+
]
30+
}
31+
],
32+
33+
sidebar: [
34+
{
35+
text: 'Guide',
36+
items: [
37+
{ text: 'Introduction', link: '/guide/' },
38+
{ text: 'Getting Started', link: '/guide/getting-started' },
39+
{ text: 'Configuration', link: '/guide/config' }
40+
]
41+
},
42+
{
43+
text: 'Syntax',
44+
items: [
45+
{ text: 'Basics', link: '/guide/basics' },
46+
{ text: 'Variables', link: '/guide/variables' },
47+
{ text: 'Expressions', link: '/guide/expressions' },
48+
{ text: 'Builtins', link: '/guide/builtin' }
49+
]
50+
},
51+
{
52+
text: 'Examples',
53+
items: [
54+
{ text: 'Scripts', link: '/guide/scripts' },
55+
{ text: 'Programs', link: '/guide/programs' }
56+
]
57+
},
58+
{
59+
text: 'API Reference',
60+
link: '/api/'
61+
}
62+
],
63+
64+
socialLinks: [
65+
{ icon: 'github', link: 'https://github.com/mathflowjs/mathflow' }
66+
],
67+
68+
editLink: {
69+
text: 'Edit this page on GitHub',
70+
pattern:
71+
'https://github.com/mathflowjs/mathflow/edit/master/:path'
72+
},
73+
74+
footer: {
75+
message:
76+
'Released under the <a href="https://github.com/mathflowjs/mathflow/blob/master/LICENSE.md">MIT License</a>.',
77+
copyright:
78+
'Copyright &copy; 2024, <a href="https://github.com/henryhale">Henry Hale</a> - 2024-present MathFlow.'
79+
}
80+
},
81+
markdown: {
82+
lineNumbers: true
83+
}
84+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
:root {
2+
--vp-c-brand-1: #4169e1;
3+
--vp-c-brand-2: #747bff;
4+
--vp-home-hero-image-background-image: linear-gradient(180deg, var(--vp-home-hero-name-color) 50%,#27332a 50%);
5+
--vp-home-hero-image-filter: blur(40px);
6+
}
7+
8+
.VPImage {
9+
border-radius: 5px;
10+
}
11+
12+
.VPImage.image-src {
13+
width: min(25vw, 250px);
14+
height: min(25vw, 250px);
15+
}
16+
17+
.image-src {
18+
border-radius: 20px;
19+
}
20+
21+
.dark .vp-doc .custom-block a {
22+
transition: color 0.25s;
23+
}
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
<script setup>
2+
import { ref, onMounted } from 'vue';
3+
import { evaluate } from 'mathflow';
4+
5+
const input = ref('');
6+
const code = ref('');
7+
const output = ref('');
8+
const link = ref('');
9+
const copied = ref(false);
10+
11+
function runScript() {
12+
try {
13+
output.value = evaluate(code.value);
14+
} catch (error) {
15+
output.value = '' + error;
16+
}
17+
}
18+
19+
function generateURL() {
20+
link.value =
21+
window.location.origin +
22+
window.location.pathname +
23+
'?s=' +
24+
encodeURIComponent(code.value);
25+
}
26+
27+
function reset() {
28+
link.value = '';
29+
output.value = '';
30+
}
31+
32+
function copyURL() {
33+
try {
34+
navigator.clipboard.writeText(link.value);
35+
copied.value = true;
36+
setTimeout(() => {
37+
copied.value = false;
38+
}, 750);
39+
} catch (error) {
40+
console.error(error);
41+
}
42+
}
43+
44+
onMounted(() => {
45+
const params = new URLSearchParams(window.location.search);
46+
if (params.has('s')) {
47+
code.value = decodeURIComponent(params.get('s'));
48+
} else {
49+
code.value = '# Hello World!\n# This is a comment\nx = 1\ny = 2\n\n# return sum of x and y\nx + y\n\n# now hit run to view the solution';
50+
}
51+
});
52+
</script>
53+
54+
<template>
55+
<div class="box">
56+
<div>
57+
<textarea ref="input" v-model.trim="code" @input="reset" spellcheck="false" autocomplete="off"></textarea>
58+
</div>
59+
<div>
60+
<button @click="runScript">Run</button>
61+
<button @click="generateURL" :disabled="!code">Share</button>
62+
</div>
63+
<div v-show="code.length && link.length">
64+
<div class="copy">
65+
<span>Link</span>
66+
<span v-text="link"></span>
67+
<span @click="copyURL">{{ copied ? 'Copied' : 'Copy' }}</span>
68+
</div>
69+
</div>
70+
<div v-show="(typeof output !== 'string')">
71+
<div v-if="output.solution">
72+
<b>Solution:</b>
73+
<div v-for="n in output.solution" :key="n">= {{ n }}</div>
74+
</div>
75+
</div>
76+
<div v-show="(typeof output !== 'string')">
77+
<b>Output:</b>
78+
<p>{{ JSON.stringify(output, null, 2) }}</p>
79+
</div>
80+
</div>
81+
</template>
82+
83+
<style scoped>
84+
.box {
85+
max-width: 720px;
86+
margin: 3rem auto;
87+
display: flex;
88+
flex-direction: column;
89+
}
90+
91+
.box>div {
92+
margin-bottom: 1.5rem;
93+
}
94+
95+
button {
96+
border: 1px solid;
97+
border-color: var(--vp-button-alt-border);
98+
color: var(--vp-button-alt-text);
99+
background-color: var(--vp-button-alt-bg);
100+
margin-right: 1rem;
101+
border-radius: 10px;
102+
padding: 0 20px;
103+
line-height: 38px;
104+
font-size: 14px;
105+
}
106+
107+
textarea:focus,
108+
button:focus,
109+
button:hover {
110+
background-color: var(--vp-button-alt-hover-bg);
111+
}
112+
113+
button:focus {
114+
border-color: var(--vp-button-brand-bg);
115+
}
116+
117+
textarea {
118+
width: 100%;
119+
padding: 0.75rem;
120+
overflow-wrap: break-word;
121+
border-radius: 8px;
122+
min-height: 250px;
123+
max-height: 500px;
124+
}
125+
126+
.copy {
127+
display: flex;
128+
border: 1px solid var(--vp-input-border-color);
129+
border-radius: 10px;
130+
overflow: hidden;
131+
transition: all 0.25ms;
132+
}
133+
134+
.copy>span {
135+
display: inline-block;
136+
padding: 5px 15px;
137+
max-height: 50px;
138+
}
139+
140+
.copy>span:nth-child(2) {
141+
flex-grow: 1;
142+
border-width: 0 1px 0 1px;
143+
border-style: solid;
144+
border-color: var(--vp-input-border-color);
145+
white-space: nowrap;
146+
overflow: hidden;
147+
text-overflow: ellipsis;
148+
}
149+
150+
.copy>span:last-child {
151+
background-color: var(--vp-input-switch-bg-color);
152+
cursor: pointer;
153+
}
154+
155+
.copy>span:last-child:hover {
156+
background-color: var(--vp-bg-brand);
157+
color: var(--vp-c-brand-1);
158+
}
159+
</style>

docs/.vitepress/theme/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import DefaultTheme from "vitepress/theme";
2+
3+
// @ts-ignore
4+
import PlayGround from "./components/PlayGround.vue";
5+
// @ts-ignore
6+
// import ProjectCards from "./components/ProjectCards.vue";
7+
8+
import "./assets/styles.css";
9+
10+
export default {
11+
extends: DefaultTheme,
12+
enhanceApp(ctx) {
13+
ctx.app.component('PlayGround', PlayGround);
14+
// ctx.app.component('ProjectCards', ProjectCards);
15+
}
16+
};

0 commit comments

Comments
 (0)