From ca1ec12725c32b0173692e01259570966da8a9a6 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 3 Feb 2026 21:09:44 +0800 Subject: Updated docs. --- doc/.gitignore | 4 +- doc/docs/.vitepress/config.mts | 53 +- doc/docs/.vitepress/env.d.ts | 19 + doc/docs/.vitepress/grammars/moonscript.tmLanguage | 263 + .../.vitepress/grammars/moonscript.tmLanguage.json | 149 + doc/docs/.vitepress/public/favicon.ico | Bin 0 -> 15406 bytes doc/docs/.vitepress/public/image/yuescript.svg | 54 +- .../.vitepress/theme/components/CompilerModal.vue | 20 +- .../.vitepress/theme/components/YueCompiler.vue | 342 +- .../.vitepress/theme/components/YueDisplay.vue | 4 +- doc/docs/.vitepress/theme/custom.css | 92 +- doc/docs/.vitepress/theme/index.ts | 10 +- doc/docs/README.md | 14 - doc/docs/doc/README.md | 5148 ------------------ doc/docs/doc/index.md | 5520 ++++++++++++++++++++ doc/docs/index.md | 25 + doc/docs/try/README.md | 6 - doc/docs/try/index.md | 6 + doc/docs/zh/README.md | 14 - doc/docs/zh/doc/README.md | 5089 ------------------ doc/docs/zh/doc/index.md | 5453 +++++++++++++++++++ doc/docs/zh/index.md | 25 + doc/docs/zh/try/README.md | 6 - doc/docs/zh/try/index.md | 6 + doc/package.json | 6 + doc/tsconfig.json | 18 + 26 files changed, 11953 insertions(+), 10393 deletions(-) create mode 100644 doc/docs/.vitepress/env.d.ts create mode 100644 doc/docs/.vitepress/grammars/moonscript.tmLanguage create mode 100644 doc/docs/.vitepress/grammars/moonscript.tmLanguage.json create mode 100644 doc/docs/.vitepress/public/favicon.ico delete mode 100755 doc/docs/README.md delete mode 100755 doc/docs/doc/README.md create mode 100755 doc/docs/doc/index.md create mode 100644 doc/docs/index.md delete mode 100755 doc/docs/try/README.md create mode 100755 doc/docs/try/index.md delete mode 100755 doc/docs/zh/README.md delete mode 100755 doc/docs/zh/doc/README.md create mode 100755 doc/docs/zh/doc/index.md create mode 100644 doc/docs/zh/index.md delete mode 100755 doc/docs/zh/try/README.md create mode 100755 doc/docs/zh/try/index.md create mode 100644 doc/tsconfig.json (limited to 'doc') diff --git a/doc/.gitignore b/doc/.gitignore index 0cef669..dea1a07 100755 --- a/doc/.gitignore +++ b/doc/.gitignore @@ -11,5 +11,5 @@ dist config.local.js basement_dist yarn.lock -docs/.vuepress/public/js/yuescript.js -docs/.vuepress/public/js/yuescript.wasm +docs/.vitepress/public/js/yuescript.js +docs/.vitepress/public/js/yuescript.wasm diff --git a/doc/docs/.vitepress/config.mts b/doc/docs/.vitepress/config.mts index 7f7416d..da3876d 100644 --- a/doc/docs/.vitepress/config.mts +++ b/doc/docs/.vitepress/config.mts @@ -1,10 +1,26 @@ import { defineConfig } from 'vitepress' +import { resolve, dirname } from 'path' +import { readFileSync } from 'fs' +import { fileURLToPath } from 'url' +import lightPlus from '@shikijs/themes/light-plus' +import darkPlus from '@shikijs/themes/dark-plus' + +const __dirname = dirname(fileURLToPath(import.meta.url)) +const moonscriptGrammarPath = resolve(__dirname, 'grammars/moonscript.tmLanguage.json') +const moonscriptGrammar = JSON.parse(readFileSync(moonscriptGrammarPath, 'utf-8')) +const moonscriptLanguage = { + ...moonscriptGrammar, + name: 'moonscript', + scopeName: 'source.moonscript', + aliases: ['yue', 'yuescript', 'moon'], +} export default defineConfig({ title: 'YueScript', description: 'A language that compiles to Lua', + base: '/', head: [ - ['meta', { name: 'theme-color', content: '#3eaf7c' }], + ['meta', { name: 'theme-color', content: '#b4ac8f' }], ['meta', { name: 'apple-mobile-web-app-capable', content: 'yes' }], ['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'black' }], ['meta', { property: 'og:title', content: 'YueScript' }], @@ -29,10 +45,35 @@ export default defineConfig({ window.yue = Module; window.dispatchEvent(new Event('yue:ready')); } -};` - ], - ['script', { src: '/js/yuescript.js' }] +}; +(function() { + function loadStub() { + window.yue = { + version: function() { return '(build with: make wasm)'; }, + tolua: function() { return ['', 'Build yuescript wasm with: make wasm']; }, + exec: function() { return ''; } + }; + window.dispatchEvent(new Event('yue:ready')); + } + var s = document.createElement('script'); + s.src = '/js/yuescript.js'; + s.async = true; + document.head.appendChild(s); +})();` + ] ], + vite: { + publicDir: resolve(__dirname, 'public'), + }, + markdown: { + languages: [ + moonscriptLanguage, + ], + theme: { + light: lightPlus, + dark: darkPlus, + }, + }, locales: { root: { label: 'English', @@ -42,7 +83,7 @@ export default defineConfig({ nav: [ { text: 'Document', link: '/doc/' }, { text: 'Try yue!', link: '/try/' }, - { text: 'Github', link: 'https://github.com/pigpigyyy/Yuescript' } + { text: 'Github', link: 'https://github.com/IppClub/Yuescript' } ] } }, @@ -54,7 +95,7 @@ export default defineConfig({ nav: [ { text: '文档', link: '/zh/doc/' }, { text: '试一试!', link: '/zh/try/' }, - { text: 'Github', link: 'https://github.com/pigpigyyy/Yuescript' } + { text: 'Github', link: 'https://github.com/IppClub/Yuescript' } ] } } diff --git a/doc/docs/.vitepress/env.d.ts b/doc/docs/.vitepress/env.d.ts new file mode 100644 index 0000000..0f28852 --- /dev/null +++ b/doc/docs/.vitepress/env.d.ts @@ -0,0 +1,19 @@ +/// + +declare module '*.vue' { + import type { DefineComponent } from 'vue' + const component: DefineComponent<{}, {}, any> + export default component +} + +declare global { + interface Window { + yue?: { + version: () => string + tolua: (code: string, ...args: unknown[]) => [string, string] + exec: (code: string) => string + } + } +} + +export {} diff --git a/doc/docs/.vitepress/grammars/moonscript.tmLanguage b/doc/docs/.vitepress/grammars/moonscript.tmLanguage new file mode 100644 index 0000000..2c041ba --- /dev/null +++ b/doc/docs/.vitepress/grammars/moonscript.tmLanguage @@ -0,0 +1,263 @@ + + + + + + comment + MoonScript Syntax: 0.0.1 + fileTypes + + moon + + + name + MoonScript + + patterns + + + captures + + 1 + + name + punctuation.definition.comment.lua + + + match + (--)(?!\[\[).*$\n? + name + comment.line.double-dash.lua + + + + + begin + ' + beginCaptures + + 0 + + name + punctuation.definition.string.begin.lua + + + end + ' + endCaptures + + 0 + + name + punctuation.definition.string.end.lua + + + name + string.quoted.single.lua + patterns + + + match + \\(\d{1,3}|.) + name + constant.character.escape.lua + + + + + + begin + " + beginCaptures + + 0 + + name + punctuation.definition.string.begin.lua + + + end + " + endCaptures + + 0 + + name + punctuation.definition.string.end.lua + + + name + string.quoted.double.lua + patterns + + + match + \\(\d{1,3}|.) + name + constant.character.escape.lua + + + + + + begin + (?<!--)\[(=*)\[ + beginCaptures + + 0 + + name + punctuation.definition.string.begin.lua + + + end + \]\1\] + endCaptures + + 0 + + name + punctuation.definition.string.end.lua + + + name + string.quoted.other.multiline.lua + + + + match + (?<![\d.])\s0x[a-fA-F\d]+|\b\d+(\.\d+)?([eE]-?\d+)?|\.\d+([eE]-?\d+)? + name + constant.numeric.lua + + + + name + support.constant + match + \b[A-Z]\w*\b(?!:) + + + + name + keyword.operator + match + =>|-> + + + + match + \b(and|or|not)\b + name + keyword.operator.lua + + + + match + [a-zA-Z_]\w*\s*(?=:) + name + entity.name.function + + + + match + \(|\) + name + entity.name.function + + + + match + \+|-|%|#|\*|\/|\^|==?|~=|!=|\\|:|,|;|\.|<=?|>=?|(?<!\.)\.{2}(?!\.) + name + keyword.operator.lua + + + + match + {|}|\[|\] + name + storage.modifier + + + + name + storage.type.class + match + \b(class|extends|super)\b + + + + name + keyword.control + match + \b(if|then|else|elseif|export|import|from|switch|when|with|using|do|for|in|while|return|local|unless|continue|break)\b + + + + name + variable.language + match + \b(self)\b + + + + name + variable.parameter + match + @@?[a-zA-Z_]\w*\b + + + + name + constant.language.nil + match + \b(nil)\b + + + + + match + \b(true|false)\b + name + constant.language.boolean + + + + match + (?<!\.|\\)\b(function|repeat|end)\b(?!\s*:) + name + invalid.illegal + + + + match + (?<![^.]\.|\\)\b(assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|loadfile|loadstring|module|next|pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\b + name + support.function.lua + + + + match + (?<![^.]\.|\\)\b(_G)\b + name + support.constant + + + + match + (?<![^.]\.|\\)\b(coroutine\.(create|resume|running|status|wrap|yield)|string\.(byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)|table\.(concat|insert|maxn|remove|sort)|math\.(abs|acos|asin|atan2?|ceil|cosh?|deg|exp|floor|fmod|frexp|ldexp|log|log10|max|min|modf|pow|rad|random|randomseed|sinh?|sqrt|tanh?)|io\.(close|flush|input|lines|open|output|popen|read|tmpfile|type|write)|os\.(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)|package\.(cpath|loaded|loadlib|path|preload|seeall)|debug\.(debug|[gs]etfenv|[gs]ethook|getinfo|[gs]etlocal|[gs]etmetatable|getregistry|[gs]etupvalue|traceback))\b + name + support.function.library.lua + + + + + scopeName + source.moonscript + uuid + D363822C-639B-4450-A21A-F45643A6940F + + diff --git a/doc/docs/.vitepress/grammars/moonscript.tmLanguage.json b/doc/docs/.vitepress/grammars/moonscript.tmLanguage.json new file mode 100644 index 0000000..98a3dc9 --- /dev/null +++ b/doc/docs/.vitepress/grammars/moonscript.tmLanguage.json @@ -0,0 +1,149 @@ +{ + "comment": "MoonScript Syntax: 0.0.1", + "fileTypes": [ + "moon" + ], + "name": "MoonScript", + "patterns": [ + { + "captures": { + "1": { + "name": "punctuation.definition.comment.lua" + } + }, + "match": "(--)(?!\\[\\[).*$\\n?", + "name": "comment.line.double-dash.lua" + }, + { + "begin": "'", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.lua" + } + }, + "end": "'", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.lua" + } + }, + "name": "string.quoted.single.lua", + "patterns": [ + { + "match": "\\\\(\\d{1,3}|.)", + "name": "constant.character.escape.lua" + } + ] + }, + { + "begin": "\"", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.lua" + } + }, + "end": "\"", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.lua" + } + }, + "name": "string.quoted.double.lua", + "patterns": [ + { + "match": "\\\\(\\d{1,3}|.)", + "name": "constant.character.escape.lua" + } + ] + }, + { + "begin": "(? - - - - - - - - -]> - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/doc/docs/.vitepress/theme/components/CompilerModal.vue b/doc/docs/.vitepress/theme/components/CompilerModal.vue index 8620536..c00443e 100755 --- a/doc/docs/.vitepress/theme/components/CompilerModal.vue +++ b/doc/docs/.vitepress/theme/components/CompilerModal.vue @@ -1,7 +1,6 @@