Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/stacks-svelte/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ This package is an implementation of the [Stacks Design System](https://stackove

[Documentation](https://svelte.stackoverflow.design)

The documentation hosting contract uses `main` for
`svelte.stackoverflow.design` and `v2` for
`v2.svelte.stackoverflow.design`. The former beta domain redirects to the
current documentation.

## Installation

Stacks Svelte can be installed via npm:
Expand Down
6 changes: 6 additions & 0 deletions packages/stacks-svelte/netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@
# variable through the Netlify UI otherwise netlify won't be able to clone the repo due to all our images.
# https://docs.netlify.com/build/configure-builds/environment-variables/#netlify-configuration-variables
GIT_LFS_ENABLED = "true" # just here as a reminder

[[redirects]]
from = "https://beta.svelte.stackoverflow.design/*"
to = "https://svelte.stackoverflow.design/:splat"
status = 301
force = true
20 changes: 20 additions & 0 deletions packages/stacks-svelte/tools/netlify-config.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import assert from "node:assert";
import { describe, test } from "node:test";

const toolsDirectory = dirname(fileURLToPath(import.meta.url));
const netlifyConfig = readFileSync(
join(toolsDirectory, "..", "netlify.toml"),
"utf8"
);

describe("Netlify configuration", () => {
test("redirects the beta hostname to the current documentation", () => {
assert.match(
netlifyConfig,
/\[\[redirects\]\][\s\S]*from = "https:\/\/beta\.svelte\.stackoverflow\.design\/\*"[\s\S]*to = "https:\/\/svelte\.stackoverflow\.design\/:splat"[\s\S]*status = 301[\s\S]*force = true/
);
});
});
9 changes: 7 additions & 2 deletions packages/stacks-svelte/tools/storybook-llms-extractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import process from "node:process";
const __dirname = dirname(fileURLToPath(import.meta.url));

function getCurrentBranch() {
return execSync("git branch --show-current", { encoding: "utf-8" }).trim();
return (
process.env.BRANCH ??
execSync("git branch --show-current", { encoding: "utf-8" }).trim()
);
}

const currentBranch = getCurrentBranch();
Expand All @@ -34,6 +37,8 @@ const CONFIG = {
};
const { distPath, summaryBaseUrl, summaryTitle, summaryDescription } = CONFIG;

export { summaryBaseUrl };

export function parseStorybookIndex(distPath) {
const content = readFileSync(join(distPath, "index.json"), "utf-8");
return JSON.parse(content);
Expand Down Expand Up @@ -366,7 +371,7 @@ function findSubcomponents(componentPath) {
}));
}

function generateDocs(groups) {
export function generateDocs(groups) {
let md = `# ${summaryTitle}\n\n${summaryDescription}\n\n`;
md += `> Generated Storybook documentation optimized for LLM consumption.\n\n---\n\n## Table of Contents\n\n`;

Expand Down
28 changes: 28 additions & 0 deletions packages/stacks-svelte/tools/storybook-llms-extractor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,38 @@ import {
extractPropsFromInterface,
extractPropsFromExports,
extractStoryExamples,
generateDocs,
parseArgsTable,
summaryBaseUrl,
} from "./storybook-llms-extractor.js";

describe("Storybook LLM Extractor", () => {
test("uses the current documentation hostname", () => {
assert.strictEqual(
summaryBaseUrl,
"https://svelte.stackoverflow.design"
);
});

test("generates current documentation and story links", () => {
const result = generateDocs([
{
title: "Components/Button",
docs: { id: "components-button--docs" },
stories: [{ id: "components-button--base", name: "Base" }],
},
]);

assert.match(
result,
/https:\/\/svelte\.stackoverflow\.design\/\?path=\/docs\/components-button--docs/
);
assert.match(
result,
/https:\/\/svelte\.stackoverflow\.design\/\?path=\/story\/components-button--base/
);
});

describe("cleanJSDoc", () => {
test("should remove JSDoc asterisks and trim whitespace", () => {
const input = `
Expand Down
Loading