@shd101wyy/yo 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/cjs/index.cjs +241 -241
- package/out/cjs/yo-cli.cjs +604 -532
- package/out/cjs/yo-lsp.cjs +298 -298
- package/out/esm/index.mjs +2 -2
- package/out/types/src/doc/builder.d.ts +2 -0
- package/out/types/src/doc/model.d.ts +14 -1
- package/out/types/src/doc-command.d.ts +2 -0
- package/out/types/src/evaluator/builtins/build.d.ts +1 -0
- package/out/types/src/evaluator/index.d.ts +3 -0
- package/out/types/src/evaluator/values/impl.d.ts +14 -0
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/scripts/build-site.ts +66 -12
- package/std/build.yo +7 -2
- package/std/collections/array_list.yo +3 -0
package/package.json
CHANGED
package/scripts/build-site.ts
CHANGED
|
@@ -57,12 +57,42 @@ export function getStdDocCommand(rootDir: string = ROOT): {
|
|
|
57
57
|
// ── Parse args ───────────────────────────────────────────────────────
|
|
58
58
|
|
|
59
59
|
let outputDir = path.join(ROOT, "site");
|
|
60
|
+
let siteVersion: string | undefined;
|
|
60
61
|
const args = process.argv.slice(2);
|
|
61
62
|
for (let i = 0; i < args.length; i++) {
|
|
62
63
|
if (args[i] === "--output" && args[i + 1]) {
|
|
63
64
|
outputDir = path.resolve(args[i + 1]!);
|
|
64
65
|
i++;
|
|
66
|
+
} else if (args[i] === "--version" && args[i + 1]) {
|
|
67
|
+
siteVersion = args[i + 1]!;
|
|
68
|
+
i++;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Fallback: auto-detect version from git (tag or commit hash)
|
|
73
|
+
if (!siteVersion) {
|
|
74
|
+
siteVersion = detectGitVersion(ROOT);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function detectGitVersion(cwd: string): string | undefined {
|
|
78
|
+
function git(...gitArgs: string[]): string | undefined {
|
|
79
|
+
try {
|
|
80
|
+
return (
|
|
81
|
+
execFileSync("git", gitArgs, {
|
|
82
|
+
cwd,
|
|
83
|
+
encoding: "utf-8",
|
|
84
|
+
timeout: 5000,
|
|
85
|
+
}).trim() || undefined
|
|
86
|
+
);
|
|
87
|
+
} catch {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
65
90
|
}
|
|
91
|
+
// Show exact tag only if HEAD is exactly at that tag; otherwise show short commit hash
|
|
92
|
+
return (
|
|
93
|
+
git("describe", "--tags", "--exact-match", "HEAD") ??
|
|
94
|
+
git("rev-parse", "--short", "HEAD")
|
|
95
|
+
);
|
|
66
96
|
}
|
|
67
97
|
|
|
68
98
|
// ── Helpers ──────────────────────────────────────────────────────────
|
|
@@ -306,6 +336,17 @@ th {
|
|
|
306
336
|
margin-top: 8px;
|
|
307
337
|
}
|
|
308
338
|
|
|
339
|
+
.version-badge {
|
|
340
|
+
font-size: 0.4em;
|
|
341
|
+
font-weight: 500;
|
|
342
|
+
color: var(--accent);
|
|
343
|
+
background: var(--bg-secondary);
|
|
344
|
+
padding: 2px 10px;
|
|
345
|
+
border-radius: 4px;
|
|
346
|
+
vertical-align: middle;
|
|
347
|
+
margin-left: 8px;
|
|
348
|
+
}
|
|
349
|
+
|
|
309
350
|
.site-nav {
|
|
310
351
|
margin-top: 16px;
|
|
311
352
|
display: flex;
|
|
@@ -341,7 +382,15 @@ th {
|
|
|
341
382
|
`;
|
|
342
383
|
}
|
|
343
384
|
|
|
344
|
-
function wrapHomepage(
|
|
385
|
+
function wrapHomepage(
|
|
386
|
+
title: string,
|
|
387
|
+
bodyHtml: string,
|
|
388
|
+
css: string,
|
|
389
|
+
version?: string
|
|
390
|
+
): string {
|
|
391
|
+
const versionBadge = version
|
|
392
|
+
? `<span class="version-badge">${escapeHtml(version)}</span>`
|
|
393
|
+
: "";
|
|
345
394
|
return `<!DOCTYPE html>
|
|
346
395
|
<html lang="en">
|
|
347
396
|
<head>
|
|
@@ -354,7 +403,7 @@ function wrapHomepage(title: string, bodyHtml: string, css: string): string {
|
|
|
354
403
|
<div class="container">
|
|
355
404
|
<div class="site-header">
|
|
356
405
|
<img src="Yo_logo.png" alt="Yo logo" width="80" height="80">
|
|
357
|
-
<h1>Yo Programming Language</h1>
|
|
406
|
+
<h1>Yo Programming Language ${versionBadge}</h1>
|
|
358
407
|
<p class="tagline">A general-purpose, ahead-of-time compiled language with algebraic effects</p>
|
|
359
408
|
<div class="site-nav">
|
|
360
409
|
<a href="${GITHUB_REPO}">GitHub</a>
|
|
@@ -434,7 +483,12 @@ export async function main(): Promise<void> {
|
|
|
434
483
|
readmeHtml = rewriteReadmeLinks(readmeHtml);
|
|
435
484
|
|
|
436
485
|
const css = generateHomepageCSS();
|
|
437
|
-
const homepage = wrapHomepage(
|
|
486
|
+
const homepage = wrapHomepage(
|
|
487
|
+
"Yo Programming Language",
|
|
488
|
+
readmeHtml,
|
|
489
|
+
css,
|
|
490
|
+
siteVersion
|
|
491
|
+
);
|
|
438
492
|
fs.writeFileSync(path.join(outputDir, "index.html"), homepage, "utf-8");
|
|
439
493
|
console.log(" ✓ index.html");
|
|
440
494
|
|
|
@@ -461,15 +515,15 @@ export async function main(): Promise<void> {
|
|
|
461
515
|
|
|
462
516
|
try {
|
|
463
517
|
const stdDocCommand = getStdDocCommand();
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
);
|
|
518
|
+
const docArgs = [...stdDocCommand.args, "--output", stdOutputDir];
|
|
519
|
+
if (siteVersion) {
|
|
520
|
+
docArgs.push("--version", siteVersion);
|
|
521
|
+
}
|
|
522
|
+
execFileSync(stdDocCommand.command, docArgs, {
|
|
523
|
+
cwd: ROOT,
|
|
524
|
+
stdio: ["ignore", "inherit", "inherit"],
|
|
525
|
+
timeout: 600_000,
|
|
526
|
+
});
|
|
473
527
|
console.log(" ✓ Standard library docs generated");
|
|
474
528
|
} catch (err) {
|
|
475
529
|
console.error(
|
package/std/build.yo
CHANGED
|
@@ -460,6 +460,9 @@ DocConfig :: struct(
|
|
|
460
460
|
(include_deps : bool) ?= false,
|
|
461
461
|
/// Custom site title (default: project name).
|
|
462
462
|
(title : comptime_string) ?= "",
|
|
463
|
+
/// Release version to display (e.g., "v1.0.0").
|
|
464
|
+
/// When empty, auto-detects from git tag or commit hash.
|
|
465
|
+
(version : comptime_string) ?= "",
|
|
463
466
|
/// Path to logo image.
|
|
464
467
|
(logo : comptime_string) ?= "",
|
|
465
468
|
/// Path to favicon.
|
|
@@ -483,7 +486,8 @@ export DocConfig;
|
|
|
483
486
|
/// root: "./src",
|
|
484
487
|
/// output: "docs/api",
|
|
485
488
|
/// format: DocFormat.Markdown,
|
|
486
|
-
/// title: "My Library API"
|
|
489
|
+
/// title: "My Library API",
|
|
490
|
+
/// version: "v1.0.0"
|
|
487
491
|
/// });
|
|
488
492
|
///
|
|
489
493
|
/// install :: build.step("install", "Build all artifacts");
|
|
@@ -498,7 +502,8 @@ doc :: (fn(comptime(config) : DocConfig) -> comptime(Step)) {
|
|
|
498
502
|
__yo_build_doc(
|
|
499
503
|
config.name, config.root, config.output, fmt_str,
|
|
500
504
|
config.include_private, config.include_deps,
|
|
501
|
-
config.title, config.logo, config.favicon
|
|
505
|
+
config.title, config.logo, config.favicon,
|
|
506
|
+
config.version
|
|
502
507
|
);
|
|
503
508
|
Step(name: config.name, kind: StepKind.Documentation)
|
|
504
509
|
};
|
|
@@ -490,7 +490,10 @@ impl(forall(T : Type), ArrayList(T),
|
|
|
490
490
|
})
|
|
491
491
|
);
|
|
492
492
|
impl(forall(T : Type), ArrayList(T), Index(usize)(
|
|
493
|
+
/// The output type is the element type `T`.
|
|
493
494
|
Output : T,
|
|
495
|
+
|
|
496
|
+
/// Returns a pointer to the element at the given index. Panics if the index is out of bounds.
|
|
494
497
|
index : (fn(self: *(Self), idx: usize) -> *(Self.Output))({
|
|
495
498
|
assert((idx < self.*._length), "ArrayList: index out of bounds");
|
|
496
499
|
match(self.*._ptr,
|