Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ecd4435
Initial plan
Copilot Feb 2, 2026
b002ac5
Add usage instructions and experimental warning to HTTP typekits docu…
Copilot Feb 3, 2026
0e0dc1e
Merge latest main to fix website build issues
Copilot Feb 24, 2026
f6c5749
Merge latest main to fix website build issues
Copilot Feb 24, 2026
aa2b623
Revert "Merge latest main to fix website build issues"
Copilot Feb 24, 2026
7b6e19e
Add experimental warning and usage docs to auto-generated typekit doc…
Copilot Mar 3, 2026
27e2db9
Merge latest main branch
Copilot Mar 3, 2026
cb879ff
Merge branch 'main' into copilot/fix-http-typekits-documentation
markcowl Mar 3, 2026
22f90fe
Fix formatting and add changeset for tspd
Copilot Mar 3, 2026
f88c271
Merge latest main
Copilot Mar 3, 2026
1bd3d39
Refactor to use generic @usageDoc mechanism instead of HTTP-specific …
Copilot Mar 3, 2026
e5d4397
Add changeset for @typespec/http package
Copilot Mar 3, 2026
02c2ea8
Use TSDoc custom block for @usageDoc instead of file I/O
Copilot Mar 3, 2026
8329284
Merge branch 'main' into copilot/fix-http-typekits-documentation
markcowl Mar 3, 2026
55ff5d7
Merge latest main
Copilot Mar 4, 2026
f454442
Address review comments: update changeset description and simplify ex…
Copilot Mar 4, 2026
499a3a7
Simplify changeset description per review feedback
Copilot Mar 4, 2026
5bb12a1
Merge latest main
Copilot Mar 4, 2026
5b5706c
Auto-generate usage info from library metadata, remove @usageDoc mech…
Copilot Mar 4, 2026
584f40f
Merge latest main
Copilot Mar 5, 2026
843912c
Remove package-specific logic and skip usage instructions for compile…
Copilot Mar 5, 2026
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@typespec/tspd"
---

Auto-generate experimental warnings and usage documentation for typekits
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/http"
---

Provide example usage of the experimental typekit in reference documentation
40 changes: 38 additions & 2 deletions packages/tspd/src/ref-doc/components/typekits-file.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,52 @@ import { format as prettierFormat } from "prettier";
import { TypekitCollection } from "../typekit-docs.js";
import { TypekitSection } from "./typekit-section.js";

export function createTypekitDocs(typekit: TypekitCollection) {
export function createTypekitDocs(typekit: TypekitCollection, packageName: string) {
const isCompilerPackage = packageName === "@typespec/compiler";

// Construct import path: for experimental typekits, use /experimental/typekit pattern
const typekitImportPath = typekit.isExperimental
? `${packageName}/experimental/typekit`
: `${packageName}/typekit`;

const jsxContent = (
<Output>
<md.SourceFile path={`typekits.mdx`}>
<>
<md.Frontmatter jsValue={{ title: "[API] Typekits" }} />
{code`
import { Badge } from '@astrojs/starlight/components';
import { Badge${typekit.isExperimental ? ", Aside" : ""} } from '@astrojs/starlight/components';
`}
</>
{typekit.isExperimental && !isCompilerPackage && (
<>
{code`

<Aside type="caution">
**Experimental Feature**: These typekits are currently experimental. The API surface is volatile and may have breaking changes without notice. Use with caution in production environments.
</Aside>

To use these typekits in your TypeSpec emitter or tool, you need to import the typekit module:

\`\`\`ts
import "${typekitImportPath}";
import { $ } from "@typespec/compiler/typekit";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would not repeat this for the compiler typekit

\`\`\`

The first import registers the typekit extensions. This import only needs to exist once in your compilation as only its side effects are important.
`}
</>
)}
{typekit.isExperimental && isCompilerPackage && (
<>
{code`

<Aside type="caution">
**Experimental Feature**: These typekits are currently experimental. The API surface is volatile and may have breaking changes without notice. Use with caution in production environments.
</Aside>
`}
</>
)}
<md.Section>
<For each={Object.values(typekit.namespaces)}>
{(x) => <TypekitSection typekit={x} />}
Expand Down
22 changes: 19 additions & 3 deletions packages/tspd/src/ref-doc/typekit-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import { readPackageJson } from "./utils/misc.js";

export interface TypekitCollection {
namespaces: Record<string, TypekitNamespace>;
isExperimental?: boolean;
}

export interface TypekitNamespace {
name: string;
typeName: string;
doc?: DocSection;
entries: Record<string, TypekitEntryDoc>;
isExperimental?: boolean;
}

type TypekitEntryDoc = TypekitNamespace | TypekitFunctionDoc;
Expand Down Expand Up @@ -72,7 +74,7 @@ export async function writeTypekitDocs(libraryPath: string, outputDir: string):
if (!typekits) {
return;
}
const output = await createTypekitDocs(typekits);
const output = await createTypekitDocs(typekits, pkgJson.name);
for (const [file, content] of Object.entries(output)) {
await writeFile(joinPaths(outputDir, file), content);
}
Expand All @@ -87,6 +89,8 @@ async function getTypekitApi(
return undefined;
}
const namespaces: Record<string, TypekitNamespace> = {};
let hasExperimental = false;

for (const pkgMember of api.packages[0].members) {
for (const member of pkgMember.members) {
if (member instanceof ApiInterface) {
Expand All @@ -96,19 +100,29 @@ async function getTypekitApi(
const name = (typekitTag.content.nodes[0] as any).nodes.filter(
(x: DocNode) => x.kind === "PlainText",
)[0].text;
const typekit: TypekitNamespace = resolveTypekit(member, [name]);
const isExperimental = docComment?.modifierTagSet.hasTagName("@experimental") ?? false;
if (isExperimental) {
hasExperimental = true;
}

const typekit: TypekitNamespace = resolveTypekit(member, [name], isExperimental);
namespaces[name] = typekit;
}
}
}
}

function resolveTypekit(iface: ApiInterface, path: string[]): TypekitNamespace {
function resolveTypekit(
iface: ApiInterface,
path: string[],
isExperimental: boolean,
): TypekitNamespace {
const typekit: TypekitNamespace = {
name: path[0],
typeName: iface.displayName,
doc: iface.tsdocComment?.summarySection,
entries: {},
isExperimental,
};
for (const member of iface.members) {
if (member instanceof ApiPropertySignature) {
Expand All @@ -119,6 +133,7 @@ async function getTypekitApi(
typekit.entries[member.displayName] = resolveTypekit(
subkit.resolvedApiItem as ApiInterface,
[...path, member.displayName],
isExperimental,
);
} else if (propertyReference.toString() === "@typespec/compiler!Diagnosable:type") {
typekit.entries[member.displayName] = {
Expand Down Expand Up @@ -170,5 +185,6 @@ async function getTypekitApi(

return {
namespaces,
isExperimental: hasExperimental,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@
title: "[API] Typekits"
---

import { Badge } from '@astrojs/starlight/components';
import { Badge, Aside } from '@astrojs/starlight/components';

<Aside type="caution">
**Experimental Feature**: These typekits are currently experimental. The API surface is volatile and may have breaking changes without notice. Use with caution in production environments.
</Aside>

To use these typekits in your TypeSpec emitter or tool, you need to import the typekit module:

```ts
import "@typespec/http/experimental/typekit";
import { $ } from "@typespec/compiler/typekit";
```

The first import registers the typekit extensions. This import only needs to exist once in your compilation as only its side effects are important.

## model

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
title: "[API] Typekits"
---

import { Badge } from '@astrojs/starlight/components';
import { Badge, Aside } from '@astrojs/starlight/components';

<Aside type="caution">
**Experimental Feature**: These typekits are currently experimental. The API surface is volatile and may have breaking changes without notice. Use with caution in production environments.
</Aside>

## array

Expand Down