diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-02-03 22:42:37 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-03 22:42:37 +0800 |
| commit | e4f8d1b3b075323968bb6dc334226dff33c0a2b0 (patch) | |
| tree | 657e1ac82e54b91014dc12d15e90329bf66f9d0f | |
| parent | ca1ec12725c32b0173692e01259570966da8a9a6 (diff) | |
| download | yuescript-e4f8d1b3b075323968bb6dc334226dff33c0a2b0.tar.gz yuescript-e4f8d1b3b075323968bb6dc334226dff33c0a2b0.tar.bz2 yuescript-e4f8d1b3b075323968bb6dc334226dff33c0a2b0.zip | |
Updated doc.
| -rw-r--r-- | doc/docs/.vitepress/public/image/yuescript.svg | 2 | ||||
| -rwxr-xr-x | doc/docs/.vitepress/theme/components/YueCompiler.vue | 46 | ||||
| -rw-r--r-- | doc/docs/.vitepress/theme/custom.css | 42 | ||||
| -rw-r--r-- | doc/docs/.vitepress/theme/index.ts | 3 | ||||
| -rwxr-xr-x | doc/docs/doc/index.md | 10 | ||||
| -rw-r--r-- | doc/docs/index.md | 4 | ||||
| -rwxr-xr-x | doc/docs/zh/doc/index.md | 18 | ||||
| -rw-r--r-- | doc/docs/zh/index.md | 4 | ||||
| -rw-r--r-- | spec/inputs/compile_doc.yue | 4 | ||||
| -rw-r--r-- | spec/outputs/codes_from_doc.lua | 34 | ||||
| -rw-r--r-- | spec/outputs/codes_from_doc_zh.lua | 34 | ||||
| -rw-r--r-- | spec/outputs/compile_doc.lua | 10 |
12 files changed, 151 insertions, 60 deletions
diff --git a/doc/docs/.vitepress/public/image/yuescript.svg b/doc/docs/.vitepress/public/image/yuescript.svg index 71214fe..f81e533 100644 --- a/doc/docs/.vitepress/public/image/yuescript.svg +++ b/doc/docs/.vitepress/public/image/yuescript.svg | |||
| @@ -1 +1 @@ | |||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 284 244" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;"><g><path d="M88.8,198.15c-2.775,0.6 -6.075,1.2 -8.775,1.725c0.375,-1.5 1.425,-5.85 2.175,-8.625l-2.1,-2.175l-2.475,10.875c-0,0.15 -0.075,0.3 -0.225,0.45l-4.5,4.275l1.8,1.95l4.575,-4.35c0.15,-0.15 0.225,-0.225 0.375,-0.225l11.025,-1.875l-1.875,-2.025Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M100.5,220.05c-1.425,2.025 -3.15,2.925 -5.85,1.125c-2.7,-1.875 -2.55,-3.9 -1.2,-5.85l5.775,-8.4l-2.175,-1.5l-5.85,8.55c-2.1,3 -1.725,5.925 2.4,8.775c4.425,3 7.275,1.8 9.15,-0.975l5.775,-8.475l-2.25,-1.5l-5.775,8.25Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M112.275,233.1l10.8,4.275l1.05,-1.575l-8.7,-3.525l2.025,-5.1l7.95,3.15l0.675,-1.8l-7.875,-3.15l1.8,-4.425l8.25,3.3l0.675,-1.725l-10.65,-4.275l-6,14.85Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M144.15,225.975c-3.525,-0.6 -6.15,0.6 -6.6,3.15c-0.375,2.25 0.9,3.675 4.725,5.4c3,1.35 3.9,2.25 3.6,3.975c-0.3,1.65 -1.8,2.325 -4.05,1.95c-2.175,-0.375 -3.525,-1.65 -3.6,-3.6l-2.625,-0.45c-0.225,2.925 1.8,5.1 5.7,5.85c4.275,0.75 6.75,-0.825 7.2,-3.45c0.375,-2.175 -0.525,-3.9 -4.95,-5.925c-2.775,-1.275 -3.675,-1.95 -3.45,-3.375c0.225,-1.35 1.425,-2.025 3.525,-1.65c2.25,0.375 3.075,1.575 3.075,3.15l2.55,0.45c0.45,-2.475 -0.975,-4.725 -5.1,-5.475Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M167.925,242.1c-3.9,0.15 -5.25,-3 -5.325,-6.3c-0.15,-3.3 1.2,-6.3 4.8,-6.45c2.775,-0.075 3.9,1.2 4.425,2.925l2.625,-0.075c-0.45,-2.625 -2.55,-4.875 -7.05,-4.725c-5.4,0.225 -7.725,4.125 -7.575,8.4c0.15,4.725 2.4,8.25 8.1,8.025c4.575,-0.15 6.45,-2.625 6.9,-5.25l-2.625,0.075c-0.45,1.8 -1.5,3.3 -4.275,3.375Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M198.975,234.3c-0.525,-2.1 -1.65,-3.15 -3.675,-3.15c1.35,-0.825 2.625,-2.175 2.025,-4.425c-0.675,-2.625 -3.375,-3.45 -6.675,-2.55l-6.675,1.725l3.975,15.45l2.55,-0.675l-1.8,-6.9l3.075,-0.825c2.925,-0.75 4.05,-0.15 4.575,1.95l0.075,0.3c0.45,1.65 0.825,3 1.275,3.6l2.55,-0.675c-0.45,-0.825 -0.825,-2.175 -1.2,-3.6l-0.075,-0.225Zm-7.425,-3.15l-3.3,0.825l-1.275,-5.025l3.825,-0.975c2.1,-0.525 3.6,-0.075 3.975,1.5c0.525,2.175 -0.975,3.15 -3.225,3.675Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M208.708,217.966l-2.391,1.086l6.608,14.545l2.39,-1.086l-6.607,-14.545Z" style="fill:#b4ac8f;"/><path d="M223.95,208.725l-5.4,3.675l9,13.2l2.175,-1.5l-3.825,-5.55l2.925,-2.025c3.225,-2.175 4.575,-5.025 2.775,-7.65c-1.575,-2.4 -4.725,-2.175 -7.65,-0.15Zm3.825,6.375l-2.775,1.95l-3.15,-4.65l2.85,-1.95c1.95,-1.35 3.75,-1.5 4.8,-0c1.2,1.8 0.225,3.3 -1.725,4.65Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M246.15,191.325l-1.425,-1.35l-9.45,9.9l1.425,1.275l3.75,-3.975l10.2,9.75l1.875,-1.95l-10.2,-9.675l3.825,-3.975Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M182.1,1.425c-1.575,-0.225 -3.15,-0.45 -4.725,-0.675l-0,11.175c16.8,18.15 27.675,41.925 29.25,68.175l-103.65,-0c0,-0 -10.5,0.525 -10.5,9.225c0,9.075 8.325,10.575 10.425,10.575l52.05,0c0,0 6.525,-0.375 6.525,4.575c0,4.725 -4.8,4.5 -6.45,4.5l-106.125,0c8.25,-55.725 51.9,-99.9 107.325,-108.975c-59.775,3.15 -108.15,49.875 -113.925,108.975l-30.825,0c-0,0 -11.475,-1.35 -11.475,8.625c-0,9.975 8.625,9.6 11.025,9.6l30.825,0c1.125,21.225 7.8,41.1 18.525,58.05l0.075,-0.075c-6.6,-13.425 -10.875,-28.2 -12.45,-43.8l56.475,0c2.7,0 10.275,-0.375 10.275,-9.15c-0,-8.7 -9.3,-8.925 -9.3,-8.925l-76.35,0c-0,0 -6.675,0.525 -6.675,-4.8c-0,-5.325 4.35,-5.55 6.3,-5.55l142.875,0c0,0 10.95,1.2 10.95,-8.925c-0,-9 -9.6,-8.625 -13.125,-8.625l-48.825,0c0,0 -7.275,0.3 -7.275,-5.175c0,-5.475 6.15,-5.175 7.2,-5.175l86.025,0l-0,1.65c-0,28.875 -11.175,55.2 -29.475,74.85c-16.2,17.475 -38.025,29.7 -62.625,33.825c4.725,2.925 9.675,5.475 14.85,7.65c17.925,-5.1 34.2,-14.25 47.7,-26.4c11.025,-9.9 20.25,-21.9 27.075,-35.25l53.325,0l0,-5.025l-50.925,0c6.825,-15.15 10.65,-31.95 10.65,-49.65l0,-1.65l49.425,0c3.825,11.175 5.925,23.1 5.925,35.55c0,20.625 -5.7,39.975 -15.675,56.55l8.4,6.825c11.4,-18.45 18,-40.125 18,-63.375c0.3,-59.925 -43.65,-109.875 -101.1,-119.175Zm-87.975,131.325c0,4.875 -4.725,5.175 -4.725,5.175l-41.55,-0c-0.225,-3.225 -0.375,-6.45 -0.375,-9.675l0,-1.05l42.375,-0c0.75,0.075 4.275,0.675 4.275,5.55Zm123.225,-52.65c-1.35,-24.3 -9.825,-46.65 -23.475,-65.025c32.475,9.6 58.8,33.825 71.25,65.025l-47.775,-0Z" style="fill:#b4ac8f;fill-rule:nonzero;"/></g></svg> \ No newline at end of file | <?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 300 258" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;"><g><path d="M96.8,205.15c-2.775,0.6 -6.075,1.2 -8.775,1.725c0.375,-1.5 1.425,-5.85 2.175,-8.625l-2.1,-2.175l-2.475,10.875c0,0.15 -0.075,0.3 -0.225,0.45l-4.5,4.275l1.8,1.95l4.575,-4.35c0.15,-0.15 0.225,-0.225 0.375,-0.225l11.025,-1.875l-1.875,-2.025Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M108.5,227.05c-1.425,2.025 -3.15,2.925 -5.85,1.125c-2.7,-1.875 -2.55,-3.9 -1.2,-5.85l5.775,-8.4l-2.175,-1.5l-5.85,8.55c-2.1,3 -1.725,5.925 2.4,8.775c4.425,3 7.275,1.8 9.15,-0.975l5.775,-8.475l-2.25,-1.5l-5.775,8.25Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M120.275,240.1l10.8,4.275l1.05,-1.575l-8.7,-3.525l2.025,-5.1l7.95,3.15l0.675,-1.8l-7.875,-3.15l1.8,-4.425l8.25,3.3l0.675,-1.725l-10.65,-4.275l-6,14.85Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M152.15,232.975c-3.525,-0.6 -6.15,0.6 -6.6,3.15c-0.375,2.25 0.9,3.675 4.725,5.4c3,1.35 3.9,2.25 3.6,3.975c-0.3,1.65 -1.8,2.325 -4.05,1.95c-2.175,-0.375 -3.525,-1.65 -3.6,-3.6l-2.625,-0.45c-0.225,2.925 1.8,5.1 5.7,5.85c4.275,0.75 6.75,-0.825 7.2,-3.45c0.375,-2.175 -0.525,-3.9 -4.95,-5.925c-2.775,-1.275 -3.675,-1.95 -3.45,-3.375c0.225,-1.35 1.425,-2.025 3.525,-1.65c2.25,0.375 3.075,1.575 3.075,3.15l2.55,0.45c0.45,-2.475 -0.975,-4.725 -5.1,-5.475Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M175.925,249.1c-3.9,0.15 -5.25,-3 -5.325,-6.3c-0.15,-3.3 1.2,-6.3 4.8,-6.45c2.775,-0.075 3.9,1.2 4.425,2.925l2.625,-0.075c-0.45,-2.625 -2.55,-4.875 -7.05,-4.725c-5.4,0.225 -7.725,4.125 -7.575,8.4c0.15,4.725 2.4,8.25 8.1,8.025c4.575,-0.15 6.45,-2.625 6.9,-5.25l-2.625,0.075c-0.45,1.8 -1.5,3.3 -4.275,3.375Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M206.975,241.3c-0.525,-2.1 -1.65,-3.15 -3.675,-3.15c1.35,-0.825 2.625,-2.175 2.025,-4.425c-0.675,-2.625 -3.375,-3.45 -6.675,-2.55l-6.675,1.725l3.975,15.45l2.55,-0.675l-1.8,-6.9l3.075,-0.825c2.925,-0.75 4.05,-0.15 4.575,1.95l0.075,0.3c0.45,1.65 0.825,3 1.275,3.6l2.55,-0.675c-0.45,-0.825 -0.825,-2.175 -1.2,-3.6l-0.075,-0.225Zm-7.425,-3.15l-3.3,0.825l-1.275,-5.025l3.825,-0.975c2.1,-0.525 3.6,-0.075 3.975,1.5c0.525,2.175 -0.975,3.15 -3.225,3.675Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M216.708,224.966l-2.391,1.086l6.608,14.545l2.39,-1.086l-6.607,-14.545Z" style="fill:#b4ac8f;"/><path d="M231.95,215.725l-5.4,3.675l9,13.2l2.175,-1.5l-3.825,-5.55l2.925,-2.025c3.225,-2.175 4.575,-5.025 2.775,-7.65c-1.575,-2.4 -4.725,-2.175 -7.65,-0.15Zm3.825,6.375l-2.775,1.95l-3.15,-4.65l2.85,-1.95c1.95,-1.35 3.75,-1.5 4.8,0c1.2,1.8 0.225,3.3 -1.725,4.65Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M254.15,198.325l-1.425,-1.35l-9.45,9.9l1.425,1.275l3.75,-3.975l10.2,9.75l1.875,-1.95l-10.2,-9.675l3.825,-3.975Z" style="fill:#b4ac8f;fill-rule:nonzero;"/><path d="M190.1,8.425c-1.575,-0.225 -3.15,-0.45 -4.725,-0.675l0,11.175c16.8,18.15 27.675,41.925 29.25,68.175l-103.65,0c0,0 -10.5,0.525 -10.5,9.225c0,9.075 8.325,10.575 10.425,10.575l52.05,0c0,0 6.525,-0.375 6.525,4.575c0,4.725 -4.8,4.5 -6.45,4.5l-106.125,0c8.25,-55.725 51.9,-99.9 107.325,-108.975c-59.775,3.15 -108.15,49.875 -113.925,108.975l-30.825,0c0,0 -11.475,-1.35 -11.475,8.625c0,9.975 8.625,9.6 11.025,9.6l30.825,0c1.125,21.225 7.8,41.1 18.525,58.05l0.075,-0.075c-6.6,-13.425 -10.875,-28.2 -12.45,-43.8l56.475,0c2.7,0 10.275,-0.375 10.275,-9.15c0,-8.7 -9.3,-8.925 -9.3,-8.925l-76.35,0c0,0 -6.675,0.525 -6.675,-4.8c0,-5.325 4.35,-5.55 6.3,-5.55l142.875,0c0,0 10.95,1.2 10.95,-8.925c0,-9 -9.6,-8.625 -13.125,-8.625l-48.825,0c0,0 -7.275,0.3 -7.275,-5.175c-0,-5.475 6.15,-5.175 7.2,-5.175l86.025,0l0,1.65c0,28.875 -11.175,55.2 -29.475,74.85c-16.2,17.475 -38.025,29.7 -62.625,33.825c4.725,2.925 9.675,5.475 14.85,7.65c17.925,-5.1 34.2,-14.25 47.7,-26.4c11.025,-9.9 20.25,-21.9 27.075,-35.25l53.325,0l0,-5.025l-50.925,0c6.825,-15.15 10.65,-31.95 10.65,-49.65l0,-1.65l49.425,0c3.825,11.175 5.925,23.1 5.925,35.55c0,20.625 -5.7,39.975 -15.675,56.55l8.4,6.825c11.4,-18.45 18,-40.125 18,-63.375c0.3,-59.925 -43.65,-109.875 -101.1,-119.175Zm-87.975,131.325c0,4.875 -4.725,5.175 -4.725,5.175l-41.55,0c-0.225,-3.225 -0.375,-6.45 -0.375,-9.675l0,-1.05l42.375,0c0.75,0.075 4.275,0.675 4.275,5.55Zm123.225,-52.65c-1.35,-24.3 -9.825,-46.65 -23.475,-65.025c32.475,9.6 58.8,33.825 71.25,65.025l-47.775,0Z" style="fill:#b4ac8f;fill-rule:nonzero;"/></g></svg> \ No newline at end of file | ||
diff --git a/doc/docs/.vitepress/theme/components/YueCompiler.vue b/doc/docs/.vitepress/theme/components/YueCompiler.vue index 28a6a9f..dcea692 100755 --- a/doc/docs/.vitepress/theme/components/YueCompiler.vue +++ b/doc/docs/.vitepress/theme/components/YueCompiler.vue | |||
| @@ -39,24 +39,25 @@ import { history, indentWithTab } from '@codemirror/commands' | |||
| 39 | import { defaultKeymap, historyKeymap } from '@codemirror/commands' | 39 | import { defaultKeymap, historyKeymap } from '@codemirror/commands' |
| 40 | import { simpleMode } from '@codemirror/legacy-modes/mode/simple-mode' | 40 | import { simpleMode } from '@codemirror/legacy-modes/mode/simple-mode' |
| 41 | 41 | ||
| 42 | const vscodeLightTheme = EditorView.theme( | 42 | /* shikijs/themes/light-plus: editor.background #FFFFFF, editor.foreground #000000 */ |
| 43 | const lightPlusTheme = EditorView.theme( | ||
| 43 | { | 44 | { |
| 44 | '&': { | 45 | '&': { |
| 45 | height: '100%', | 46 | height: '100%', |
| 46 | backgroundColor: '#ffffff', | 47 | backgroundColor: '#FFFFFF', |
| 47 | color: '#000000', | 48 | color: '#000000', |
| 48 | fontSize: '15px' | 49 | fontSize: '0.8em' |
| 49 | }, | 50 | }, |
| 50 | '&.cm-focused': { | 51 | '&.cm-focused': { |
| 51 | outline: 'none' | 52 | outline: 'none' |
| 52 | }, | 53 | }, |
| 53 | '.cm-content': { | 54 | '.cm-content': { |
| 54 | fontFamily: | 55 | fontFamily: |
| 55 | "Consolas, Menlo, Monaco, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Liberation Mono', 'Nimbus Mono L', 'Courier New', Courier, monospace", | 56 | "ui-monospace, 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace", |
| 56 | lineHeight: '1.375' | 57 | lineHeight: '1.375' |
| 57 | }, | 58 | }, |
| 58 | '.cm-gutters': { | 59 | '.cm-gutters': { |
| 59 | backgroundColor: '#ffffff', | 60 | backgroundColor: '#FFFFFF', |
| 60 | color: '#6e6e6e', | 61 | color: '#6e6e6e', |
| 61 | borderRight: 'none' | 62 | borderRight: 'none' |
| 62 | }, | 63 | }, |
| @@ -82,24 +83,25 @@ const vscodeLightTheme = EditorView.theme( | |||
| 82 | { dark: false } | 83 | { dark: false } |
| 83 | ) | 84 | ) |
| 84 | 85 | ||
| 85 | const vscodeDarkTheme = EditorView.theme( | 86 | /* shikijs/themes/dark-plus: editor.background #1E1E1E, editor.foreground #D4D4D4 */ |
| 87 | const darkPlusTheme = EditorView.theme( | ||
| 86 | { | 88 | { |
| 87 | '&': { | 89 | '&': { |
| 88 | height: '100%', | 90 | height: '100%', |
| 89 | backgroundColor: '#1e1e1e', | 91 | backgroundColor: '#1E1E1E', |
| 90 | color: '#d4d4d4', | 92 | color: '#D4D4D4', |
| 91 | fontSize: '15px' | 93 | fontSize: '0.8em' |
| 92 | }, | 94 | }, |
| 93 | '&.cm-focused': { | 95 | '&.cm-focused': { |
| 94 | outline: 'none' | 96 | outline: 'none' |
| 95 | }, | 97 | }, |
| 96 | '.cm-content': { | 98 | '.cm-content': { |
| 97 | fontFamily: | 99 | fontFamily: |
| 98 | "Consolas, Menlo, Monaco, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Liberation Mono', 'Nimbus Mono L', 'Courier New', Courier, monospace", | 100 | "ui-monospace, 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace", |
| 99 | lineHeight: '1.375' | 101 | lineHeight: '1.375' |
| 100 | }, | 102 | }, |
| 101 | '.cm-gutters': { | 103 | '.cm-gutters': { |
| 102 | backgroundColor: '#1e1e1e', | 104 | backgroundColor: '#1E1E1E', |
| 103 | color: '#858585', | 105 | color: '#858585', |
| 104 | borderRight: 'none' | 106 | borderRight: 'none' |
| 105 | }, | 107 | }, |
| @@ -125,16 +127,17 @@ const vscodeDarkTheme = EditorView.theme( | |||
| 125 | { dark: true } | 127 | { dark: true } |
| 126 | ) | 128 | ) |
| 127 | 129 | ||
| 128 | const vscodeLightHighlightStyle = HighlightStyle.define([ | 130 | /* shikijs/themes/light-plus tokenColors */ |
| 131 | const lightPlusHighlightStyle = HighlightStyle.define([ | ||
| 129 | { tag: tags.comment, color: '#008000' }, | 132 | { tag: tags.comment, color: '#008000' }, |
| 130 | { tag: tags.keyword, color: '#0000ff' }, | 133 | { tag: tags.keyword, color: '#AF00DB' }, |
| 131 | { tag: [tags.operator, tags.punctuation], color: '#000000' }, | 134 | { tag: [tags.operator, tags.punctuation], color: '#000000' }, |
| 132 | { tag: [tags.string, tags.special(tags.string)], color: '#a31515' }, | 135 | { tag: [tags.string, tags.special(tags.string)], color: '#a31515' }, |
| 136 | { tag: tags.regexp, color: '#811f3f' }, | ||
| 133 | { tag: [tags.number, tags.bool, tags.null], color: '#098658' }, | 137 | { tag: [tags.number, tags.bool, tags.null], color: '#098658' }, |
| 134 | { tag: tags.function(tags.variableName), color: '#795e26' }, | 138 | { tag: tags.function(tags.variableName), color: '#795e26' }, |
| 135 | { tag: tags.typeName, color: '#267f99' }, | 139 | { tag: tags.typeName, color: '#267f99' }, |
| 136 | { tag: tags.className, color: '#267f99' }, | 140 | { tag: tags.className, color: '#267f99' }, |
| 137 | { tag: tags.variableName, color: '#001080' }, | ||
| 138 | { tag: tags.propertyName, color: '#001080' }, | 141 | { tag: tags.propertyName, color: '#001080' }, |
| 139 | { tag: tags.tagName, color: '#800000' }, | 142 | { tag: tags.tagName, color: '#800000' }, |
| 140 | { tag: tags.attributeName, color: '#e50000' }, | 143 | { tag: tags.attributeName, color: '#e50000' }, |
| @@ -142,16 +145,17 @@ const vscodeLightHighlightStyle = HighlightStyle.define([ | |||
| 142 | { tag: tags.invalid, color: '#cd3131' } | 145 | { tag: tags.invalid, color: '#cd3131' } |
| 143 | ]) | 146 | ]) |
| 144 | 147 | ||
| 145 | const vscodeDarkHighlightStyle = HighlightStyle.define([ | 148 | /* shikijs/themes/dark-plus tokenColors */ |
| 149 | const darkPlusHighlightStyle = HighlightStyle.define([ | ||
| 146 | { tag: tags.comment, color: '#6a9955' }, | 150 | { tag: tags.comment, color: '#6a9955' }, |
| 147 | { tag: tags.keyword, color: '#569cd6' }, | 151 | { tag: tags.keyword, color: '#C586C0' }, |
| 148 | { tag: [tags.operator, tags.punctuation], color: '#d4d4d4' }, | 152 | { tag: [tags.operator, tags.punctuation], color: '#d4d4d4' }, |
| 149 | { tag: [tags.string, tags.special(tags.string)], color: '#ce9178' }, | 153 | { tag: [tags.string, tags.special(tags.string)], color: '#ce9178' }, |
| 154 | { tag: tags.regexp, color: '#d16969' }, | ||
| 150 | { tag: [tags.number, tags.bool, tags.null], color: '#b5cea8' }, | 155 | { tag: [tags.number, tags.bool, tags.null], color: '#b5cea8' }, |
| 151 | { tag: tags.function(tags.variableName), color: '#dcdcaa' }, | 156 | { tag: tags.function(tags.variableName), color: '#dcdcaa' }, |
| 152 | { tag: tags.typeName, color: '#4ec9b0' }, | 157 | { tag: tags.typeName, color: '#4ec9b0' }, |
| 153 | { tag: tags.className, color: '#4ec9b0' }, | 158 | { tag: tags.className, color: '#4ec9b0' }, |
| 154 | { tag: tags.variableName, color: '#9cdcfe' }, | ||
| 155 | { tag: tags.propertyName, color: '#9cdcfe' }, | 159 | { tag: tags.propertyName, color: '#9cdcfe' }, |
| 156 | { tag: tags.tagName, color: '#569cd6' }, | 160 | { tag: tags.tagName, color: '#569cd6' }, |
| 157 | { tag: tags.attributeName, color: '#9cdcfe' }, | 161 | { tag: tags.attributeName, color: '#9cdcfe' }, |
| @@ -328,12 +332,12 @@ export default { | |||
| 328 | this.readOnlyCompartment.of(EditorState.readOnly.of(this.readonly)), | 332 | this.readOnlyCompartment.of(EditorState.readOnly.of(this.readonly)), |
| 329 | this.highlightCompartment.of( | 333 | this.highlightCompartment.of( |
| 330 | syntaxHighlighting( | 334 | syntaxHighlighting( |
| 331 | isDark ? vscodeDarkHighlightStyle : vscodeLightHighlightStyle, | 335 | isDark ? darkPlusHighlightStyle : lightPlusHighlightStyle, |
| 332 | { fallback: true } | 336 | { fallback: true } |
| 333 | ) | 337 | ) |
| 334 | ), | 338 | ), |
| 335 | updateListener, | 339 | updateListener, |
| 336 | this.themeCompartment.of(isDark ? vscodeDarkTheme : vscodeLightTheme) | 340 | this.themeCompartment.of(isDark ? darkPlusTheme : lightPlusTheme) |
| 337 | ] | 341 | ] |
| 338 | }) | 342 | }) |
| 339 | 343 | ||
| @@ -350,11 +354,11 @@ export default { | |||
| 350 | this.editorView.dispatch({ | 354 | this.editorView.dispatch({ |
| 351 | effects: [ | 355 | effects: [ |
| 352 | this.themeCompartment.reconfigure( | 356 | this.themeCompartment.reconfigure( |
| 353 | isDark ? vscodeDarkTheme : vscodeLightTheme | 357 | isDark ? darkPlusTheme : lightPlusTheme |
| 354 | ), | 358 | ), |
| 355 | this.highlightCompartment.reconfigure( | 359 | this.highlightCompartment.reconfigure( |
| 356 | syntaxHighlighting( | 360 | syntaxHighlighting( |
| 357 | isDark ? vscodeDarkHighlightStyle : vscodeLightHighlightStyle, | 361 | isDark ? darkPlusHighlightStyle : lightPlusHighlightStyle, |
| 358 | { fallback: true } | 362 | { fallback: true } |
| 359 | ) | 363 | ) |
| 360 | ) | 364 | ) |
diff --git a/doc/docs/.vitepress/theme/custom.css b/doc/docs/.vitepress/theme/custom.css index 9085b4b..7b4e593 100644 --- a/doc/docs/.vitepress/theme/custom.css +++ b/doc/docs/.vitepress/theme/custom.css | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | max-width: 450px !important; | 14 | max-width: 450px !important; |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | /* Prism theme for YueCompiler output (VS Code Light/Dark) */ | 17 | /* Prism theme for YueCompiler output (shikijs/themes light-plus & dark-plus) */ |
| 18 | .code-output, | 18 | .code-output, |
| 19 | .code-output code { | 19 | .code-output code { |
| 20 | background: #ffffff; | 20 | background: #ffffff; |
| @@ -27,12 +27,13 @@ | |||
| 27 | color: #d4d4d4; | 27 | color: #d4d4d4; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | /* light-plus */ | ||
| 30 | .code-output .token.comment { | 31 | .code-output .token.comment { |
| 31 | color: #008000; | 32 | color: #008000; |
| 32 | } | 33 | } |
| 33 | 34 | ||
| 34 | .code-output .token.keyword { | 35 | .code-output .token.keyword { |
| 35 | color: #0000ff; | 36 | color: #AF00DB; |
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | .code-output .token.operator, | 39 | .code-output .token.operator, |
| @@ -41,12 +42,19 @@ | |||
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | .code-output .token.string, | 44 | .code-output .token.string, |
| 44 | .code-output .token.char, | 45 | .code-output .token.char { |
| 45 | .code-output .token.regex, | ||
| 46 | .code-output .token.variable { | ||
| 47 | color: #a31515; | 46 | color: #a31515; |
| 48 | } | 47 | } |
| 49 | 48 | ||
| 49 | .code-output .token.regex { | ||
| 50 | color: #811f3f; | ||
| 51 | } | ||
| 52 | |||
| 53 | .code-output .token.variable, | ||
| 54 | .code-output .token.parameter { | ||
| 55 | color: #001080; | ||
| 56 | } | ||
| 57 | |||
| 50 | .code-output .token.number, | 58 | .code-output .token.number, |
| 51 | .code-output .token.boolean, | 59 | .code-output .token.boolean, |
| 52 | .code-output .token.constant { | 60 | .code-output .token.constant { |
| @@ -62,12 +70,17 @@ | |||
| 62 | color: #267f99; | 70 | color: #267f99; |
| 63 | } | 71 | } |
| 64 | 72 | ||
| 73 | .code-output .token.invalid { | ||
| 74 | color: #cd3131; | ||
| 75 | } | ||
| 76 | |||
| 77 | /* dark-plus */ | ||
| 65 | .dark .code-output .token.comment { | 78 | .dark .code-output .token.comment { |
| 66 | color: #6a9955; | 79 | color: #6a9955; |
| 67 | } | 80 | } |
| 68 | 81 | ||
| 69 | .dark .code-output .token.keyword { | 82 | .dark .code-output .token.keyword { |
| 70 | color: #569cd6; | 83 | color: #C586C0; |
| 71 | } | 84 | } |
| 72 | 85 | ||
| 73 | .dark .code-output .token.operator, | 86 | .dark .code-output .token.operator, |
| @@ -76,12 +89,19 @@ | |||
| 76 | } | 89 | } |
| 77 | 90 | ||
| 78 | .dark .code-output .token.string, | 91 | .dark .code-output .token.string, |
| 79 | .dark .code-output .token.char, | 92 | .dark .code-output .token.char { |
| 80 | .dark .code-output .token.regex, | ||
| 81 | .dark .code-output .token.variable { | ||
| 82 | color: #ce9178; | 93 | color: #ce9178; |
| 83 | } | 94 | } |
| 84 | 95 | ||
| 96 | .dark .code-output .token.regex { | ||
| 97 | color: #d16969; | ||
| 98 | } | ||
| 99 | |||
| 100 | .dark .code-output .token.variable, | ||
| 101 | .dark .code-output .token.parameter { | ||
| 102 | color: #9cdcfe; | ||
| 103 | } | ||
| 104 | |||
| 85 | .dark .code-output .token.number, | 105 | .dark .code-output .token.number, |
| 86 | .dark .code-output .token.boolean, | 106 | .dark .code-output .token.boolean, |
| 87 | .dark .code-output .token.constant { | 107 | .dark .code-output .token.constant { |
| @@ -96,3 +116,7 @@ | |||
| 96 | .dark .code-output .token.builtin { | 116 | .dark .code-output .token.builtin { |
| 97 | color: #4ec9b0; | 117 | color: #4ec9b0; |
| 98 | } | 118 | } |
| 119 | |||
| 120 | .dark .code-output .token.invalid { | ||
| 121 | color: #f44747; | ||
| 122 | } | ||
diff --git a/doc/docs/.vitepress/theme/index.ts b/doc/docs/.vitepress/theme/index.ts index e2a44c6..398df17 100644 --- a/doc/docs/.vitepress/theme/index.ts +++ b/doc/docs/.vitepress/theme/index.ts | |||
| @@ -2,8 +2,11 @@ import DefaultTheme from 'vitepress/theme' | |||
| 2 | import type { Theme } from 'vitepress' | 2 | import type { Theme } from 'vitepress' |
| 3 | import './custom.css' | 3 | import './custom.css' |
| 4 | 4 | ||
| 5 | // @ts-ignore | ||
| 5 | import CompilerModal from './components/CompilerModal.vue' | 6 | import CompilerModal from './components/CompilerModal.vue' |
| 7 | // @ts-ignore | ||
| 6 | import YueCompiler from './components/YueCompiler.vue' | 8 | import YueCompiler from './components/YueCompiler.vue' |
| 9 | // @ts-ignore | ||
| 7 | import YueDisplay from './components/YueDisplay.vue' | 10 | import YueDisplay from './components/YueDisplay.vue' |
| 8 | 11 | ||
| 9 | const theme: Theme = { | 12 | const theme: Theme = { |
diff --git a/doc/docs/doc/index.md b/doc/docs/doc/index.md index 6998747..6de2ce7 100755 --- a/doc/docs/doc/index.md +++ b/doc/docs/doc/index.md | |||
| @@ -2908,7 +2908,7 @@ thing = { | |||
| 2908 | width: 123 | 2908 | width: 123 |
| 2909 | } | 2909 | } |
| 2910 | 2910 | ||
| 2911 | thing_copy = \{k, v for k, v in pairs thing} | 2911 | thing_copy = {k, v for k, v in pairs thing} |
| 2912 | ``` | 2912 | ``` |
| 2913 | 2913 | ||
| 2914 | </YueDisplay> | 2914 | </YueDisplay> |
| @@ -2919,7 +2919,7 @@ no_color = {k, v for k, v in pairs thing when k != "color"} | |||
| 2919 | <YueDisplay> | 2919 | <YueDisplay> |
| 2920 | 2920 | ||
| 2921 | ```yue | 2921 | ```yue |
| 2922 | no_color = \{k, v for k, v in pairs thing when k != "color"} | 2922 | no_color = {k, v for k, v in pairs thing when k != "color"} |
| 2923 | ``` | 2923 | ``` |
| 2924 | 2924 | ||
| 2925 | </YueDisplay> | 2925 | </YueDisplay> |
| @@ -2934,7 +2934,7 @@ sqrts = {i, math.sqrt i for i in *numbers} | |||
| 2934 | 2934 | ||
| 2935 | ```yue | 2935 | ```yue |
| 2936 | numbers = [1, 2, 3, 4] | 2936 | numbers = [1, 2, 3, 4] |
| 2937 | sqrts = \{i, math.sqrt i for i in *numbers} | 2937 | sqrts = {i, math.sqrt i for i in *numbers} |
| 2938 | ``` | 2938 | ``` |
| 2939 | 2939 | ||
| 2940 | </YueDisplay> | 2940 | </YueDisplay> |
| @@ -2951,7 +2951,7 @@ tbl = {unpack tuple for tuple in *tuples} | |||
| 2951 | 2951 | ||
| 2952 | ```yue | 2952 | ```yue |
| 2953 | tuples = [ ["hello", "world"], ["foo", "bar"]] | 2953 | tuples = [ ["hello", "world"], ["foo", "bar"]] |
| 2954 | tbl = \{unpack tuple for tuple in *tuples} | 2954 | tbl = {unpack tuple for tuple in *tuples} |
| 2955 | ``` | 2955 | ``` |
| 2956 | 2956 | ||
| 2957 | </YueDisplay> | 2957 | </YueDisplay> |
| @@ -4751,7 +4751,7 @@ to_lua: function(code: string, config?: Config): | |||
| 4751 | | --- | --- | | 4751 | | --- | --- | |
| 4752 | | string \| nil | The compiled Lua code, or nil if the compilation failed. | | 4752 | | string \| nil | The compiled Lua code, or nil if the compilation failed. | |
| 4753 | | string \| nil | The error message, or nil if the compilation succeeded. | | 4753 | | string \| nil | The error message, or nil if the compilation succeeded. | |
| 4754 | | \{\{string, integer, integer}} \| nil | The global variables appearing in the code (with name, row and column), or nil if the compiler option `lint_global` is false. | | 4754 | | {{string, integer, integer}} \| nil | The global variables appearing in the code (with name, row and column), or nil if the compiler option `lint_global` is false. | |
| 4755 | 4755 | ||
| 4756 | #### file_exist | 4756 | #### file_exist |
| 4757 | 4757 | ||
diff --git a/doc/docs/index.md b/doc/docs/index.md index a8c43d2..0ce1284 100644 --- a/doc/docs/index.md +++ b/doc/docs/index.md | |||
| @@ -15,8 +15,8 @@ features: | |||
| 15 | details: Write concise syntax that compiles to readable Lua, with predictable output. | 15 | details: Write concise syntax that compiles to readable Lua, with predictable output. |
| 16 | - title: Modern language features | 16 | - title: Modern language features |
| 17 | details: Pipe, pattern matching, slicing, and destructuring without giving up Lua interop. | 17 | details: Pipe, pattern matching, slicing, and destructuring without giving up Lua interop. |
| 18 | - title: Tooling built in | 18 | - title: Rapid Iteration |
| 19 | details: Browser-based playground, syntax highlighting, and docs that stay in sync. | 19 | details: Any feedback is welcome to help accelerate the language development and evolution! |
| 20 | footer: MIT Licensed | Copyright © 2017-2026 Li Jin | 20 | footer: MIT Licensed | Copyright © 2017-2026 Li Jin |
| 21 | --- | 21 | --- |
| 22 | 22 | ||
diff --git a/doc/docs/zh/doc/index.md b/doc/docs/zh/doc/index.md index dff51a9..5250325 100755 --- a/doc/docs/zh/doc/index.md +++ b/doc/docs/zh/doc/index.md | |||
| @@ -2858,7 +2858,7 @@ thing = { | |||
| 2858 | width: 123 | 2858 | width: 123 |
| 2859 | } | 2859 | } |
| 2860 | 2860 | ||
| 2861 | thing_copy = \{k, v for k, v in pairs thing} | 2861 | thing_copy = {k, v for k, v in pairs thing} |
| 2862 | ``` | 2862 | ``` |
| 2863 | 2863 | ||
| 2864 | </YueDisplay> | 2864 | </YueDisplay> |
| @@ -2869,7 +2869,7 @@ no_color = {k, v for k, v in pairs thing when k != "color"} | |||
| 2869 | <YueDisplay> | 2869 | <YueDisplay> |
| 2870 | 2870 | ||
| 2871 | ```yue | 2871 | ```yue |
| 2872 | no_color = \{k, v for k, v in pairs thing when k != "color"} | 2872 | no_color = {k, v for k, v in pairs thing when k != "color"} |
| 2873 | ``` | 2873 | ``` |
| 2874 | 2874 | ||
| 2875 | </YueDisplay> | 2875 | </YueDisplay> |
| @@ -2884,7 +2884,7 @@ sqrts = {i, math.sqrt i for i in *numbers} | |||
| 2884 | 2884 | ||
| 2885 | ```yue | 2885 | ```yue |
| 2886 | numbers = [1, 2, 3, 4] | 2886 | numbers = [1, 2, 3, 4] |
| 2887 | sqrts = \{i, math.sqrt i for i in *numbers} | 2887 | sqrts = {i, math.sqrt i for i in *numbers} |
| 2888 | ``` | 2888 | ``` |
| 2889 | 2889 | ||
| 2890 | </YueDisplay> | 2890 | </YueDisplay> |
| @@ -2901,7 +2901,7 @@ tbl = {unpack tuple for tuple in *tuples} | |||
| 2901 | 2901 | ||
| 2902 | ```yue | 2902 | ```yue |
| 2903 | tuples = [ ["hello", "world"], ["foo", "bar"]] | 2903 | tuples = [ ["hello", "world"], ["foo", "bar"]] |
| 2904 | tbl = \{unpack tuple for tuple in *tuples} | 2904 | tbl = {unpack tuple for tuple in *tuples} |
| 2905 | ``` | 2905 | ``` |
| 2906 | 2906 | ||
| 2907 | </YueDisplay> | 2907 | </YueDisplay> |
| @@ -3588,7 +3588,7 @@ switch item | |||
| 3588 | <YueDisplay> | 3588 | <YueDisplay> |
| 3589 | 3589 | ||
| 3590 | ```yue | 3590 | ```yue |
| 3591 | item = \{} | 3591 | item = {} |
| 3592 | 3592 | ||
| 3593 | {pos: {:x = 50, :y = 200}} = item -- 获取错误:尝试索引nil值(字段'pos') | 3593 | {pos: {:x = 50, :y = 200}} = item -- 获取错误:尝试索引nil值(字段'pos') |
| 3594 | 3594 | ||
| @@ -3748,7 +3748,7 @@ class Inventory | |||
| 3748 | ```yue | 3748 | ```yue |
| 3749 | class Inventory | 3749 | class Inventory |
| 3750 | new: => | 3750 | new: => |
| 3751 | @items = \{} | 3751 | @items = {} |
| 3752 | 3752 | ||
| 3753 | add_item: (name) => | 3753 | add_item: (name) => |
| 3754 | if @items[name] | 3754 | if @items[name] |
| @@ -4463,7 +4463,7 @@ tbl = { | |||
| 4463 | <YueDisplay> | 4463 | <YueDisplay> |
| 4464 | 4464 | ||
| 4465 | ```yue | 4465 | ```yue |
| 4466 | tbl = \{ | 4466 | tbl = { |
| 4467 | key: do | 4467 | key: do |
| 4468 | print "分配键值!" | 4468 | print "分配键值!" |
| 4469 | 1234 | 4469 | 1234 |
| @@ -4501,7 +4501,7 @@ run_callback my_object\write | |||
| 4501 | <YueDisplay> | 4501 | <YueDisplay> |
| 4502 | 4502 | ||
| 4503 | ```yue | 4503 | ```yue |
| 4504 | my_object = \{ | 4504 | my_object = { |
| 4505 | value: 1000 | 4505 | value: 1000 |
| 4506 | write: => print "值为:", @value | 4506 | write: => print "值为:", @value |
| 4507 | } | 4507 | } |
| @@ -4698,7 +4698,7 @@ to_lua: function(code: string, config?: Config): | |||
| 4698 | | --- | --- | | 4698 | | --- | --- | |
| 4699 | | string \| nil | 编译后的 Lua 代码,如果编译失败则为 nil。 | | 4699 | | string \| nil | 编译后的 Lua 代码,如果编译失败则为 nil。 | |
| 4700 | | string \| nil | 错误消息,如果编译成功则为 nil。 | | 4700 | | string \| nil | 错误消息,如果编译成功则为 nil。 | |
| 4701 | | \{\{string, integer, integer}} \| nil | 代码中出现的全局变量(带有名称、行和列),如果编译器选项 `lint_global` 为 false 则为 nil。 | | 4701 | | {{string, integer, integer}} \| nil | 代码中出现的全局变量(带有名称、行和列),如果编译器选项 `lint_global` 为 false 则为 nil。 | |
| 4702 | 4702 | ||
| 4703 | #### file_exist | 4703 | #### file_exist |
| 4704 | 4704 | ||
diff --git a/doc/docs/zh/index.md b/doc/docs/zh/index.md index 6d677e9..9068956 100644 --- a/doc/docs/zh/index.md +++ b/doc/docs/zh/index.md | |||
| @@ -15,8 +15,8 @@ features: | |||
| 15 | details: 更精简的语法,编译为可读 Lua,输出可预测、易集成。 | 15 | details: 更精简的语法,编译为可读 Lua,输出可预测、易集成。 |
| 16 | - title: 现代语言特性 | 16 | - title: 现代语言特性 |
| 17 | details: 管道、模式匹配、切片与解构,同时保留 Lua 互操作性。 | 17 | details: 管道、模式匹配、切片与解构,同时保留 Lua 互操作性。 |
| 18 | - title: 置工具 | 18 | - title: 迭代 |
| 19 | details: Playground、语高亮新的文档 | 19 | details: 虚用反馈,帮助和加速语言的发和演进! |
| 20 | footer: MIT Licensed | Copyright © 2017-2026 Li Jin | 20 | footer: MIT Licensed | Copyright © 2017-2026 Li Jin |
| 21 | --- | 21 | --- |
| 22 | 22 | ||
diff --git a/spec/inputs/compile_doc.yue b/spec/inputs/compile_doc.yue index c189c17..db0464b 100644 --- a/spec/inputs/compile_doc.yue +++ b/spec/inputs/compile_doc.yue | |||
| @@ -7,13 +7,13 @@ for [compiledFile, docFile] in *[ | |||
| 7 | import "yue" as :to_lua | 7 | import "yue" as :to_lua |
| 8 | text = \read "*a" | 8 | text = \read "*a" |
| 9 | codes = [] | 9 | codes = [] |
| 10 | for code in text\gmatch "```moonscript(.-)```" | 10 | for code in text\gmatch "```yuescript[\r\n]+(.-)```[^%w]" |
| 11 | if result, err := to_lua code, implicit_return_root: false, reserve_line_number: false | 11 | if result, err := to_lua code, implicit_return_root: false, reserve_line_number: false |
| 12 | codes[] = result | 12 | codes[] = result |
| 13 | elseif not err\match "macro exporting module only accepts macro definition" | 13 | elseif not err\match "macro exporting module only accepts macro definition" |
| 14 | print err | 14 | print err |
| 15 | os.exit 1 | 15 | os.exit 1 |
| 16 | for code in text\gmatch "```yue(.-)```" | 16 | for code in text\gmatch "```yue[\r\n]+(.-)```[^%w]" |
| 17 | if result, err := to_lua code, implicit_return_root: false, reserve_line_number: false | 17 | if result, err := to_lua code, implicit_return_root: false, reserve_line_number: false |
| 18 | codes[] = result | 18 | codes[] = result |
| 19 | else | 19 | else |
diff --git a/spec/outputs/codes_from_doc.lua b/spec/outputs/codes_from_doc.lua index 3b0724a..b8985e7 100644 --- a/spec/outputs/codes_from_doc.lua +++ b/spec/outputs/codes_from_doc.lua | |||
| @@ -107,7 +107,7 @@ if cond then | |||
| 107 | end | 107 | end |
| 108 | end | 108 | end |
| 109 | print("yuescript") | 109 | print("yuescript") |
| 110 | print(3) | 110 | print(2) |
| 111 | print("Valid enum type:", "Static") | 111 | print("Valid enum type:", "Static") |
| 112 | do | 112 | do |
| 113 | print(123, "hello") | 113 | print(123, "hello") |
| @@ -992,6 +992,36 @@ local arg1 = { | |||
| 992 | a = 0 | 992 | a = 0 |
| 993 | } | 993 | } |
| 994 | f2(arg1, arg2) | 994 | f2(arg1, arg2) |
| 995 | local findFirstEven | ||
| 996 | findFirstEven = function(list) | ||
| 997 | for _index_0 = 1, #list do | ||
| 998 | local item = list[_index_0] | ||
| 999 | if type(item) == "table" then | ||
| 1000 | for _index_1 = 1, #item do | ||
| 1001 | local sub = item[_index_1] | ||
| 1002 | if sub % 2 == 0 then | ||
| 1003 | return sub | ||
| 1004 | end | ||
| 1005 | end | ||
| 1006 | end | ||
| 1007 | end | ||
| 1008 | return nil | ||
| 1009 | end | ||
| 1010 | local findFirstEven | ||
| 1011 | findFirstEven = function(list) | ||
| 1012 | for _index_0 = 1, #list do | ||
| 1013 | local item = list[_index_0] | ||
| 1014 | if type(item) == "table" then | ||
| 1015 | for _index_1 = 1, #item do | ||
| 1016 | local sub = item[_index_1] | ||
| 1017 | if sub % 2 == 0 then | ||
| 1018 | return sub | ||
| 1019 | end | ||
| 1020 | end | ||
| 1021 | end | ||
| 1022 | end | ||
| 1023 | return nil | ||
| 1024 | end | ||
| 995 | local f | 1025 | local f |
| 996 | f = function(...) | 1026 | f = function(...) |
| 997 | local t = { | 1027 | local t = { |
| @@ -2637,7 +2667,7 @@ if cond then | |||
| 2637 | end | 2667 | end |
| 2638 | end | 2668 | end |
| 2639 | print("yuescript") | 2669 | print("yuescript") |
| 2640 | print(3) | 2670 | print(2) |
| 2641 | print("Valid enum type:", "Static") | 2671 | print("Valid enum type:", "Static") |
| 2642 | do | 2672 | do |
| 2643 | print(123, "hello") | 2673 | print(123, "hello") |
diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua index 89335c9..2aa354e 100644 --- a/spec/outputs/codes_from_doc_zh.lua +++ b/spec/outputs/codes_from_doc_zh.lua | |||
| @@ -107,7 +107,7 @@ if cond then | |||
| 107 | end | 107 | end |
| 108 | end | 108 | end |
| 109 | print("yuescript") | 109 | print("yuescript") |
| 110 | print(3) | 110 | print(2) |
| 111 | print("有效的枚举类型:", "Static") | 111 | print("有效的枚举类型:", "Static") |
| 112 | do | 112 | do |
| 113 | print(123, "hello") | 113 | print(123, "hello") |
| @@ -986,6 +986,36 @@ local arg1 = { | |||
| 986 | a = 0 | 986 | a = 0 |
| 987 | } | 987 | } |
| 988 | f2(arg1, arg2) | 988 | f2(arg1, arg2) |
| 989 | local findFirstEven | ||
| 990 | findFirstEven = function(list) | ||
| 991 | for _index_0 = 1, #list do | ||
| 992 | local item = list[_index_0] | ||
| 993 | if type(item) == "table" then | ||
| 994 | for _index_1 = 1, #item do | ||
| 995 | local sub = item[_index_1] | ||
| 996 | if sub % 2 == 0 then | ||
| 997 | return sub | ||
| 998 | end | ||
| 999 | end | ||
| 1000 | end | ||
| 1001 | end | ||
| 1002 | return nil | ||
| 1003 | end | ||
| 1004 | local findFirstEven | ||
| 1005 | findFirstEven = function(list) | ||
| 1006 | for _index_0 = 1, #list do | ||
| 1007 | local item = list[_index_0] | ||
| 1008 | if type(item) == "table" then | ||
| 1009 | for _index_1 = 1, #item do | ||
| 1010 | local sub = item[_index_1] | ||
| 1011 | if sub % 2 == 0 then | ||
| 1012 | return sub | ||
| 1013 | end | ||
| 1014 | end | ||
| 1015 | end | ||
| 1016 | end | ||
| 1017 | return nil | ||
| 1018 | end | ||
| 989 | local f | 1019 | local f |
| 990 | f = function(...) | 1020 | f = function(...) |
| 991 | local t = { | 1021 | local t = { |
| @@ -2631,7 +2661,7 @@ if cond then | |||
| 2631 | end | 2661 | end |
| 2632 | end | 2662 | end |
| 2633 | print("yuescript") | 2663 | print("yuescript") |
| 2634 | print(3) | 2664 | print(2) |
| 2635 | print("有效的枚举类型:", "Static") | 2665 | print("有效的枚举类型:", "Static") |
| 2636 | do | 2666 | do |
| 2637 | print(123, "hello") | 2667 | print(123, "hello") |
diff --git a/spec/outputs/compile_doc.lua b/spec/outputs/compile_doc.lua index 3781fb9..e7d307d 100644 --- a/spec/outputs/compile_doc.lua +++ b/spec/outputs/compile_doc.lua | |||
| @@ -2,11 +2,11 @@ local outputFolder = ... | |||
| 2 | local _list_0 = { | 2 | local _list_0 = { |
| 3 | { | 3 | { |
| 4 | "codes_from_doc.lua", | 4 | "codes_from_doc.lua", |
| 5 | "doc/docs/doc/README.md" | 5 | "doc/docs/doc/index.md" |
| 6 | }, | 6 | }, |
| 7 | { | 7 | { |
| 8 | "codes_from_doc_zh.lua", | 8 | "codes_from_doc_zh.lua", |
| 9 | "doc/docs/zh/doc/README.md" | 9 | "doc/docs/zh/doc/index.md" |
| 10 | } | 10 | } |
| 11 | } | 11 | } |
| 12 | for _index_0 = 1, #_list_0 do | 12 | for _index_0 = 1, #_list_0 do |
| @@ -18,7 +18,7 @@ for _index_0 = 1, #_list_0 do | |||
| 18 | local to_lua = require("yue").to_lua | 18 | local to_lua = require("yue").to_lua |
| 19 | local text = _with_0:read("*a") | 19 | local text = _with_0:read("*a") |
| 20 | local codes = { } | 20 | local codes = { } |
| 21 | for code in text:gmatch("```moonscript(.-)```") do | 21 | for code in text:gmatch("```yuescript[\r\n]+(.-)```[^%w]") do |
| 22 | local result, err = to_lua(code, { | 22 | local result, err = to_lua(code, { |
| 23 | implicit_return_root = false, | 23 | implicit_return_root = false, |
| 24 | reserve_line_number = false | 24 | reserve_line_number = false |
| @@ -30,8 +30,8 @@ for _index_0 = 1, #_list_0 do | |||
| 30 | os.exit(1) | 30 | os.exit(1) |
| 31 | end | 31 | end |
| 32 | end | 32 | end |
| 33 | for code in text:gmatch("<pre>(.-)</pre>") do | 33 | for code in text:gmatch("```yue[\r\n]+(.-)```[^%w]") do |
| 34 | local result, err = to_lua(code:gsub("<", "<"):gsub(">", ">"), { | 34 | local result, err = to_lua(code, { |
| 35 | implicit_return_root = false, | 35 | implicit_return_root = false, |
| 36 | reserve_line_number = false | 36 | reserve_line_number = false |
| 37 | }) | 37 | }) |
