-
Notifications
You must be signed in to change notification settings - Fork 340
Auto-generate experimental warnings and usage docs for typekits from library metadata #9564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ecd4435
b002ac5
0e0dc1e
f6c5749
aa2b623
7b6e19e
27e2db9
cb879ff
22f90fe
f88c271
1bd3d39
e5d4397
02c2ea8
8329284
55ff5d7
f454442
499a3a7
5bb12a1
5b5706c
584f40f
843912c
882add9
eeb575d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,16 +12,68 @@ 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 && ( | ||
| <> | ||
| {code` | ||
|
|
||
| <Aside type="caution"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This aside should only be printed when the typekit is experimental |
||
| **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> | ||
| `} | ||
| </> | ||
| )} | ||
| {!isCompilerPackage && ( | ||
| <> | ||
| {code` | ||
|
|
||
| To use these typekits in your TypeSpec emitter or tool, you need to import the typekit module: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This usage information should be printed for any typekit (other than the compiler typekit) |
||
|
|
||
| \`\`\`ts${ | ||
| typekit.isExperimental | ||
| ? ` | ||
| import "${typekitImportPath}";` | ||
| : "" | ||
| } | ||
| import { $ } from "@typespec/compiler/typekit"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I mean is that, for the compiler typekit, you would want to load the typekit like this: import { $ } from "@typespec/compiler/typekit";So it makes sense to still include this usage text in the compiler typekit, but not the other import statement. Only typekits other than the compiler would have both import statements.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done (commit 882add9). Compiler typekits now include usage instructions with the import statement: import { $ } from "@typespec/compiler/typekit";The first import statement (for registering extensions) is only shown for non-compiler packages like HTTP. |
||
| \`\`\`${ | ||
| typekit.isExperimental | ||
| ? ` | ||
|
|
||
| The first import registers the typekit extensions. This import only needs to exist once in your compilation as only its side effects are important.` | ||
| : "" | ||
| } | ||
| `} | ||
| </> | ||
| )} | ||
| {isCompilerPackage && ( | ||
| <> | ||
| {code` | ||
|
|
||
| To use these typekits in your TypeSpec emitter or tool, you need to import the typekit module: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This usage documentation should occur whether the typekit is experimental or not |
||
|
|
||
| \`\`\`ts | ||
| import { $ } from "@typespec/compiler/typekit"; | ||
markcowl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| \`\`\` | ||
| `} | ||
| </> | ||
| )} | ||
| <md.Section> | ||
| <For each={Object.values(typekit.namespaces)}> | ||
| {(x) => <TypekitSection typekit={x} />} | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.