Remove the `@theme` aliasing and update regen docs to render correct
import for starlight
This commit is contained in:
Timothee Guerin 2024-11-04 14:35:31 -08:00 коммит произвёл GitHub
Родитель 2d7eecff6d
Коммит 3b17396f9b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
24 изменённых файлов: 81 добавлений и 198 удалений

Просмотреть файл

@ -155,7 +155,7 @@ op read(): string;
Specify OpenAPI additional information.
```typespec
@TypeSpec.OpenAPI.tagMetadata(name: valueof string, tagMetadata?: valueof TypeSpec.OpenAPI.TagMetadata)
@TypeSpec.OpenAPI.tagMetadata(name: valueof string, tagMetadata: valueof TypeSpec.OpenAPI.TagMetadata)
```
##### Target

Просмотреть файл

@ -13,7 +13,6 @@ import {
inlinecode,
renderMarkdowDoc,
section,
tabs,
} from "../utils/markdown.js";
import { MarkdownRenderer, groupByNamespace } from "./markdown.js";
@ -301,3 +300,24 @@ export class DocusaurusRenderer extends MarkdownRenderer {
return [":::warning", `**Deprecated**: ${notice.message}`, ":::"];
}
}
type Tab = {
id: string;
label: string;
content: string;
};
function tabs(tabs: Tab[]) {
const result = ["<Tabs>"];
for (const tab of tabs) {
result.push(
`<TabItem value="${tab.id}" label="${tab.label}" default>`,
"",
tab.content,
"",
"</TabItem>",
);
}
result.push("</Tabs>", "");
return result.join("\n");
}

Просмотреть файл

@ -13,7 +13,6 @@ import {
inlinecode,
renderMarkdowDoc,
section,
tabs,
} from "../utils/markdown.js";
import { MarkdownRenderer, groupByNamespace } from "./markdown.js";
@ -61,8 +60,7 @@ function renderIndexFile(renderer: DocusaurusRenderer, refDoc: TypeSpecLibraryRe
"toc_min_heading_level: 2",
"toc_max_heading_level: 3",
"---",
"import Tabs from '@theme/Tabs';",
"import TabItem from '@theme/TabItem';",
"import { Tabs, TabItem } from '@astrojs/starlight/components';",
"",
refDoc.description ?? [],
@ -242,12 +240,10 @@ export class DocusaurusRenderer extends MarkdownRenderer {
"Install",
tabs([
{
id: "spec",
label: "In a spec",
content: codeblock(`npm install ${refDoc.name}`, "bash"),
},
{
id: "library",
label: "In a library",
content: codeblock(`npm install --save-peer ${refDoc.name}`, "bash"),
},
@ -285,3 +281,17 @@ export class DocusaurusRenderer extends MarkdownRenderer {
return [":::warning", `**Deprecated**: ${notice.message}`, ":::"];
}
}
type Tab = {
label: string;
content: string;
};
function tabs(tabs: Tab[]) {
const result = ["<Tabs>"];
for (const tab of tabs) {
result.push(`<TabItem label="${tab.label}" default>`, "", tab.content, "", "</TabItem>");
}
result.push("</Tabs>", "");
return result.join("\n");
}

Просмотреть файл

@ -40,27 +40,6 @@ export function table([header, ...rows]: string[][]) {
].join("\n");
}
export type Tab = {
id: string;
label: string;
content: string;
};
export function tabs(tabs: Tab[]) {
const result = ["<Tabs>"];
for (const tab of tabs) {
result.push(
`<TabItem value="${tab.id}" label="${tab.label}" default>`,
"",
tab.content,
"",
"</TabItem>",
);
}
result.push("</Tabs>", "");
return result.join("\n");
}
export interface MarkdownSection {
kind: "section";
title: string;

Просмотреть файл

@ -101,6 +101,7 @@ const sidebar: SidebarItem[] = [
{
label: "📚 Libraries",
items: [
createLibraryReferenceStructure("libraries/events", "Events", false, []),
createLibraryReferenceStructure("libraries/http", "Http", true, [
"libraries/http/cheat-sheet",
"libraries/http/authentication",
@ -115,6 +116,8 @@ const sidebar: SidebarItem[] = [
"libraries/rest/resource-routing",
]),
createLibraryReferenceStructure("libraries/openapi", "OpenAPI", false, []),
createLibraryReferenceStructure("libraries/sse", "Server-Sent Events", false, []),
createLibraryReferenceStructure("libraries/streams", "Streams", false, []),
createLibraryReferenceStructure("libraries/versioning", "Versioning", false, [
"libraries/versioning/guide",
]),

Просмотреть файл

@ -5,22 +5,21 @@ toc_min_heading_level: 2
toc_max_heading_level: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { Tabs, TabItem } from '@astrojs/starlight/components';
TypeSpec library for emitting TypeSpec to JSON Schema and converting JSON Schema to TypeSpec
## Install
<Tabs>
<TabItem value="spec" label="In a spec" default>
<TabItem label="In a spec" default>
```bash
npm install @typespec/json-schema
```
</TabItem>
<TabItem value="library" label="In a library" default>
<TabItem label="In a library" default>
```bash
npm install --save-peer @typespec/json-schema

Просмотреть файл

@ -5,22 +5,21 @@ toc_min_heading_level: 2
toc_max_heading_level: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { Tabs, TabItem } from '@astrojs/starlight/components';
TypeSpec library for emitting OpenAPI 3.0 from the TypeSpec REST protocol binding and converting OpenAPI3 to TypeSpec
## Install
<Tabs>
<TabItem value="spec" label="In a spec" default>
<TabItem label="In a spec" default>
```bash
npm install @typespec/openapi3
```
</TabItem>
<TabItem value="library" label="In a library" default>
<TabItem label="In a library" default>
```bash
npm install --save-peer @typespec/openapi3

Просмотреть файл

@ -50,7 +50,7 @@ model TestMessage {
will be transformed into the Protobuf message below:
```proto3
```protobuf
message TestMessage {
int32 n = 1;
}
@ -76,7 +76,7 @@ model TestMessage {
will be transformed into the Protobuf message below:
```proto3
```protobuf
message TestMessage {
int32 n = 1;
}
@ -100,7 +100,7 @@ namespace Example {
will generate the following Protobuf file (named `example.proto`):
```proto3
```protobuf
syntax = "proto3";
package example;
@ -131,7 +131,7 @@ interface Example {
Results in the following `.proto` file:
```proto3
```protobuf
message Input {
string exampleField = 1;
}

Просмотреть файл

@ -5,22 +5,21 @@ toc_min_heading_level: 2
toc_max_heading_level: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { Tabs, TabItem } from '@astrojs/starlight/components';
TypeSpec library and emitter for Protobuf (gRPC)
## Install
<Tabs>
<TabItem value="spec" label="In a spec" default>
<TabItem label="In a spec" default>
```bash
npm install @typespec/protobuf
```
</TabItem>
<TabItem value="library" label="In a library" default>
<TabItem label="In a library" default>
```bash
npm install --save-peer @typespec/protobuf

Просмотреть файл

@ -56,7 +56,7 @@ For VSCode to respect the TypeSpec standard style set the following options styl
If using `.editorconfig` with the editor config extension
```editorconfig
```toml
[*.tsp]
indent_size = 2
indent_style = space

Просмотреть файл

@ -5,22 +5,21 @@ toc_min_heading_level: 2
toc_max_heading_level: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { Tabs, TabItem } from '@astrojs/starlight/components';
TypeSpec library providing events bindings
## Install
<Tabs>
<TabItem value="spec" label="In a spec" default>
<TabItem label="In a spec" default>
```bash
npm install @typespec/events
```
</TabItem>
<TabItem value="library" label="In a library" default>
<TabItem label="In a library" default>
```bash
npm install --save-peer @typespec/events

Просмотреть файл

@ -5,8 +5,7 @@ toc_min_heading_level: 2
toc_max_heading_level: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { Tabs, TabItem } from '@astrojs/starlight/components';

Просмотреть файл

@ -5,22 +5,21 @@ toc_min_heading_level: 2
toc_max_heading_level: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { Tabs, TabItem } from '@astrojs/starlight/components';
TypeSpec HTTP protocol binding
## Install
<Tabs>
<TabItem value="spec" label="In a spec" default>
<TabItem label="In a spec" default>
```bash
npm install @typespec/http
```
</TabItem>
<TabItem value="library" label="In a library" default>
<TabItem label="In a library" default>
```bash
npm install --save-peer @typespec/http

Просмотреть файл

@ -142,7 +142,7 @@ op read(): string;
Specify OpenAPI additional information.
```typespec
@TypeSpec.OpenAPI.tagMetadata(name: valueof string, tagMetadata?: valueof TypeSpec.OpenAPI.TagMetadata)
@TypeSpec.OpenAPI.tagMetadata(name: valueof string, tagMetadata: valueof TypeSpec.OpenAPI.TagMetadata)
```
#### Target

Просмотреть файл

@ -5,22 +5,21 @@ toc_min_heading_level: 2
toc_max_heading_level: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { Tabs, TabItem } from '@astrojs/starlight/components';
TypeSpec library providing OpenAPI concepts
## Install
<Tabs>
<TabItem value="spec" label="In a spec" default>
<TabItem label="In a spec" default>
```bash
npm install @typespec/openapi
```
</TabItem>
<TabItem value="library" label="In a library" default>
<TabItem label="In a library" default>
```bash
npm install --save-peer @typespec/openapi

Просмотреть файл

@ -5,22 +5,21 @@ toc_min_heading_level: 2
toc_max_heading_level: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { Tabs, TabItem } from '@astrojs/starlight/components';
TypeSpec REST protocol binding
## Install
<Tabs>
<TabItem value="spec" label="In a spec" default>
<TabItem label="In a spec" default>
```bash
npm install @typespec/rest
```
</TabItem>
<TabItem value="library" label="In a library" default>
<TabItem label="In a library" default>
```bash
npm install --save-peer @typespec/rest

Просмотреть файл

@ -5,22 +5,21 @@ toc_min_heading_level: 2
toc_max_heading_level: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { Tabs, TabItem } from '@astrojs/starlight/components';
TypeSpec library providing server sent events bindings
## Install
<Tabs>
<TabItem value="spec" label="In a spec" default>
<TabItem label="In a spec" default>
```bash
npm install @typespec/sse
```
</TabItem>
<TabItem value="library" label="In a library" default>
<TabItem label="In a library" default>
```bash
npm install --save-peer @typespec/sse

Просмотреть файл

@ -1,31 +0,0 @@
---
title: "Data types"
toc_min_heading_level: 2
toc_max_heading_level: 3
---
## TypeSpec.Streams
### `Stream` {#TypeSpec.Streams.Stream}
Defines a model that represents a stream protocol type whose data is described
by `Type`.
This can be useful when the underlying data type is not relevant, or to serve as
a base type for custom streams.
```typespec
model TypeSpec.Streams.Stream<Type>
```
#### Template Parameters
| Name | Description |
| ---- | ------------------------------ |
| Type | The type of the stream's data. |
#### Properties
None

Просмотреть файл

@ -1,42 +0,0 @@
---
title: "Decorators"
toc_min_heading_level: 2
toc_max_heading_level: 3
---
## TypeSpec.Streams
### `@streamOf` {#@TypeSpec.Streams.streamOf}
Specify that a model represents a stream protocol type whose data is described
by `Type`.
```typespec
@TypeSpec.Streams.streamOf(type: unknown)
```
#### Target
`Model`
#### Parameters
| Name | Type | Description |
| ---- | --------- | ------------------------------------------------------- |
| type | `unknown` | The type that models the underlying data of the stream. |
#### Examples
```typespec
model Message {
id: string;
text: string;
}
@streamOf(Message)
model Response {
@body body: string;
}
```

Просмотреть файл

@ -1,42 +0,0 @@
---
title: Overview
sidebar_position: 0
toc_min_heading_level: 2
toc_max_heading_level: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
TypeSpec library providing stream bindings
## Install
<Tabs>
<TabItem value="spec" label="In a spec" default>
```bash
npm install @typespec/streams
```
</TabItem>
<TabItem value="library" label="In a library" default>
```bash
npm install --save-peer @typespec/streams
```
</TabItem>
</Tabs>
## TypeSpec.Streams
### Decorators
- [`@streamOf`](./decorators.md#@TypeSpec.Streams.streamOf)
### Models
- [`Stream`](./data-types.md#TypeSpec.Streams.Stream)

Просмотреть файл

@ -5,22 +5,21 @@ toc_min_heading_level: 2
toc_max_heading_level: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { Tabs, TabItem } from '@astrojs/starlight/components';
TypeSpec library providing stream bindings
## Install
<Tabs>
<TabItem value="spec" label="In a spec" default>
<TabItem label="In a spec" default>
```bash
npm install @typespec/streams
```
</TabItem>
<TabItem value="library" label="In a library" default>
<TabItem label="In a library" default>
```bash
npm install --save-peer @typespec/streams

Просмотреть файл

@ -5,22 +5,21 @@ toc_min_heading_level: 2
toc_max_heading_level: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { Tabs, TabItem } from '@astrojs/starlight/components';
TypeSpec library for declaring and emitting versioned APIs
## Install
<Tabs>
<TabItem value="spec" label="In a spec" default>
<TabItem label="In a spec" default>
```bash
npm install @typespec/versioning
```
</TabItem>
<TabItem value="library" label="In a library" default>
<TabItem label="In a library" default>
```bash
npm install --save-peer @typespec/versioning

Просмотреть файл

@ -5,22 +5,21 @@ toc_min_heading_level: 2
toc_max_heading_level: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { Tabs, TabItem } from '@astrojs/starlight/components';
TypeSpec library providing xml bindings
## Install
<Tabs>
<TabItem value="spec" label="In a spec" default>
<TabItem label="In a spec" default>
```bash
npm install @typespec/xml
```
</TabItem>
<TabItem value="library" label="In a library" default>
<TabItem label="In a library" default>
```bash
npm install --save-peer @typespec/xml

Просмотреть файл

@ -4,9 +4,7 @@
"baseUrl": "./",
"noImplicitAny": false,
"paths": {
"@site/*": ["*"],
"@docusaurus/*": ["src/components/docusaurus/core/*"],
"@theme/*": ["src/components/docusaurus/theme/*"]
"@site/*": ["*"]
},
"jsx": "react-jsx",
"jsxImportSource": "react"