Skip to content

Commit

Permalink
Add website build to CI (#4994)
Browse files Browse the repository at this point in the history
Using the same steps as what is used in the github action to publish it.
  • Loading branch information
timotheeguerin authored Nov 7, 2024
1 parent 25e996a commit 58987c5
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 27 deletions.
1 change: 0 additions & 1 deletion .github/workflows/website-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ jobs:

- name: Install browsers
run: pnpm exec playwright install
working-directory: packages/playground-website

- name: Build
run: pnpm --filter "@typespec/website..." run build
Expand Down
11 changes: 11 additions & 0 deletions eng/tsp-core/pipelines/jobs/website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- template: /eng/tsp-core/pipelines/templates/install.yml

- script: pnpm exec playwright install
displayName: Install browsers

- script: pnpm --filter "@typespec/website..." run build
displayName: Build

- script: node eng/common/scripts/check-for-changed-files.js
displayName: Check Git Status For Changed Files
10 changes: 10 additions & 0 deletions eng/tsp-core/pipelines/stages/ci-stages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ stages:
nodeVersion: $(nodeVersion)
os: linux

- job: website
displayName: Website
pool:
name: $(LINUXPOOL)
image: $(LINUXVMIMAGE)
os: linux

steps:
- template: /eng/tsp-core/pipelines/jobs/website.yml

- template: /eng/tsp-core/pipelines/jobs/publish-artifacts.yml
- template: /eng/tsp-core/pipelines/jobs/e2e.yml

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"eslint-plugin-vitest": "^0.5.4",
"micromatch": "^4.0.8",
"picocolors": "~1.1.0",
"playwright": "^1.48.2",
"prettier": "~3.3.3",
"prettier-plugin-astro": "^0.14.1",
"prettier-plugin-organize-imports": "~4.1.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/tspd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
"main": "./dist/src/index.js",
"exports": {
".": {
"types": "./dist/src/index.d.ts",
"default": "./dist/src/index.js"
"import": "./dist/src/index.js"
},
"./ref-doc": {
"types": "./dist/src/ref-doc/index.d.ts",
"default": "./dist/src/ref-doc/index.js"
"import": "./dist/src/ref-doc/index.js"
},
"./ref-doc/emitters/docusaurus": {
"types": "./dist/src/ref-doc/emitters/docusaurus.d.ts",
"default": "./dist/src/ref-doc/emitters/docusaurus.js"
"import": "./dist/src/ref-doc/emitters/docusaurus.js"
},
"./ref-doc/emitters/starlight": {
"import": "./dist/src/ref-doc/emitters/starlight.js"
}
},
"engines": {
Expand Down
16 changes: 8 additions & 8 deletions packages/tspd/src/ref-doc/emitters/starlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { MarkdownRenderer, groupByNamespace } from "./markdown.js";
* Render doc to a markdown using docusaurus addons.
*/
export function renderToAstroStarlightMarkdown(refDoc: TypeSpecRefDoc): Record<string, string> {
const renderer = new DocusaurusRenderer(refDoc);
const renderer = new StarlightRenderer(refDoc);
const files: Record<string, string> = {
"index.mdx": renderIndexFile(renderer, refDoc),
};
Expand Down Expand Up @@ -52,7 +52,7 @@ export function renderToAstroStarlightMarkdown(refDoc: TypeSpecRefDoc): Record<s
return files;
}

function renderIndexFile(renderer: DocusaurusRenderer, refDoc: TypeSpecLibraryRefDoc): string {
function renderIndexFile(renderer: StarlightRenderer, refDoc: TypeSpecLibraryRefDoc): string {
const content: MarkdownDoc = [
"---",
`title: Overview`,
Expand Down Expand Up @@ -97,7 +97,7 @@ export type DecoratorRenderOptions = {
};

export function renderDecoratorFile(
renderer: DocusaurusRenderer,
renderer: StarlightRenderer,
refDoc: TypeSpecRefDocBase,
options?: DecoratorRenderOptions,
): string | undefined {
Expand All @@ -118,7 +118,7 @@ export function renderDecoratorFile(
}

function renderInterfacesFile(
renderer: DocusaurusRenderer,
renderer: StarlightRenderer,
refDoc: TypeSpecRefDoc,
): string | undefined {
if (!refDoc.namespaces.some((x) => x.operations.length > 0 || x.interfaces.length > 0)) {
Expand Down Expand Up @@ -152,7 +152,7 @@ export type DataTypeRenderOptions = {
};

export function renderDataTypes(
renderer: DocusaurusRenderer,
renderer: StarlightRenderer,
refDoc: TypeSpecRefDoc,
options?: DataTypeRenderOptions,
): string | undefined {
Expand Down Expand Up @@ -193,7 +193,7 @@ export function renderDataTypes(
}

function renderEmitter(
renderer: DocusaurusRenderer,
renderer: StarlightRenderer,
refDoc: TypeSpecLibraryRefDoc,
): string | undefined {
if (refDoc.emitter?.options === undefined) {
Expand All @@ -209,7 +209,7 @@ function renderEmitter(
return renderMarkdowDoc(content, 2);
}
function renderLinter(
renderer: DocusaurusRenderer,
renderer: StarlightRenderer,
refDoc: TypeSpecLibraryRefDoc,
): string | undefined {
if (refDoc.linter === undefined) {
Expand All @@ -225,7 +225,7 @@ function renderLinter(
return renderMarkdowDoc(content, 2);
}

export class DocusaurusRenderer extends MarkdownRenderer {
export class StarlightRenderer extends MarkdownRenderer {
headingTitle(item: NamedTypeRefDoc): string {
// Set an explicit anchor id.
return `${inlinecode(item.name)} {#${item.id}}`;
Expand Down
33 changes: 27 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions website/.scripts/regen-compiler-docs.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { NodeHost, joinPaths, logDiagnostics } from "@typespec/compiler";
import { generateJsApiDocs, resolveLibraryRefDocsBase } from "@typespec/tspd/ref-doc";
import {
DocusaurusRenderer,
StarlightRenderer,
renderDataTypes,
renderDecoratorFile,
} from "@typespec/tspd/ref-doc/emitters/docusaurus";
} from "@typespec/tspd/ref-doc/emitters/starlight";

import assert from "assert";
import { writeFile } from "fs/promises";
Expand All @@ -15,7 +15,7 @@ export const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../.."

const diagnostics = new Map();

class CompilerDocusaurusRenderer extends DocusaurusRenderer {
class CompilerRenderer extends StarlightRenderer {
/**
* @param {import("../../tspd/dist/src/ref-doc/types.js").RefDocEntity} type
*/
Expand Down Expand Up @@ -59,7 +59,7 @@ async function generateCompilerDocs() {
});
assert(results, "Unexpected ref doc should have been resolved for compiler.");
const [refDoc, diagnostics] = results;
const renderer = new CompilerDocusaurusRenderer(refDoc as any);
const renderer = new CompilerRenderer(refDoc as any);
const decoratorContent = renderDecoratorFile(renderer, refDoc, { title: "Built-in Decorators" });
assert(decoratorContent, "Unexpected decorator file shouldn't be empty for compiler.");
await writeFile(join(outputDir, "built-in-decorators.md"), decoratorContent);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---
title: "Built-in Data types"
toc_min_heading_level: 2
toc_max_heading_level: 3
---
## TypeSpec
### `Array` {#Array}
Expand Down

0 comments on commit 58987c5

Please sign in to comment.