2023-11-06 21:24:24 +03:00
|
|
|
import { SidebarsConfig } from "@docusaurus/plugin-content-docs";
|
|
|
|
import { SidebarItemConfig } from "@docusaurus/plugin-content-docs/src/sidebars/types.js";
|
2022-11-14 23:44:38 +03:00
|
|
|
|
2023-11-06 21:24:24 +03:00
|
|
|
function createLibraryReferenceStructure(
|
2024-05-02 19:54:35 +03:00
|
|
|
libDir: string,
|
2023-11-06 21:24:24 +03:00
|
|
|
labelName: string,
|
2023-11-16 00:03:36 +03:00
|
|
|
hasLinterRules: boolean,
|
2024-09-16 23:20:57 +03:00
|
|
|
extra: SidebarItemConfig[],
|
2023-11-06 21:24:24 +03:00
|
|
|
): SidebarItemConfig {
|
2023-11-16 00:03:36 +03:00
|
|
|
const rules: SidebarItemConfig = {
|
|
|
|
type: "category",
|
|
|
|
label: "Rules",
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
type: "autogenerated",
|
2024-05-02 19:54:35 +03:00
|
|
|
dirName: `${libDir}/rules`,
|
2023-11-16 00:03:36 +03:00
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
2022-12-15 19:48:16 +03:00
|
|
|
return {
|
|
|
|
type: "category",
|
2023-05-19 21:43:28 +03:00
|
|
|
label: labelName,
|
2022-12-15 19:48:16 +03:00
|
|
|
link: {
|
|
|
|
type: "doc",
|
2024-05-02 19:54:35 +03:00
|
|
|
id: `${libDir}/reference/index`,
|
2022-12-15 19:48:16 +03:00
|
|
|
},
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
type: "autogenerated",
|
2024-05-02 19:54:35 +03:00
|
|
|
dirName: `${libDir}/reference`,
|
2022-12-15 19:48:16 +03:00
|
|
|
},
|
2023-11-16 00:03:36 +03:00
|
|
|
...(hasLinterRules ? [rules] : []),
|
2022-12-15 19:48:16 +03:00
|
|
|
...(extra ?? []),
|
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-11-06 21:24:24 +03:00
|
|
|
const sidebars: SidebarsConfig = {
|
2022-11-14 23:44:38 +03:00
|
|
|
docsSidebar: [
|
|
|
|
{
|
|
|
|
type: "category",
|
2024-01-19 20:42:25 +03:00
|
|
|
label: "Getting started",
|
2022-11-14 23:44:38 +03:00
|
|
|
items: [
|
|
|
|
"introduction/installation",
|
2023-08-02 01:52:37 +03:00
|
|
|
{
|
|
|
|
type: "category",
|
|
|
|
label: "Editor",
|
|
|
|
items: ["introduction/editor/vscode", "introduction/editor/vs"],
|
|
|
|
},
|
2022-11-14 23:44:38 +03:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "category",
|
2023-11-21 23:13:40 +03:00
|
|
|
label: "Guides",
|
2023-09-29 00:45:37 +03:00
|
|
|
items: [
|
2024-07-15 18:42:17 +03:00
|
|
|
{
|
|
|
|
type: "category",
|
2024-07-30 21:05:11 +03:00
|
|
|
label: "TypeSpec for REST",
|
|
|
|
link: { type: "doc", id: "getting-started/getting-started-rest/01-setup-basic-syntax" },
|
2024-07-15 18:42:17 +03:00
|
|
|
items: [
|
|
|
|
{
|
|
|
|
type: "autogenerated",
|
2024-07-30 21:05:11 +03:00
|
|
|
dirName: `getting-started/getting-started-rest`,
|
2024-07-15 18:42:17 +03:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-09-29 00:45:37 +03:00
|
|
|
"getting-started/typespec-for-openapi-dev",
|
|
|
|
],
|
2022-11-14 23:44:38 +03:00
|
|
|
},
|
2024-01-19 20:42:25 +03:00
|
|
|
{
|
|
|
|
type: "category",
|
|
|
|
label: "Handbook",
|
|
|
|
items: [
|
|
|
|
"handbook/cli",
|
|
|
|
"handbook/style-guide",
|
|
|
|
"handbook/formatter",
|
|
|
|
"handbook/reproducibility",
|
|
|
|
{
|
|
|
|
type: "category",
|
|
|
|
label: "Configuration",
|
|
|
|
items: ["handbook/configuration/configuration", "handbook/configuration/tracing"],
|
|
|
|
},
|
|
|
|
"handbook/releases",
|
|
|
|
"handbook/faq",
|
|
|
|
],
|
|
|
|
},
|
2022-11-14 23:44:38 +03:00
|
|
|
{
|
|
|
|
type: "category",
|
2023-11-21 23:13:40 +03:00
|
|
|
label: "📐 Language Basics",
|
2022-11-14 23:44:38 +03:00
|
|
|
items: [
|
|
|
|
"language-basics/overview",
|
2023-04-01 17:22:40 +03:00
|
|
|
"language-basics/built-in-types",
|
2024-07-10 01:35:20 +03:00
|
|
|
"language-basics/identifiers",
|
2022-11-14 23:44:38 +03:00
|
|
|
"language-basics/imports",
|
|
|
|
"language-basics/namespaces",
|
|
|
|
"language-basics/decorators",
|
2023-08-29 01:27:41 +03:00
|
|
|
"language-basics/documentation",
|
2022-11-29 20:09:39 +03:00
|
|
|
"language-basics/scalars",
|
2022-11-14 23:44:38 +03:00
|
|
|
"language-basics/models",
|
|
|
|
"language-basics/operations",
|
|
|
|
"language-basics/interfaces",
|
|
|
|
"language-basics/templates",
|
|
|
|
"language-basics/enums",
|
|
|
|
"language-basics/unions",
|
|
|
|
"language-basics/intersections",
|
|
|
|
"language-basics/type-literals",
|
|
|
|
"language-basics/aliases",
|
Value world, object, tuple literals, const (#3022)
resolves #2046
[Playround](https://cadlplayground.z22.web.core.windows.net/prs/3022/)
Add the new syntax for object literals using `#{`. For this first
version an object literal can only contain other object literal and
other literals(string, number, boolean))
## Values axioms
1. `alias` always produces a type. If you attempt to alias a value, you
get an error.
2. A string template produces a string template type if all
substitutions are types, and a value if all substitutions are numeric,
boolean, or string values. A mixture of types and values is an error.
3. The string literal syntax always results in a string literal type
4. A string literal type may be passed as a string value when the
signature expects a value. When the signature expects either a string
literal type or a string value, it is passed as a string value.
5. A string template type can be passed as a string value when all its
substitutions are string literal types.
## Breaking change
### Removal of the `ValueType` replacement with `MixedConstraint`
This shouldn't affect anyone as you were only exposed to this if you
digged into the template parameter and looked at the constraint
## Deprecation
## Using a tuple instead of a tuple literal
- ✅ still work
- emit a warning
<img width="1013" alt="image"
src="https://github.com/microsoft/typespec/assets/1031227/ab05359a-5ed9-4a27-a8d1-f40d1e21766f">
- provide a codefix
<img width="312" alt="image"
src="https://github.com/microsoft/typespec/assets/1031227/5ef93bdf-665f-4445-a6b2-62475efe8c16">
## Using a model expression instead of an object literal
This technically didn't work before(different from above where tuple was
used as a value) but allow this will allow us to convert most of our
decorators to use `valueof` without being breaking
![Kapture 2024-03-18 at 19 31
32](https://github.com/microsoft/typespec/assets/1031227/f6d69ab4-139e-4b01-95a3-f376b8515d1c)
## Old decorator marshalling
If a library had a decorator with `valueof` one of those types
`numeric`, `int64`, `uint64`, `integer`, `float`, `decimal`,
`decimal128`, `null` it used to marshall those as JS `number` and
`NullType` for `null`. With the introduction of values we have a new
marshalling logic which will marshall those numeric types as `Numeric`
and the others will remain numbers. `null` will also get marshalled as
`null`.
For now this is an opt-in behavior with a warning on decorators not
opt-in having a parameter with a constraint from the list above.
Example:
```
extern dec multipleOf(target: numeric | Reflection.ModelProperty, value: valueof numeric);
```
Will now emit a deprecated warning because `value` is of type `valueof
string` which would marshall to `Numeric` under the new logic but as
`number` previously.
To opt-in you can add the following to your library
```ts
export const $flags = defineModuleFlags({
decoratorArgMarshalling: "value",
});
```
---------
Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-05-08 23:06:28 +03:00
|
|
|
"language-basics/values",
|
2022-11-14 23:44:38 +03:00
|
|
|
"language-basics/type-relations",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "category",
|
2023-11-21 23:13:40 +03:00
|
|
|
label: "📘 Standard Library",
|
2022-11-14 23:44:38 +03:00
|
|
|
items: [
|
|
|
|
"standard-library/built-in-decorators",
|
2023-08-24 21:51:04 +03:00
|
|
|
"standard-library/built-in-data-types",
|
2023-03-31 22:40:47 +03:00
|
|
|
{
|
|
|
|
type: "autogenerated",
|
|
|
|
dirName: `standard-library/reference`,
|
|
|
|
},
|
2024-09-19 21:58:30 +03:00
|
|
|
"standard-library/encoded-names",
|
2023-07-14 04:51:27 +03:00
|
|
|
"standard-library/discriminated-types",
|
2024-08-01 21:26:02 +03:00
|
|
|
"standard-library/examples",
|
2023-11-21 23:13:40 +03:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "category",
|
|
|
|
label: "📚 Libraries",
|
|
|
|
items: [
|
2024-05-02 19:54:35 +03:00
|
|
|
createLibraryReferenceStructure("libraries/http", "Http", true, [
|
2023-11-21 23:13:40 +03:00
|
|
|
"libraries/http/cheat-sheet",
|
|
|
|
"libraries/http/authentication",
|
|
|
|
"libraries/http/operations",
|
|
|
|
"libraries/http/content-types",
|
|
|
|
"libraries/http/multipart",
|
|
|
|
"libraries/http/encoding",
|
2024-08-01 21:26:02 +03:00
|
|
|
"libraries/http/examples",
|
2023-05-19 21:43:28 +03:00
|
|
|
]),
|
2024-05-02 19:54:35 +03:00
|
|
|
createLibraryReferenceStructure("libraries/rest", "Rest", false, [
|
2023-11-21 23:13:40 +03:00
|
|
|
"libraries/rest/cheat-sheet",
|
|
|
|
"libraries/rest/resource-routing",
|
2023-05-19 21:43:28 +03:00
|
|
|
]),
|
2024-05-02 19:54:35 +03:00
|
|
|
createLibraryReferenceStructure("libraries/openapi", "OpenAPI", false, []),
|
|
|
|
createLibraryReferenceStructure("libraries/versioning", "Versioning", false, [
|
|
|
|
"libraries/versioning/guide",
|
2023-05-19 21:43:28 +03:00
|
|
|
]),
|
2024-05-02 19:54:35 +03:00
|
|
|
createLibraryReferenceStructure("libraries/xml", "Xml", false, ["libraries/xml/guide"]),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "category",
|
|
|
|
label: "🖨️ Emitters",
|
|
|
|
items: [
|
|
|
|
createLibraryReferenceStructure("emitters/json-schema", "JSON Schema", false, []),
|
|
|
|
createLibraryReferenceStructure("emitters/openapi3", "OpenAPI3", false, [
|
|
|
|
"emitters/openapi3/openapi",
|
2024-07-03 01:43:49 +03:00
|
|
|
"emitters/openapi3/cli",
|
2024-05-02 19:54:35 +03:00
|
|
|
"emitters/openapi3/diagnostics",
|
2023-05-19 21:43:28 +03:00
|
|
|
]),
|
2024-05-02 19:54:35 +03:00
|
|
|
createLibraryReferenceStructure("emitters/protobuf", "Protobuf", false, [
|
|
|
|
"emitters/protobuf/guide",
|
2023-05-19 21:43:28 +03:00
|
|
|
]),
|
2022-11-14 23:44:38 +03:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "category",
|
2023-11-21 23:13:40 +03:00
|
|
|
label: "🛠️ Writing TypeSpec Libraries",
|
2022-11-14 23:44:38 +03:00
|
|
|
items: [
|
2023-02-16 01:37:39 +03:00
|
|
|
"extending-typespec/basics",
|
2023-05-06 00:17:53 +03:00
|
|
|
"extending-typespec/diagnostics",
|
2023-02-16 01:37:39 +03:00
|
|
|
"extending-typespec/create-decorators",
|
|
|
|
"extending-typespec/linters",
|
2024-03-28 22:41:27 +03:00
|
|
|
"extending-typespec/codefixes",
|
2023-02-16 01:37:39 +03:00
|
|
|
"extending-typespec/emitters",
|
|
|
|
"extending-typespec/emitter-framework",
|
|
|
|
"extending-typespec/emitter-metadata-handling",
|
|
|
|
"extending-typespec/writing-scaffolding-template",
|
2022-11-14 23:44:38 +03:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "category",
|
2023-11-21 23:13:40 +03:00
|
|
|
label: "🚀 Release Notes",
|
2022-11-14 23:44:38 +03:00
|
|
|
collapsed: true,
|
|
|
|
link: {
|
|
|
|
type: "generated-index",
|
|
|
|
title: "Release Notes",
|
|
|
|
slug: "/release-notes",
|
|
|
|
},
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
type: "autogenerated",
|
|
|
|
dirName: "release-notes",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
2023-11-06 21:24:24 +03:00
|
|
|
export default sidebars;
|