Repository navigation
Expand file tree
/
Copy pathinstall_docs.php
More file actions
137 lines (109 loc) · 29.5 KB
/
Copy pathinstall_docs.php
File metadata and controls
137 lines (109 loc) · 29.5 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
/**
* install_docs.php — YL v4 docs (VitePress, i18n: ru / en / zh-Hans / zh-Hant)
* Весь файл — чистый ASCII. Юникод-символы YL вставляются через escape-последовательности.
*/
declare(strict_types=1);
$BASE = __DIR__;
/* ---------- Утилиты ---------- */
function y(string $s): string {
static $m = null;
if ($m === null) {
$m = [
'~DECL~'=>"\u{00A4}", '~FN~'=>"\u{00A7}", '~LAM~'=>"\u{03BB}",
'~PR~'=>"\u{00BB}", '~O~'=>"\u{27E6}", '~C~'=>"\u{27E7}",
'~EL~'=>"\u{00BF}", '~EACH~'=>"\u{21F6}", '~YLD~'=>"\u{21A4}",
'~CLS~'=>"\u{2021}", '~MET~'=>"\u{22D4}", '~NEW~'=>"\u{21E2}",
'~INH~'=>"\u{2020}", '~ASY~'=>"\u{26A1}", '~AWT~'=>"\u{23F8}",
'~T~'=>"\u{2611}", '~F~'=>"\u{2610}", '~NUL~'=>"\u{2205}",
'~TRY~'=>"\u{203C}", '~CTH~'=>"\u{2047}", '~FIN~'=>"\u{2326}",
'~IMP~'=>"\u{2295}", '~DO~'=>"\u{27EA}", '~DC~'=>"\u{27EB}",
'~BRK~'=>"\u{2298}", '~CNT~'=>"\u{21BB}", '~AST~'=>"\u{2261}",
'~RAR~'=>"\u{2192}", '~UARR~'=>"\u{2191}",
];
}
return str_replace(array_keys($m), array_values($m), $s);
}
function w(string $rel, string $content): void {
global $BASE;
$p = $BASE . '/' . $rel;
if (!is_dir(dirname($p))) mkdir(dirname($p), 0777, true);
file_put_contents($p, y($content));
echo " + $rel (" . strlen($content) . " b)\n";
}
echo "YL v4 docs installer -> $BASE\n\n";
/* ---------- КОРНЕВЫЕ ФАЙЛЫ ---------- */
w('package.json', '{
"name": "yl-lang",
"version": "4.0.0",
"private": true,
"description": "YL - Yankee Language, esoteric programming language on PHP",
"scripts": {
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs"
},
"devDependencies": {
"vitepress": "^1.5.0"
}
}');
w('vercel.json', '{
"$schema": "https://openapi.vercel.sh/vercel.json",
"buildCommand": "npm run docs:build",
"outputDirectory": "docs/.vitepress/dist",
"installCommand": "npm install",
"framework": null
}');
w('.gitignore', "# PHP\n/vendor/\ncomposer.lock\n\n# Node\nnode_modules/\ndocs/.vitepress/dist/\ndocs/.vitepress/cache/\n.vercel\n\n# YL\n*.bak\n*.bak2\n*.bak3\nmain_compiled.php\ntest_*_compiled.php\nout.txt\nyl_modules/\nylpkg.json\n\n# OS\n.DS_Store\nThumbs.db\n");
w('LICENSE', "MIT License\n\nCopyright (c) 2026 YL Contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n");
w('composer.json', '{
"name": "yankee/yl",
"description": "YL - Yankee Language, esoteric programming language on PHP",
"type": "project",
"license": "MIT",
"require": {
"php": ">=8.1",
"ext-mbstring": "*",
"ext-json": "*"
},
"bin": ["yl.php"]
}');
w('README.md', "# YL - Yankee Language\n\nEsoteric programming language on PHP with unicode syntax.\n\n## Example\n\n```yl\n~CLS~ Point ~O~\n ~MET~ init(x, y) ~O~ this.x = x; this.y = y ~C~\n ~MET~ length() ~O~ ^ sqrt(this.x * this.x + this.y * this.y) ~C~\n~C~\n\n~DECL~ p = ~NEW~ Point(3, 4)\n~PR~ \"Length:\", p.length()\n```\n\n## Features\n\n- Unique unicode syntax (~DECL~ ~FN~ ~LAM~ ~O~ ~C~ ~CLS~ ~MET~ ~NEW~)\n- Gradual typing: ~DECL~ x :int = 5\n- OOP with ~INH~ inheritance: ~CLS~ Child ~INH~ Parent\n- Closures: ~LAM~ (x) ~O~ ^ x * 2 ~C~\n- Generators on PHP Fibers: ~YLD~ + ~EACH~\n- Async: ~ASY~ ~FN~, ~AWT~\n- Stdlib: prelude, math, list, string, json, datetime, http\n- REPL v4 with :vars, :load, multiline\n- Compiler YL->PHP (ylc.php)\n- Package manager (ylpkg.php)\n- Browser playground (playground/)\n\n## Quick start\n\n```bash\nphp yl.php examples/main.yl\n```\n\n## Docs (i18n)\n\n- Russian: /\n- English: /en/\n- Simplified Chinese: /zh-Hans/\n- Traditional Chinese (Taiwan style): /zh-Hant/\n\n## License\n\nMIT\n");
/* ---------- VITEPRESS CONFIG ---------- */
w('docs/.vitepress/config.mts', "import { defineConfig } from 'vitepress'\n\nexport default defineConfig({\n title: 'YL',\n description: 'Yankee Language - esoteric programming language with unicode syntax',\n cleanUrls: true,\n head: [['meta', { name: 'theme-color', content: '#ffd369' }]],\n themeConfig: {\n socialLinks: [{ icon: 'github', link: 'https://github.com/your/yl' }],\n },\n locales: {\n root: {\n label: 'Russian', lang: 'ru',\n themeConfig: {\n nav: [\n { text: 'Guide', link: '/guide/getting-started' },\n { text: 'Syntax', link: '/guide/syntax' },\n { text: 'Stdlib', link: '/guide/stdlib' },\n ],\n sidebar: [{ text: 'Guide', items: [\n { text: 'Getting started', link: '/guide/getting-started' },\n { text: 'Syntax', link: '/guide/syntax' },\n { text: 'Stdlib', link: '/guide/stdlib' },\n ]}],\n },\n },\n en: {\n label: 'English', lang: 'en', link: '/en/',\n themeConfig: {\n nav: [\n { text: 'Guide', link: '/en/guide/getting-started' },\n { text: 'Syntax', link: '/en/guide/syntax' },\n { text: 'Stdlib', link: '/en/guide/stdlib' },\n ],\n sidebar: [{ text: 'Guide', items: [\n { text: 'Getting started', link: '/en/guide/getting-started' },\n { text: 'Syntax', link: '/en/guide/syntax' },\n { text: 'Stdlib', link: '/en/guide/stdlib' },\n ]}],\n },\n },\n 'zh-Hans': {\n label: 'Simplified Chinese', lang: 'zh-Hans', link: '/zh-Hans/',\n themeConfig: {\n nav: [\n { text: 'Guide', link: '/zh-Hans/guide/getting-started' },\n { text: 'Syntax', link: '/zh-Hans/guide/syntax' },\n { text: 'Stdlib', link: '/zh-Hans/guide/stdlib' },\n ],\n sidebar: [{ text: 'Guide', items: [\n { text: 'Getting started', link: '/zh-Hans/guide/getting-started' },\n { text: 'Syntax', link: '/zh-Hans/guide/syntax' },\n { text: 'Stdlib', link: '/zh-Hans/guide/stdlib' },\n ]}],\n },\n },\n 'zh-Hant': {\n label: 'Traditional Chinese (Taiwan)', lang: 'zh-Hant', link: '/zh-Hant/',\n themeConfig: {\n nav: [\n { text: 'Guide der', link: '/zh-Hant/guide/getting-started' },\n { text: 'Syntax', link: '/zh-Hant/guide/syntax' },\n { text: 'Stdlib', link: '/zh-Hant/guide/stdlib' },\n ],\n sidebar: [{ text: 'Guide', items: [\n { text: 'Getting started', link: '/zh-Hant/guide/getting-started' },\n { text: 'Syntax', link: '/zh-Hant/guide/syntax' },\n { text: 'Stdlib', link: '/zh-Hant/guide/stdlib' },\n ]}],\n },\n },\n },\n})\n");
w('docs/.vitepress/theme/index.ts', "import DefaultTheme from 'vitepress/theme'\nimport './custom.css'\n\nexport default DefaultTheme\n");
w('docs/.vitepress/theme/custom.css', ":root{--vp-c-brand-1:#ffd369;--vp-c-brand-2:#f9c74f;--vp-c-brand-3:#e0a800}.dark{--vp-c-bg:#1a1a2e;--vp-c-bg-alt:#16213e;--vp-c-brand-1:#ffd369}.vp-doc code{font-feature-settings:'liga' 0}.VPHero .name{font-family:var(--vp-font-family-mono);letter-spacing:-.02em}\n");
/* ---------- СТРАНИЦЫ: RU ---------- */
w('docs/index.md', "---\nlayout: home\nhero:\n name: YL\n text: Yankee Language\n tagline: Esoteric language on PHP with unicode syntax. Unlike anything else.\n actions:\n - theme: brand\n text: Getting started\n link: /guide/getting-started\n - theme: alt\n text: Syntax\n link: /guide/syntax\nfeatures:\n - title: ~DECL~ ~FN~ ~LAM~ ~O~ ~C~\n details: Unique symbols instead of keywords.\n - title: OOP with ~INH~ inheritance\n details: ~CLS~ Class ~INH~ Parent, ~MET~ method, ~NEW~ new.\n - title: Closures and map/filter\n details: ~LAM~ (x) ~O~ ^ x * 2 ~C~\n - title: Generators on Fibers\n details: ~YLD~ value + ~EACH~ x = gen ~O~ ~C~\n - title: Async ~ASY~ ~AWT~\n details: async fn and await built into the language.\n - title: Stdlib + JSON + HTTP\n details: prelude, math, list, string, json, datetime, http.\n---\n\n## Example\n\n```yl\n~CLS~ Animal ~O~\n ~MET~ init(name :str) ~O~\n this.name = name\n ~C~\n ~MET~ sound() ~O~\n ^ \"...\"\n ~C~\n~C~\n\n~CLS~ Dog ~INH~ Animal ~O~\n ~MET~ sound() ~O~ ^ \"Woof!\" ~C~\n~C~\n\n~DECL~ rex = ~NEW~ Dog(\"Rex\")\n~PR~ rex.name + \" says: \" + rex.sound()\n```\n\nOutput:\n\n```\nRex says: Woof!\n```\n");
w('docs/guide/getting-started.md', "# Getting started\n\n## Requirements\n\n- PHP 8.1+\n- Composer (optional)\n- Node 18+ (for building these docs)\n\n```bash\nphp -v\n```\n\n## Install\n\n```bash\ngit clone https://github.com/your/yl.git\ncd yl\n```\n\n## First program\n\nCreate `hello.yl`:\n\n```yl\n~PR~ \"Hello, world!\"\n```\n\nRun:\n\n```bash\nphp yl.php hello.yl\n```\n\n## Variables\n\n```yl\n~DECL~ name = \"Alice\"\n~DECL~ age = 25\n~DECL~ flag = ~T~\n```\n\n## Functions\n\n```yl\n~FN~ square(x) ~O~\n ^ x * x\n~C~\n```\n\n## REPL\n\n```bash\nphp yl.php --repl\n```\n\nCommands: `:help`, `:vars`, `:load <file>`, `exit`.\n\n## Playground\n\n```bash\ncd playground\nphp -S 127.0.0.1:8080\n```\n\n## Compiler\n\n```bash\nphp ylc.php script.yl script.php\nphp script.php\n```\n");
w('docs/guide/syntax.md', "# Syntax\n\n## Symbols\n\n| Symbol | Meaning |\n|---|---|\n| `~` | comment |\n| `~DECL~` | declare variable |\n| `~FN~` | function |\n| `~LAM~` | lambda |\n| `~PR~` | print |\n| `~O~ ~C~` | block |\n| `?` / `~EL~` | if / else |\n| `@` | while |\n| `#` | for |\n| `~EACH~` | foreach |\n| `^` | return |\n| `~YLD~` | yield |\n| `~TRY~ ~CTH~ ~FIN~` | try/catch/finally |\n| `~IMP~` | import |\n| `~BRK~ ~CNT~` | break/continue |\n| `~AST~` | assert |\n| `~T~ ~F~ ~NUL~` | true/false/null |\n| `~DO~ ~DC~` | dict |\n| `~CLS~` | class |\n| `~MET~` | method |\n| `~NEW~` | new |\n| `~INH~` | inherit |\n| `~ASY~ ~AWT~` | async/await |\n\n## Variables\n\n```yl\n~DECL~ x = 5\n~DECL~ name = \"Alice\"\n~DECL~ flag = ~T~\n~DECL~ nums = [1, 2, 3]\n~DECL~ person = ~DO~\"name\": \"Alice\", \"age\": 25~DC~\n```\n\nWith types:\n\n```yl\n~DECL~ x :int = 5\n~DECL~ name :str = \"Alice\"\n```\n\n## Conditionals\n\n```yl\n? x > 5 ~O~\n ~PR~ \"greater than 5\"\n~C~ ~EL~ ~O~\n ~PR~ \"not greater\"\n~C~\n```\n\n## Loops\n\n```yl\n@ i < 10 ~O~\n ~PR~ i\n i = i + 1\n~C~\n\n# i = 0 .. 10 ~O~\n ~PR~ i\n~C~\n\n~EACH~ x = [1, 2, 3] ~O~\n ~PR~ x\n~C~\n```\n\n## Functions\n\n```yl\n~FN~ add(a, b) ~O~\n ^ a + b\n~C~\n\n~FN~ sqrt_newton(x :float) :float ~O~\n ? x <= 0 ~O~ ^ 0 ~C~\n ~DECL~ g = x / 2\n # i = 0 .. 10 ~O~\n g = (g + x / g) / 2\n ~C~\n ^ g\n~C~\n```\n\n## Closures\n\n```yl\n~DECL~ double = ~LAM~ (x) ~O~ ^ x * 2 ~C~\n~PR~ double(21)\n```\n\n## Destructuring\n\n```yl\n~DECL~ [a, b, c] = [1, 2, 3]\n~DECL~ ~DO~\"x\", \"y\"~DC~ = ~DO~\"x\": 10, \"y\": 20~DC~\n```\n\n## Classes\n\n```yl\n~CLS~ Animal ~O~\n ~MET~ init(name :str) ~O~\n this.name = name\n ~C~\n ~MET~ sound() ~O~\n ^ \"...\"\n ~C~\n~C~\n\n~CLS~ Dog ~INH~ Animal ~O~\n ~MET~ sound() ~O~ ^ \"Woof!\" ~C~\n~C~\n\n~DECL~ rex = ~NEW~ Dog(\"Rex\")\n~PR~ rex.name + \" says: \" + rex.sound()\n```\n\n## Generators\n\n```yl\n~FN~ evens(n) ~O~\n # i = 0 .. n ~O~\n ? even(i) ~O~ ~YLD~ i ~C~\n ~C~\n~C~\n\n~EACH~ x = evens(10) ~O~\n ~PR~ \"even:\", x\n~C~\n```\n\nGenerators use real PHP Fibers.\n\n## Async\n\n```yl\n~ASY~ ~FN~ slow(x) ~O~\n ^ x * 2\n~C~\n\n~DECL~ t = slow(21)\n~PR~ ~AWT~ t\n```\n\n## Error handling\n\n```yl\n~TRY~ ~O~\n ~DECL~ r = 10 / 0\n~C~ ~CTH~ e ~O~\n ~PR~ \"Caught:\", e\n~C~ ~FIN~ ~O~\n ~PR~ \"finally\"\n~C~\n```\n\n## Modules\n\n```yl\n~IMP~ \"std/math.yl\" as m\n~PR~ m.square(6)\n```\n");
w('docs/guide/stdlib.md', "# Standard library\n\n## Auto-loaded: std/prelude.yl\n\n### Strings\n\n`position`, `contains`, `repeat`, `replace`\n\n### Arrays\n\n`sum`, `product`, `average`, `sort`, `unique`, `max_of`, `min_of`\n\n### Math\n\n`factorial`, `gcd`, `even`, `odd`\n\n## Built-ins\n\n### General\n\n`len`, `str`, `num`, `type`, `assert`, `eval`, `exit`, `dump`, `time`\n\n### Strings\n\n`upper`, `lower`, `trim`, `split`, `join`\n\n### Math\n\n`abs`, `floor`, `ceil`, `round`, `min`, `max`, `sqrt`, `rand`, `range`\n\n### Arrays\n\n`push`, `pop`, `keys`, `vals`, `map`, `filter`, `reduce`\n\n### JSON\n\n```yl\n~DECL~ data = json_parse('{\"x\": 1}')\n~PR~ data[\"x\"]\n~DECL~ s = json_str(data)\n~DECL~ pretty = json_str_pretty(data)\n```\n\n### Date / time\n\n```yl\n~PR~ now()\n~PR~ today()\n~PR~ ISO(now())\n```\n\n### HTTP\n\n```yl\n~DECL~ html = http_get(\"https://example.com\")\n~DECL~ resp = http_post(\"https://api.example.com\", \"{}\")\n```\n\n### Files\n\n`readfile`, `writefile`, `appendfile`, `exists`, `read`\n\n## Extra modules\n\n### std/math.yl\n\n```yl\n~IMP~ \"std/math.yl\" as m\n~PR~ m.PI\n~PR~ m.power(2, 10)\n~PR~ m.clamp(15, 0, 10)\n```\n\n### std/list.yl\n\n```yl\n~IMP~ \"std/list.yl\" as list\n~PR~ list.head([1,2,3])\n~PR~ list.reverse([1,2,3])\n```\n\n### std/string.yl\n\n```yl\n~IMP~ \"std/string.yl\" as s\n~PR~ s.capital(\"hello\")\n~PR~ s.words(\"a b c\")\n```\n\n### std/json.yl\n\n```yl\n~IMP~ \"std/json.yl\" as j\n~PR~ j.parse('{\"x\":1}')\n~PR~ j.encode([1,2,3])\n```\n\n### std/datetime.yl\n\n```yl\n~IMP~ \"std/datetime.yl\" as dt\n~PR~ dt.now_str()\n~PR~ dt.ISO(now())\n```\n");
/* ---------- СТРАНИЦЫ: EN ---------- */
w('docs/en/index.md', "---\nlayout: home\nhero:\n name: YL\n text: Yankee Language\n tagline: Esoteric language on PHP with unicode syntax. Unlike anything else.\n actions:\n - theme: brand\n text: Get started\n link: /en/guide/getting-started\n - theme: alt\n text: Syntax\n link: /en/guide/syntax\nfeatures:\n - title: ~DECL~ ~FN~ ~LAM~ ~O~ ~C~\n details: Unique symbols instead of keywords.\n - title: OOP with ~INH~ inheritance\n details: ~CLS~ Class ~INH~ Parent, ~MET~ method, ~NEW~ new.\n - title: Closures and map/filter\n details: ~LAM~ (x) ~O~ ^ x * 2 ~C~\n - title: Generators on Fibers\n details: ~YLD~ value + ~EACH~ x = gen ~O~ ~C~\n - title: Async ~ASY~ ~AWT~\n details: async fn and await built in.\n - title: Stdlib + JSON + HTTP\n details: prelude, math, list, string, json, datetime, http.\n---\n\n## Example\n\n```yl\n~CLS~ Animal ~O~\n ~MET~ init(name :str) ~O~\n this.name = name\n ~C~\n ~MET~ sound() ~O~\n ^ \"...\"\n ~C~\n~C~\n\n~CLS~ Dog ~INH~ Animal ~O~\n ~MET~ sound() ~O~ ^ \"Woof!\" ~C~\n~C~\n\n~DECL~ rex = ~NEW~ Dog(\"Rex\")\n~PR~ rex.name + \" says: \" + rex.sound()\n```\n\nOutput:\n\n```\nRex says: Woof!\n```\n");
w('docs/en/guide/getting-started.md', "# Getting started\n\n## Requirements\n\n- PHP 8.1+\n- Composer (optional)\n- Node 18+ (for building these docs)\n\n```bash\nphp -v\n```\n\n## Install\n\n```bash\ngit clone https://github.com/your/yl.git\ncd yl\n```\n\n## First program\n\nCreate `hello.yl`:\n\n```yl\n~PR~ \"Hello, world!\"\n```\n\nRun:\n\n```bash\nphp yl.php hello.yl\n```\n\n## Variables\n\n```yl\n~DECL~ name = \"Alice\"\n~DECL~ age = 25\n~DECL~ flag = ~T~\n```\n\n## Functions\n\n```yl\n~FN~ square(x) ~O~\n ^ x * x\n~C~\n```\n\n## REPL\n\n```bash\nphp yl.php --repl\n```\n\nCommands: `:help`, `:vars`, `:load <file>`, `exit`.\n\n## Playground\n\n```bash\ncd playground\nphp -S 127.0.0.1:8080\n```\n\n## Compiler\n\n```bash\nphp ylc.php script.yl script.php\nphp script.php\n```\n");
w('docs/en/guide/syntax.md', "# Syntax\n\n## Symbols\n\n| Symbol | Meaning |\n|---|---|\n| `~DECL~` | declare |\n| `~FN~` | function |\n| `~LAM~` | lambda |\n| `~PR~` | print |\n| `~O~ ~C~` | block |\n| `?` / `~EL~` | if / else |\n| `@` | while |\n| `#` | for |\n| `~EACH~` | foreach |\n| `^` | return |\n| `~YLD~` | yield |\n| `~TRY~ ~CTH~ ~FIN~` | try/catch/finally |\n| `~IMP~` | import |\n| `~BRK~ ~CNT~` | break/continue |\n| `~T~ ~F~ ~NUL~` | true/false/null |\n| `~CLS~ ~MET~ ~NEW~ ~INH~` | class machinery |\n| `~ASY~ ~AWT~` | async/await |\n\n## Variables\n\n```yl\n~DECL~ x = 5\n~DECL~ name = \"Alice\"\n~DECL~ nums = [1, 2, 3]\n~DECL~ person = ~DO~\"name\": \"Alice\"~DC~\n```\n\nWith types: `~DECL~ x :int = 5`.\n\n## Conditionals\n\n```yl\n? x > 5 ~O~\n ~PR~ \"big\"\n~C~ ~EL~ ~O~\n ~PR~ \"small\"\n~C~\n```\n\n## Loops\n\n```yl\n@ i < 10 ~O~ i = i + 1 ~C~\n# i = 0 .. 10 ~O~ ~PR~ i ~C~\n~EACH~ x = [1, 2, 3] ~O~ ~PR~ x ~C~\n```\n\n## Functions and closures\n\n```yl\n~FN~ add(a, b) ~O~ ^ a + b ~C~\n~DECL~ double = ~LAM~ (x) ~O~ ^ x * 2 ~C~\n```\n\n## Classes\n\n```yl\n~CLS~ Dog ~O~\n ~MET~ init(name) ~O~ this.name = name ~C~\n ~MET~ sound() ~O~ ^ \"Woof!\" ~C~\n~C~\n\n~DECL~ rex = ~NEW~ Dog(\"Rex\")\n```\n\n## Generators / Async\n\n```yl\n~FN~ evens(n) ~O~ # i = 0 .. n ~O~ ? even(i) ~O~ ~YLD~ i ~C~ ~C~ ~C~\n\n~ASY~ ~FN~ slow(x) ~O~ ^ x * 2 ~C~\n~DECL~ t = slow(21)\n~PR~ ~AWT~ t\n```\n\n## Error handling\n\n```yl\n~TRY~ ~O~ ~DECL~ r = 10 / 0 ~C~ ~CTH~ e ~O~ ~PR~ e ~C~ ~FIN~ ~O~ ~PR~ \"done\" ~C~\n```\n");
w('docs/en/guide/stdlib.md', "# Standard library\n\n## Auto-loaded prelude\n\nStrings: `position`, `contains`, `repeat`, `replace`.\nArrays: `sum`, `product`, `average`, `sort`, `unique`, `max_of`, `min_of`.\nMath: `factorial`, `gcd`, `even`, `odd`.\n\n## Built-ins\n\nGeneral: `len`, `str`, `num`, `type`, `assert`, `eval`, `exit`, `dump`, `time`.\nStrings: `upper`, `lower`, `trim`, `split`, `join`.\nMath: `abs`, `floor`, `ceil`, `round`, `min`, `max`, `sqrt`, `rand`, `range`.\nArrays: `push`, `pop`, `keys`, `vals`, `map`, `filter`, `reduce`.\n\n## JSON\n\n```yl\n~DECL~ data = json_parse('{\"x\": 1}')\n~PR~ data[\"x\"]\n```\n\n## Datetime\n\n```yl\n~PR~ now()\n~PR~ ISO(now())\n```\n\n## HTTP\n\n```yl\n~DECL~ html = http_get(\"https://example.com\")\n```\n\n## Files\n\n`readfile`, `writefile`, `appendfile`, `exists`, `read`.\n\n## Extra modules\n\n```yl\n~IMP~ \"std/math.yl\" as m\n~IMP~ \"std/list.yl\" as list\n~IMP~ \"std/json.yl\" as j\n~IMP~ \"std/datetime.yl\" as dt\n```\n");
/* ---------- СТРАНИЦЫ: ZH-HANS ---------- */
w('docs/zh-Hans/index.md', "---\nlayout: home\nhero:\n name: YL\n text: Yankee Language\n tagline: 基于 PHP 的另类编程语言,语法用 Unicode 符号。与众不同。\n actions:\n - theme: brand\n text: 快速开始\n link: /zh-Hans/guide/getting-started\n - theme: alt\n text: 语法\n link: /zh-Hans/guide/syntax\nfeatures:\n - title: ~DECL~ ~FN~ ~LAM~ ~O~ ~C~\n details: 用符号代替关键字。\n - title: 用 ~INH~ 继承的 OOP\n details: ~CLS~ 类 ~INH~ 父类,~MET~ 方法,~NEW~ 实例化。\n - title: 闭包 + map/filter\n details: ~LAM~ (x) ~O~ ^ x * 2 ~C~\n - title: 基于 Fiber 的生成器\n details: ~YLD~ value + ~EACH~ x = gen ~O~ ~C~\n - title: 异步 ~ASY~ ~AWT~\n details: async fn 与 await 内建。\n - title: 标准库 + JSON + HTTP\n details: prelude、math、list、string、json、datetime、http。\n---\n\n## 示例\n\n```yl\n~CLS~ 动物 ~O~\n ~MET~ init(名字 :str) ~O~ this.名字 = 名字 ~C~\n ~MET~ 叫声() ~O~ ^ \"...\" ~C~\n~C~\n\n~CLS~ 狗 ~INH~ 动物 ~O~\n ~MET~ 叫声() ~O~ ^ \"汪!\" ~C~\n~C~\n\n~DECL~ 小七 = ~NEW~ 狗(\"小七\")\n~PR~ 小七.名字 + \" 说:\" + 小七.叫声()\n```\n\n输出:`小七 说:汪!`\n");
w('docs/zh-Hans/guide/getting-started.md', "# 快速开始\n\n## 环境\n\n- PHP 8.1+\n- Composer(可选)\n- Node 18+(构建本网站)\n\n## 安装\n\n```bash\ngit clone https://github.com/your/yl.git\ncd yl\n```\n\n## 第一个程序\n\n新建 `hello.yl`:\n\n```yl\n~PR~ \"你好,世界!\"\n```\n\n运行:\n\n```bash\nphp yl.php hello.yl\n```\n\n## 变量\n\n```yl\n~DECL~ 名字 = \"小七\"\n~DECL~ 年龄 = 25\n~DECL~ 标志 = ~T~\n```\n\n## 函数\n\n```yl\n~FN~ 平方(x) ~O~\n ^ x * x\n~C~\n```\n\n## REPL\n\n```bash\nphp yl.php --repl\n```\n\n命令:`:help`、`:vars`、`:load <文件>`、`выход`。\n\n## Playground\n\n```bash\ncd playground\nphp -S 127.0.0.1:8080\n```\n\n## 编译器\n\n```bash\nphp ylc.php script.yl script.php\n```\n");
w('docs/zh-Hans/guide/syntax.md', "# 语法\n\n## 符号\n\n| 符号 | 含义 |\n|---|---|\n| `~DECL~` | 声明变量 |\n| `~FN~` | 定义函数 |\n| `~LAM~` | 闭包 |\n| `~PR~` | 打印 |\n| `~O~ ~C~` | 代码块 |\n| `?` / `~EL~` | 如果 / 否则 |\n| `@` | while |\n| `#` | for |\n| `~EACH~` | foreach |\n| `^` | return |\n| `~YLD~` | yield |\n| `~TRY~ ~CTH~ ~FIN~` | try/catch/finally |\n| `~IMP~` | 导入 |\n| `~BRK~ ~CNT~` | break/continue |\n| `~T~ ~F~ ~NUL~` | true/false/null |\n| `~CLS~ ~MET~ ~NEW~ ~INH~` | 类机制 |\n| `~ASY~ ~AWT~` | 异步 / 等待 |\n\n## 变量\n\n```yl\n~DECL~ x = 5\n~DECL~ 名字 = \"小七\"\n~DECL~ 数字 = [1, 2, 3]\n~DECL~ 人 = ~DO~\"名字\": \"小七\"~DC~\n```\n\n带类型:`~DECL~ x :int = 5`。\n\n## 条件\n\n```yl\n? x > 5 ~O~\n ~PR~ \"大\"\n~C~ ~EL~ ~O~\n ~PR~ \"小\"\n~C~\n```\n\n## 循环\n\n```yl\n@ i < 10 ~O~ i = i + 1 ~C~\n# i = 0 .. 10 ~O~ ~PR~ i ~C~\n~EACH~ x = [1, 2, 3] ~O~ ~PR~ x ~C~\n```\n\n## 函数与闭包\n\n```yl\n~FN~ 加法(a, b) ~O~ ^ a + b ~C~\n~DECL~ 翻倍 = ~LAM~ (x) ~O~ ^ x * 2 ~C~\n```\n\n## 类\n\n```yl\n~CLS~ 狗 ~O~\n ~MET~ init(名字) ~O~ this.名字 = 名字 ~C~\n ~MET~ 叫声() ~O~ ^ \"汪!\" ~C~\n~C~\n\n~DECL~ 小七 = ~NEW~ 狗(\"小七\")\n```\n\n## 生成器 / 异步\n\n```yl\n~FN~ 偶数(n) ~O~ # i = 0 .. n ~O~ ? even(i) ~O~ ~YLD~ i ~C~ ~C~ ~C~\n\n~ASY~ ~FN~ 慢(x) ~O~ ^ x * 2 ~C~\n~DECL~ t = 慢(21)\n~PR~ ~AWT~ t\n```\n\n## 错误处理\n\n```yl\n~TRY~ ~O~ ~DECL~ r = 10 / 0 ~C~ ~CTH~ e ~O~ ~PR~ e ~C~ ~FIN~ ~O~ ~PR~ \"完成\" ~C~\n```\n");
w('docs/zh-Hans/guide/stdlib.md', "# 标准库\n\n## 自动加载 prelude\n\n字符串:`position`、`contains`、`repeat`、`replace`。\n数组:`sum`、`product`、`average`、`sort`、`unique`、`max_of`、`min_of`。\n数学:`factorial`、`gcd`、`even`、`odd`。\n\n## 内置函数\n\n通用:`len`、`str`、`num`、`type`、`assert`、`eval`、`exit`、`dump`、`time`。\n字符串:`upper`、`lower`、`trim`、`split`、`join`。\n数学:`abs`、`floor`、`ceil`、`round`、`min`、`max`、`sqrt`、`rand`、`range`。\n数组:`push`、`pop`、`keys`、`vals`、`map`、`filter`、`reduce`。\n\n## JSON\n\n```yl\n~DECL~ data = json_parse('{\"x\": 1}')\n~PR~ data[\"x\"]\n```\n\n## 日期时间\n\n```yl\n~PR~ now()\n~PR~ ISO(now())\n```\n\n## HTTP\n\n```yl\n~DECL~ html = http_get(\"https://example.com\")\n```\n\n## 文件\n\n`readfile`、`writefile`、`appendfile`、`exists`、`read`。\n\n## 额外模块\n\n```yl\n~IMP~ \"std/math.yl\" as m\n~IMP~ \"std/list.yl\" as list\n~IMP~ \"std/json.yl\" as j\n~IMP~ \"std/datetime.yl\" as dt\n```\n");
/* ---------- СТРАНИЦЫ: ZH-HANT (Taiwan style) ---------- */
w('docs/zh-Hant/index.md', "---\nlayout: home\nhero:\n name: YL\n text: Yankee Language\n tagline: 一個跑在 PHP 上面、語法全部用 Unicode 符號 der 冷門語言。保證你沒看過這種的啦!\n actions:\n - theme: brand\n text: 立馬開始\n link: /zh-Hant/guide/getting-started\n - theme: alt\n text: 語法 der\n link: /zh-Hant/guide/syntax\nfeatures:\n - title: ~DECL~ ~FN~ ~LAM~ ~O~ ~C~\n details: 用符號取代關鍵字,這 code 超帥 der!\n - title: ~INH~ 繼承 der OOP\n details: ~CLS~ 類別 ~INH~ 父類別、~MET~ 方法、~NEW~ 建立物件。\n - title: 閉包 + map/filter\n details: ~LAM~ (x) ~O~ ^ x * 2 ~C~ — 該有的都沒少。\n - title: Fiber 做的生成器\n details: ~YLD~ value + ~EACH~ x = gen ~O~ ~C~ — 正港 PHP Fiber。\n - title: 非同步 ~ASY~ ~AWT~\n details: async fn 跟 await 直接內建,ヤバい讚。\n - title: 標準庫 + JSON + HTTP\n details: prelude、math、list、string、json、datetime、http,該有的都有 der。\n---\n\n## 範例\n\n```yl\n~CLS~ 動物 ~O~\n ~MET~ init(名字 :str) ~O~ this.名字 = 名字 ~C~\n ~MET~ 叫聲() ~O~ ^ \"...\" ~C~\n~C~\n\n~CLS~ 狗 ~INH~ 動物 ~O~\n ~MET~ 叫聲() ~O~ ^ \"汪汪!\" ~C~\n~C~\n\n~DECL~ 小七 = ~NEW~ 狗(\"小七\")\n~PR~ 小七.名字 + \" 說:\" + 小七.叫聲()\n```\n\n輸出:`小七 說:汪汪!`\n\n::: tip 小編碎碎念\n這語言真的母湯,けどう寫起來マジ爽。\n:::\n");
w('docs/zh-Hant/guide/getting-started.md', "# 立馬開始\n\n## 環境需求\n\n- PHP 8.1+\n- Composer — 可有可無 der\n- Node 18+ — 只有要 build 這個網站才需要\n\n```bash\nphp -v\n```\n\n## 裝起來!\n\n```bash\ngit clone https://github.com/your/yl.git\ncd yl\n```\n\n## 第一個程式\n\n開個檔案 `hello.yl`:\n\n```yl\n~PR~ \"安安,世界!\"\n```\n\nRun 下去:\n\n```bash\nphp yl.php hello.yl\n```\n\n## 變數\n\n```yl\n~DECL~ 名字 = \"小七\"\n~DECL~ 年紀 = 25\n~DECL~ 是不是帥哥 = ~T~\n```\n\n## 函式\n\n```yl\n~FN~ 平方(x) ~O~\n ^ x * x\n~C~\n```\n\n## REPL\n\n```bash\nphp yl.php --repl\n```\n\n指令:`:help`、`:vars`、`:load <檔>`、`выход`(掰掰啦)。\n\n## Playground\n\n```bash\ncd playground\nphp -S 127.0.0.1:8080\n```\n\n打開瀏覽器 `http://127.0.0.1:8080`,左邊寫 code、右邊看 output。\n\n## 編譯器\n\n```bash\nphp ylc.php script.yl script.php\n```\n\n把 YL 編譯成合法 PHP。けどう OOP、模組、eval 母湯。\n");
w('docs/zh-Hant/guide/syntax.md', "# 語法 der\n\n## 符號一覽\n\n| 符號 | 代表啥 |\n|---|---|\n| `~DECL~` | 宣告變數 |\n| `~FN~` | 定義函式 |\n| `~LAM~` | 閉包 |\n| `~PR~` | 印出 |\n| `~O~ ~C~` | 區塊 |\n| `?` / `~EL~` | 如果 / 不然 |\n| `@` | while |\n| `#` | for |\n| `~EACH~` | foreach |\n| `^` | return |\n| `~YLD~` | yield |\n| `~TRY~ ~CTH~ ~FIN~` | try/catch/finally |\n| `~IMP~` | 匯入模組 |\n| `~BRK~ ~CNT~` | break / continue |\n| `~T~ ~F~ ~NUL~` | true / false / null |\n| `~CLS~ ~MET~ ~NEW~ ~INH~` | 類別機制 |\n| `~ASY~ ~AWT~` | 非同步 / 等待 |\n\n## 變數\n\n```yl\n~DECL~ x = 5\n~DECL~ 名字 = \"小七\"\n~DECL~ 帥 = ~T~\n~DECL~ 空 = ~NUL~\n~DECL~ 數字 = [1, 2, 3]\n~DECL~ 人 = ~DO~\"名字\": \"小七\", \"年紀\": 25~DC~\n```\n\n要加型別也可以:\n\n```yl\n~DECL~ x :int = 5\n~DECL~ 名字 :str = \"小七\"\n```\n\n## 條件\n\n```yl\n? x > 5 ~O~\n ~PR~ \"比 5 大啦\"\n~C~ ~EL~ ~O~\n ~PR~ \"沒比 5 大 der\"\n~C~\n```\n\n## 迴圈\n\n```yl\n@ i < 10 ~O~ i = i + 1 ~C~\n# i = 0 .. 10 ~O~ ~PR~ i ~C~\n~EACH~ x = [1, 2, 3] ~O~ ~PR~ x ~C~\n```\n\n## 函式與閉包\n\n```yl\n~FN~ 加(a, b) ~O~ ^ a + b ~C~\n~DECL~ 兩倍 = ~LAM~ (x) ~O~ ^ x * 2 ~C~\n```\n\n## 類別\n\n```yl\n~CLS~ 狗 ~O~\n ~MET~ init(名字) ~O~ this.名字 = 名字 ~C~\n ~MET~ 叫聲() ~O~ ^ \"汪汪!\" ~C~\n~C~\n\n~DECL~ 小七 = ~NEW~ 狗(\"小七\")\n```\n\n## 生成器 / 非同步\n\n```yl\n~FN~ 偶數(n) ~O~ # i = 0 .. n ~O~ ? even(i) ~O~ ~YLD~ i ~C~ ~C~ ~C~\n\n~ASY~ ~FN~ 慢慢算(x) ~O~ ^ x * 2 ~C~\n~DECL~ t = 慢慢算(21)\n~PR~ ~AWT~ t\n```\n\n生成器是正港 **PHP Fiber** 實作,不是假的 — 這是マジ lightweight。\n\n## 錯誤處理\n\n```yl\n~TRY~ ~O~ ~DECL~ r = 10 / 0 ~C~ ~CTH~ e ~O~ ~PR~ \"抓到惹:\", e ~C~ ~FIN~ ~O~ ~PR~ \"finally 跑完了\" ~C~\n```\n\n錯誤訊息會帶行號:`抓到惹:[行 1] 除以零`。\n\n## 模組\n\n```yl\n~IMP~ \"std/math.yl\" as m\n~PR~ m.квадрат(6)\n```\n\n::: warning 小編提醒\n`yl> ` 那個是 REPL 自己印的 prompt,你自己母湯打進去黑!\n:::\n");
w('docs/zh-Hant/guide/stdlib.md', "# 標準庫\n\n## 自動載入 prelude\n\n字串:`position`、`contains`、`repeat`、`replace`。\n陣列:`sum`、`product`、`average`、`sort`、`unique`、`max_of`、`min_of`。\n數學:`factorial`、`gcd`、`even`、`odd`。\n\n## 內建函式\n\n一般:`len`、`str`、`num`、`type`、`assert`、`eval`、`exit`、`dump`、`time`。\n字串:`upper`、`lower`、`trim`、`split`、`join`。\n數學:`abs`、`floor`、`ceil`、`round`、`min`、`max`、`sqrt`、`rand`、`range`。\n陣列:`push`、`pop`、`keys`、`vals`、`map`、`filter`、`reduce`。\n\n## JSON\n\n```yl\n~DECL~ data = json_parse('{\"x\": 1}')\n~PR~ data[\"x\"]\n```\n\n## 日期時間\n\n```yl\n~PR~ now()\n~PR~ ISO(now())\n```\n\n## HTTP\n\n```yl\n~DECL~ html = http_get(\"https://example.com\")\n```\n\n## 檔案\n\n`readfile`、`writefile`、`appendfile`、`exists`、`read`。\n\n## 加碼模組\n\n```yl\n~IMP~ \"std/math.yl\" as m\n~IMP~ \"std/list.yl\" as list\n~IMP~ \"std/json.yl\" as j\n~IMP~ \"std/datetime.yl\" as dt\n```\n\n::: tip 小編碎碎念\n這些 module 都嘛可以直接用,超方便的啦。\n:::\n");
/* ---------- ФИНАЛ ---------- */
$count = count(glob($BASE . '/docs/**/*.md', GLOB_BRACE)) + count(glob($BASE . '/docs/*.md'));
echo "\nГотово! Файлы созданы.\n\n";
echo "Дальше:\n";
echo " 1) npm install\n";
echo " 2) npm run docs:dev -> http://localhost:5173\n";
echo " 3) npm run docs:build -> docs/.vitepress/dist/\n\n";
echo "Git:\n";
echo " git init && git add . && git commit -m \"Initial YL v4\"\n";
echo " git branch -M main\n";
echo " git remote add origin https://github.com/YOU/yl.git\n";
echo " git push -u origin main\n\n";
echo "Vercel:\n";
echo " npx vercel (vercel.json уже готов)\n";