From 41a88c2574c89a1cfbe0b23a5c7491123750f70c Mon Sep 17 00:00:00 2001 From: tjprescott Date: Fri, 3 Mar 2023 15:18:33 -0800 Subject: [PATCH] Rename Cadl to TypeSpec. --- .../emitters/cadl-apiview/.eslintrc.cjs | 6 --- .../emitters/cadl-apiview/.prettierrc.yaml | 8 ---- .../.c8rc.json | 0 .../emitters/typespec-apiview/.eslintrc.cjs | 6 +++ .../.mocharc.yaml | 0 .../.prettierignore | 0 .../typespec-apiview/.prettierrc.yaml | 8 ++++ .../CHANGELOG.md | 5 ++- .../README.md | 40 +++++++++---------- .../{cadl-apiview => typespec-apiview}/ci.yml | 24 +++++------ .../cspell.yaml | 6 +-- .../package.json | 35 ++++++++-------- .../src/apiview.ts | 6 +-- .../src/diagnostic.ts | 0 .../src/emitter.ts | 6 +-- .../src/index.ts | 0 .../src/lib.ts | 4 +- .../src/namespace-model.ts | 4 +- .../src/navigation.ts | 2 +- .../src/testing/index.ts | 10 ++--- .../src/version.ts | 0 .../test/apiview-options.test.ts | 22 +++++----- .../test/apiview.test.ts | 22 +++++----- .../test/test-host.ts | 24 +++++------ .../tsconfig.json | 0 25 files changed, 119 insertions(+), 119 deletions(-) delete mode 100644 tools/apiview/emitters/cadl-apiview/.eslintrc.cjs delete mode 100644 tools/apiview/emitters/cadl-apiview/.prettierrc.yaml rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/.c8rc.json (100%) create mode 100644 tools/apiview/emitters/typespec-apiview/.eslintrc.cjs rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/.mocharc.yaml (100%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/.prettierignore (100%) create mode 100644 tools/apiview/emitters/typespec-apiview/.prettierrc.yaml rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/CHANGELOG.md (95%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/README.md (55%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/ci.yml (77%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/cspell.yaml (95%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/package.json (68%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/src/apiview.ts (99%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/src/diagnostic.ts (100%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/src/emitter.ts (97%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/src/index.ts (100%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/src/lib.ts (96%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/src/namespace-model.ts (99%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/src/navigation.ts (99%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/src/testing/index.ts (51%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/src/version.ts (100%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/test/apiview-options.test.ts (78%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/test/apiview.test.ts (94%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/test/test-host.ts (81%) rename tools/apiview/emitters/{cadl-apiview => typespec-apiview}/tsconfig.json (100%) diff --git a/tools/apiview/emitters/cadl-apiview/.eslintrc.cjs b/tools/apiview/emitters/cadl-apiview/.eslintrc.cjs deleted file mode 100644 index 8ce089ccb785..000000000000 --- a/tools/apiview/emitters/cadl-apiview/.eslintrc.cjs +++ /dev/null @@ -1,6 +0,0 @@ -require("@cadl-lang/eslint-config-cadl/patch/modern-module-resolution"); - -module.exports = { - extends: "@cadl-lang/eslint-config-cadl", - parserOptions: { tsconfigRootDir: __dirname }, -}; diff --git a/tools/apiview/emitters/cadl-apiview/.prettierrc.yaml b/tools/apiview/emitters/cadl-apiview/.prettierrc.yaml deleted file mode 100644 index 544f4b35e98d..000000000000 --- a/tools/apiview/emitters/cadl-apiview/.prettierrc.yaml +++ /dev/null @@ -1,8 +0,0 @@ -trailingComma: "all" -printWidth: 120 -quoteProps: "consistent" -endOfLine: lf -arrowParens: always -plugins: - - "./node_modules/@cadl-lang/prettier-plugin-cadl" -overrides: [{ "files": "*.cadl", "options": { "parser": "cadl" } }] diff --git a/tools/apiview/emitters/cadl-apiview/.c8rc.json b/tools/apiview/emitters/typespec-apiview/.c8rc.json similarity index 100% rename from tools/apiview/emitters/cadl-apiview/.c8rc.json rename to tools/apiview/emitters/typespec-apiview/.c8rc.json diff --git a/tools/apiview/emitters/typespec-apiview/.eslintrc.cjs b/tools/apiview/emitters/typespec-apiview/.eslintrc.cjs new file mode 100644 index 000000000000..a02edcee2a1a --- /dev/null +++ b/tools/apiview/emitters/typespec-apiview/.eslintrc.cjs @@ -0,0 +1,6 @@ +require("@typespec/eslint-config-typespec/patch/modern-module-resolution"); + +module.exports = { + extends: "@typespec/eslint-config-typespec", + parserOptions: { tsconfigRootDir: __dirname }, +}; diff --git a/tools/apiview/emitters/cadl-apiview/.mocharc.yaml b/tools/apiview/emitters/typespec-apiview/.mocharc.yaml similarity index 100% rename from tools/apiview/emitters/cadl-apiview/.mocharc.yaml rename to tools/apiview/emitters/typespec-apiview/.mocharc.yaml diff --git a/tools/apiview/emitters/cadl-apiview/.prettierignore b/tools/apiview/emitters/typespec-apiview/.prettierignore similarity index 100% rename from tools/apiview/emitters/cadl-apiview/.prettierignore rename to tools/apiview/emitters/typespec-apiview/.prettierignore diff --git a/tools/apiview/emitters/typespec-apiview/.prettierrc.yaml b/tools/apiview/emitters/typespec-apiview/.prettierrc.yaml new file mode 100644 index 000000000000..e19c948bb5ea --- /dev/null +++ b/tools/apiview/emitters/typespec-apiview/.prettierrc.yaml @@ -0,0 +1,8 @@ +trailingComma: "all" +printWidth: 120 +quoteProps: "consistent" +endOfLine: lf +arrowParens: always +plugins: + - "./node_modules/@typespec/prettier-plugin-typespec" +overrides: [{ "files": "*.tsp", "options": { "parser": "typespec" } }] diff --git a/tools/apiview/emitters/cadl-apiview/CHANGELOG.md b/tools/apiview/emitters/typespec-apiview/CHANGELOG.md similarity index 95% rename from tools/apiview/emitters/cadl-apiview/CHANGELOG.md rename to tools/apiview/emitters/typespec-apiview/CHANGELOG.md index 6b12380fa64e..60b6f5ad68b5 100644 --- a/tools/apiview/emitters/cadl-apiview/CHANGELOG.md +++ b/tools/apiview/emitters/typespec-apiview/CHANGELOG.md @@ -1,6 +1,9 @@ # Release History -## Version 0.3.5 (Unreleased) +## Version 0.4.0 (Unreleased) +Update for rename of Cadl to TypeSpec. + +## Version 0.3.5 (02-10-2023) Support latest release of Cadl compiler. **BREAKING CHANGE**: Removed the `--namespace` emitter option. Added the `--service` emitter option to support filtering output for multi-service specs. diff --git a/tools/apiview/emitters/cadl-apiview/README.md b/tools/apiview/emitters/typespec-apiview/README.md similarity index 55% rename from tools/apiview/emitters/cadl-apiview/README.md rename to tools/apiview/emitters/typespec-apiview/README.md index 7157d0ae539f..b99c736f75f6 100644 --- a/tools/apiview/emitters/cadl-apiview/README.md +++ b/tools/apiview/emitters/typespec-apiview/README.md @@ -1,26 +1,26 @@ -# Cadl APIView Emitter +# TypeSpec APIView Emitter -This package provides the [Cadl](https://github.com/microsoft/cadl) emitter to produce APIView token file output from Cadl source. +This package provides the [TypeSpec](https://github.com/microsoft/typespec) emitter to produce APIView token file output from TypeSpec source. ## Install -Add `@azure-tools/cadl-apiview` to your `package.json` and run `npm install`. +Add `@azure-tools/typespec-apiview` to your `package.json` and run `npm install`. ## Emit APIView spec 1. Via the command line ```bash -cadl compile {path to cadl project} --emit=@azure-tools/cadl-apiview +tsc compile {path to typespec project} --emit=@azure-tools/typespec-apiview ``` 2. Via the config -Add the following to the `cadl-project.yaml` file. +Add the following to the `typespec-project.yaml` file. ```yaml emitters: - @azure-tools/cadl-apiview: true + @azure-tools/typespec-apiview: true ``` For configuration [see options](#emitter-options) @@ -29,7 +29,7 @@ For configuration [see options](#emitter-options) 1. Log in to the API View site (apiview.dev)[https://apiview.dev]. 2. Click the blue "Create Review" button in the bottom-right corner of the screen. -3. In the first block, load the token file generated by the `cadl-apiview` emitter. +3. In the first block, load the token file generated by the `typespec-apiview` emitter. ## Revise API View @@ -37,7 +37,7 @@ For configuration [see options](#emitter-options) 2. Navigate to your review. 3. Click the "Revisions" tab in the top left. 4. Click the blue "Add Revision" button in the bottom-right corner of the screen. -5. In the first block, load the token file generated by the `cadl-apiview` emitter. +5. In the first block, load the token file generated by the `typespec-apiview` emitter. ## Use APIView-specific decorators: @@ -45,37 +45,37 @@ Currently there are no APIView-specific decorators... ## Emitter options: -Emitter options can be configured via the `cadl-project.yaml` configuration: +Emitter options can be configured via the `tspconfig.yaml` configuration: ```yaml emitters: - '@azure-tools/cadl-apiview': + '@azure-tools/typespec-apiview': : # For example emitters: - '@azure-tools/cadl-apiview': + '@azure-tools/typespec-apiview': output-file: my-custom-apiview.json ``` or via the command line with ```bash ---option "@azure-tools/cadl-apiview.=" +--option "@azure-tools/typespec-apiview.=" # For example ---option "@azure-tools/cadl-apiview.output-file=my-custom-apiview.json" +--option "@azure-tools/typespec-apiview.output-file=my-custom-apiview.json" ``` ### `emitter-output-dir` -Configure the name of the output directory. Default is `cadl-output/@azure-tools/cadl-apiview`. +Configure the name of the output directory. Default is `tsc-output/@azure-tools/typespec-apiview`. ### `include-global-namespace` Normally, APIView will filter all namespaces and only output those in the service namespace and any -subnamespaces. This is to filter out types that come from the Cadl compiler and supporting libraries. +subnamespaces. This is to filter out types that come from the TypeSpec compiler and supporting libraries. This setting, if `true`, tells APIView to output the contents of the global (empty) namespace, which would normally be excluded. @@ -93,13 +93,13 @@ all services in a multi-service spec, the output filename will be the service ro ### `version` -For multi-versioned Cadl specs, this parameter is used to control which version to emit. This -is not required for single-version specs. For multi-versioned specs, the unprojected Cadl will +For multi-versioned TypeSpec, this parameter is used to control which version to emit. This +is not required for single-version specs. For multi-versioned specs, the unprojected TypeSpec will be rendered if this is not supplied. For multi-service specs, this option cannot be supplied unless the `service` option is also set. ## See also -- [Cadl Getting Started](https://github.com/microsoft/cadl#getting-started) -- [Cadl Tutorial](https://github.com/microsoft/cadl/blob/main/docs/tutorial.md) -- [Cadl for the OpenAPI Developer](https://github.com/microsoft/cadl/blob/main/docs/cadl-for-openapi-dev.md) +- [TypeSpec Getting Started](https://github.com/microsoft/typespec#getting-started) +- [TypeSpec Tutorial](https://github.com/microsoft/typespec/blob/main/docs/tutorial.md) +- [TypeSpec for the OpenAPI Developer](https://github.com/microsoft/typespec/blob/main/docs/typespec-for-openapi-dev.md) diff --git a/tools/apiview/emitters/cadl-apiview/ci.yml b/tools/apiview/emitters/typespec-apiview/ci.yml similarity index 77% rename from tools/apiview/emitters/cadl-apiview/ci.yml rename to tools/apiview/emitters/typespec-apiview/ci.yml index b35909715be1..0dc2d7d4de53 100644 --- a/tools/apiview/emitters/cadl-apiview/ci.yml +++ b/tools/apiview/emitters/typespec-apiview/ci.yml @@ -8,7 +8,7 @@ trigger: - hotfix/* paths: include: - - tools/apiview/emitters/cadl-apiview + - tools/apiview/emitters/typespec-apiview pr: branches: @@ -19,11 +19,11 @@ pr: - hotfix/* paths: include: - - tools/apiview/emitters/cadl-apiview + - tools/apiview/emitters/typespec-apiview variables: NodeVersion: '16.x' - CadlEmitterDirectory: 'tools/apiview/emitters/cadl-apiview' + TypeSpecEmitterDirectory: 'tools/apiview/emitters/typespec-apiview' ArtifactName: 'apiview' FeedRegistry: 'https://registry.npmjs.org/' @@ -44,23 +44,23 @@ stages: - script: | npm install - workingDirectory: $(CadlEmitterDirectory) - displayName: "Install npm packages for CADL emiter" + workingDirectory: $(TypeSpecEmitterDirectory) + displayName: "Install npm packages for TypeSpec emiter" - script: | npm run-script build - workingDirectory: $(CadlEmitterDirectory) - displayName: "Build CADL emitter" + workingDirectory: $(TypeSpecEmitterDirectory) + displayName: "Build TypeSpec emitter" - script: | npm run-script test - workingDirectory: $(CadlEmitterDirectory) - displayName: "Test CADL emitter" + workingDirectory: $(TypeSpecEmitterDirectory) + displayName: "Test TypeSpec emitter" - pwsh: | - npm pack $(CadlEmitterDirectory) + npm pack $(TypeSpecEmitterDirectory) Copy-Item ./*.tgz $(Build.ArtifactStagingDirectory) - displayName: "Pack CADL Emitter" + displayName: "Pack TypeSpec Emitter" - task: PublishBuildArtifacts@1 inputs: @@ -73,7 +73,7 @@ stages: condition: Succeeded() jobs: - job: PublishPackage - displayName: 'Publish cadl-apiview package to devops feed' + displayName: 'Publish typespec-apiview package to devops feed' pool: name: azsdk-pool-mms-ubuntu-2204-general vmImage: MMSUbuntu22.04 diff --git a/tools/apiview/emitters/cadl-apiview/cspell.yaml b/tools/apiview/emitters/typespec-apiview/cspell.yaml similarity index 95% rename from tools/apiview/emitters/cadl-apiview/cspell.yaml rename to tools/apiview/emitters/typespec-apiview/cspell.yaml index 76aaf687b3ab..de4ed1284d30 100644 --- a/tools/apiview/emitters/cadl-apiview/cspell.yaml +++ b/tools/apiview/emitters/typespec-apiview/cspell.yaml @@ -10,7 +10,7 @@ words: - azurecr - blockful - blockless - - cadl + - typespec - Contoso - CRUDL - devdriven @@ -62,6 +62,6 @@ ignorePaths: - "**/node_modules/**" - "**/dist/**" - "**/dist-dev/**" - - "**/cadl-output/**" + - "**/tsp-output/**" enableFiletypes: - - cadl \ No newline at end of file + - tsp \ No newline at end of file diff --git a/tools/apiview/emitters/cadl-apiview/package.json b/tools/apiview/emitters/typespec-apiview/package.json similarity index 68% rename from tools/apiview/emitters/cadl-apiview/package.json rename to tools/apiview/emitters/typespec-apiview/package.json index 0950984ac6e0..718807fec413 100644 --- a/tools/apiview/emitters/cadl-apiview/package.json +++ b/tools/apiview/emitters/typespec-apiview/package.json @@ -1,8 +1,8 @@ { - "name": "@azure-tools/cadl-apiview", - "version": "0.3.5", + "name": "@azure-tools/typespec-apiview", + "version": "0.4.0", "author": "Microsoft Corporation", - "description": "Cadl library for emitting APIView token files from Cadl specifications", + "description": "Library for emitting APIView token files from TypeSpec", "homepage": "https://github.com/Azure/azure-sdk-tools", "readme": "https://github.com/Azure/azure-sdk-tools/blob/master/README.md", "license": "MIT", @@ -14,7 +14,7 @@ "url": "https://github.com/Azure/azure-sdk-tools/issues" }, "keywords": [ - "cadl", + "typespec", "apiview" ], "type": "module", @@ -33,39 +33,38 @@ ] } }, - "cadlMain": "dist/src/index.js", + "typespecMain": "dist/src/index.js", "engines": { "node": ">=16.0.0" }, "scripts": { "clean": "rimraf ./dist ./temp", "prebuild": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts", - "build": "npm run prebuild && tsc -p . && npm run lint-cadl-library", + "build": "npm run prebuild && tsc -p . && npm run lint-typespec-library", "watch": "tsc -p . --watch", - "lint-cadl-library": "cadl compile . --warn-as-error --import @cadl-lang/library-linter --no-emit", + "lint-typespec-library": "tsp compile . --warn-as-error --import @typespec/library-linter --no-emit", "test": "mocha", "test-official": "c8 mocha --forbid-only --reporter mocha-multi-reporters", "lint": "eslint . --ext .ts --max-warnings=0", "lint:fix": "eslint . --fix --ext .ts" }, "files": [ - "lib/*.cadl", + "lib/*.tsp", "dist/**", "!dist/test/**" ], "dependencies": { - "@azure-tools/cadl-azure-core": "0.26.0", - "@azure-tools/cadl-autorest": "0.26.0", - "@azure-tools/cadl-dpg": "latest", - "@cadl-lang/compiler": "0.40.0", - "@cadl-lang/rest": "latest", - "@cadl-lang/versioning": "latest" + "@azure-tools/typespec-azure-core": "0.27.0", + "@azure-tools/typespec-autorest": "0.27.0", + "@typespec/compiler": "0.41.0", + "@typespec/rest": "0.41.0", + "@typespec/versioning": "0.41.0" }, "devDependencies": { - "@cadl-lang/eslint-plugin": "~0.40.0", - "@cadl-lang/library-linter": "~0.40.0", - "@cadl-lang/prettier-plugin-cadl": "^0.40.0", - "@cadl-lang/eslint-config-cadl": "~0.4.1", + "@typespec/eslint-plugin": "~0.41.0", + "@typespec/library-linter": "~0.41.0", + "@typespec/prettier-plugin-typespec": "^0.41.0", + "@typespec/eslint-config-typespec": "~0.6.0", "@types/mocha": "~9.1.0", "@types/node": "~16.0.3", "@changesets/cli": "^2.24.4", diff --git a/tools/apiview/emitters/cadl-apiview/src/apiview.ts b/tools/apiview/emitters/typespec-apiview/src/apiview.ts similarity index 99% rename from tools/apiview/emitters/cadl-apiview/src/apiview.ts rename to tools/apiview/emitters/typespec-apiview/src/apiview.ts index a103706b2bca..9e0e767196f2 100644 --- a/tools/apiview/emitters/cadl-apiview/src/apiview.ts +++ b/tools/apiview/emitters/typespec-apiview/src/apiview.ts @@ -33,7 +33,7 @@ import { UnionExpressionNode, UnionStatementNode, UnionVariantNode, -} from "@cadl-lang/compiler"; +} from "@typespec/compiler"; import { ApiViewDiagnostic, ApiViewDiagnosticLevel } from "./diagnostic.js"; import { ApiViewNavigation } from "./navigation.js"; import { generateId, NamespaceModel } from "./namespace-model.js"; @@ -354,7 +354,7 @@ export class ApiView { private emitHeader() { const toolVersion = LIB_VERSION; - const headerText = `// Package parsed using @azure-tools/cadl-apiview (version:${toolVersion})`; + const headerText = `// Package parsed using @azure-tools/typespec-apiview (version:${toolVersion})`; this.token(ApiViewTokenKind.SkipDiffRangeStart); this.literal(headerText); this.namespaceStack.push("GLOBAL"); @@ -413,7 +413,7 @@ export class ApiView { break; case SyntaxKind.BlockComment: throw new Error(`Case "BlockComment" not implemented`); - case SyntaxKind.CadlScript: + case SyntaxKind.TypeSpecScript: throw new Error(`Case "CadlScript" not implemented`); case SyntaxKind.DecoratorExpression: obj = node as DecoratorExpressionNode; diff --git a/tools/apiview/emitters/cadl-apiview/src/diagnostic.ts b/tools/apiview/emitters/typespec-apiview/src/diagnostic.ts similarity index 100% rename from tools/apiview/emitters/cadl-apiview/src/diagnostic.ts rename to tools/apiview/emitters/typespec-apiview/src/diagnostic.ts diff --git a/tools/apiview/emitters/cadl-apiview/src/emitter.ts b/tools/apiview/emitters/typespec-apiview/src/emitter.ts similarity index 97% rename from tools/apiview/emitters/cadl-apiview/src/emitter.ts rename to tools/apiview/emitters/typespec-apiview/src/emitter.ts index 09e0f7322b9b..370c3b0177e7 100644 --- a/tools/apiview/emitters/cadl-apiview/src/emitter.ts +++ b/tools/apiview/emitters/typespec-apiview/src/emitter.ts @@ -1,5 +1,3 @@ -// See: https://cadlwebsite.z1.web.core.windows.net/docs/extending-cadl/emitters-basics - import { EmitContext, emitFile, @@ -12,8 +10,8 @@ import { projectProgram, resolvePath, Service, -} from "@cadl-lang/compiler"; -import { buildVersionProjections, getVersion } from "@cadl-lang/versioning"; +} from "@typespec/compiler"; +import { buildVersionProjections, getVersion } from "@typespec/versioning"; import path from "path"; import { ApiView } from "./apiview.js"; import { ApiViewEmitterOptions, reportDiagnostic } from "./lib.js"; diff --git a/tools/apiview/emitters/cadl-apiview/src/index.ts b/tools/apiview/emitters/typespec-apiview/src/index.ts similarity index 100% rename from tools/apiview/emitters/cadl-apiview/src/index.ts rename to tools/apiview/emitters/typespec-apiview/src/index.ts diff --git a/tools/apiview/emitters/cadl-apiview/src/lib.ts b/tools/apiview/emitters/typespec-apiview/src/lib.ts similarity index 96% rename from tools/apiview/emitters/cadl-apiview/src/lib.ts rename to tools/apiview/emitters/typespec-apiview/src/lib.ts index a2e613b90e3a..ef8dfd3cd056 100644 --- a/tools/apiview/emitters/cadl-apiview/src/lib.ts +++ b/tools/apiview/emitters/typespec-apiview/src/lib.ts @@ -1,4 +1,4 @@ -import { createCadlLibrary, JSONSchemaType, paramMessage } from "@cadl-lang/compiler"; +import { createCadlLibrary, JSONSchemaType, paramMessage } from "@typespec/compiler"; export interface ApiViewEmitterOptions { "output-file"?: string; @@ -21,7 +21,7 @@ const ApiViewEmitterOptionsSchema: JSONSchemaType = { export const $lib = createCadlLibrary({ - name: "@azure-tools/cadl-apiview", + name: "@azure-tools/typespec-apiview", diagnostics: { "no-services-found": { severity: "error", diff --git a/tools/apiview/emitters/cadl-apiview/src/namespace-model.ts b/tools/apiview/emitters/typespec-apiview/src/namespace-model.ts similarity index 99% rename from tools/apiview/emitters/cadl-apiview/src/namespace-model.ts rename to tools/apiview/emitters/typespec-apiview/src/namespace-model.ts index 06eeaf954365..a7a141704f6f 100644 --- a/tools/apiview/emitters/cadl-apiview/src/namespace-model.ts +++ b/tools/apiview/emitters/typespec-apiview/src/namespace-model.ts @@ -26,7 +26,7 @@ import { Node, visitChildren, ScalarStatementNode, -} from "@cadl-lang/compiler"; +} from "@typespec/compiler"; export class NamespaceModel { kind = SyntaxKind.NamespaceStatement; @@ -144,7 +144,7 @@ function inNamespace(node: Node, program: Program, namespace: Namespace): boolea switch (n.kind) { case SyntaxKind.NamespaceStatement: return program.checker.getTypeForNode(n) === namespace; - case SyntaxKind.CadlScript: + case SyntaxKind.TypeSpecScript: if (n.inScopeNamespaces.length > 0 && inNamespace(n.inScopeNamespaces[0], program, namespace)) { return true; } diff --git a/tools/apiview/emitters/cadl-apiview/src/navigation.ts b/tools/apiview/emitters/typespec-apiview/src/navigation.ts similarity index 99% rename from tools/apiview/emitters/cadl-apiview/src/navigation.ts rename to tools/apiview/emitters/typespec-apiview/src/navigation.ts index 511e2308198e..4abf8cb063ad 100644 --- a/tools/apiview/emitters/cadl-apiview/src/navigation.ts +++ b/tools/apiview/emitters/typespec-apiview/src/navigation.ts @@ -11,7 +11,7 @@ import { SyntaxKind, UnionExpressionNode, UnionStatementNode, -} from "@cadl-lang/compiler"; +} from "@typespec/compiler"; import { ApiView, NamespaceStack } from "./apiview.js"; import { NamespaceModel } from "./namespace-model.js"; diff --git a/tools/apiview/emitters/cadl-apiview/src/testing/index.ts b/tools/apiview/emitters/typespec-apiview/src/testing/index.ts similarity index 51% rename from tools/apiview/emitters/cadl-apiview/src/testing/index.ts rename to tools/apiview/emitters/typespec-apiview/src/testing/index.ts index 07a6d3bac909..0c79177717af 100644 --- a/tools/apiview/emitters/cadl-apiview/src/testing/index.ts +++ b/tools/apiview/emitters/typespec-apiview/src/testing/index.ts @@ -1,20 +1,20 @@ -import { resolvePath } from "@cadl-lang/compiler"; -import { CadlTestLibrary } from "@cadl-lang/compiler/testing"; +import { resolvePath } from "@typespec/compiler"; +import { CadlTestLibrary } from "@typespec/compiler/testing"; import { fileURLToPath } from "url"; export const ApiViewTestLibrary: CadlTestLibrary = { - name: "@azure-tools/cadl-apiview", + name: "@azure-tools/typespec-apiview", packageRoot: resolvePath(fileURLToPath(import.meta.url), "../../../../"), files: [ { realDir: "", pattern: "package.json", - virtualPath: "./node_modules/@azure-tools/cadl-apiview", + virtualPath: "./node_modules/@azure-tools/typespec-apiview", }, { realDir: "dist/src", pattern: "*.js", - virtualPath: "./node_modules/@azure-tools/cadl-apiview/dist/src", + virtualPath: "./node_modules/@azure-tools/typespec-apiview/dist/src", }, ], }; diff --git a/tools/apiview/emitters/cadl-apiview/src/version.ts b/tools/apiview/emitters/typespec-apiview/src/version.ts similarity index 100% rename from tools/apiview/emitters/cadl-apiview/src/version.ts rename to tools/apiview/emitters/typespec-apiview/src/version.ts diff --git a/tools/apiview/emitters/cadl-apiview/test/apiview-options.test.ts b/tools/apiview/emitters/typespec-apiview/test/apiview-options.test.ts similarity index 78% rename from tools/apiview/emitters/cadl-apiview/test/apiview-options.test.ts rename to tools/apiview/emitters/typespec-apiview/test/apiview-options.test.ts index 29ea0a74afb1..c8c7bef8da5c 100644 --- a/tools/apiview/emitters/cadl-apiview/test/apiview-options.test.ts +++ b/tools/apiview/emitters/typespec-apiview/test/apiview-options.test.ts @@ -1,5 +1,5 @@ -import { Diagnostic, logDiagnostics, resolvePath } from "@cadl-lang/compiler"; -import { expectDiagnosticEmpty, expectDiagnostics } from "@cadl-lang/compiler/testing"; +import { Diagnostic, logDiagnostics, resolvePath } from "@typespec/compiler"; +import { expectDiagnosticEmpty, expectDiagnostics } from "@typespec/compiler/testing"; import { strictEqual } from "assert"; import { apiViewFor, apiViewText, compare, createApiViewTestRunner, diagnosticsFor } from "./test-host.js"; @@ -7,7 +7,7 @@ describe("apiview-options: tests", () => { it("omits namespaces that aren't proper subnamespaces", async () => { const input = ` - @Cadl.service( { title: "Test", version: "1" } ) + @TypeSpec.service( { title: "Test", version: "1" } ) namespace Azure.Test { model Foo {}; } @@ -38,7 +38,7 @@ describe("apiview-options: tests", () => { const input = ` model SomeGlobal {}; - @Cadl.service( { title: "Test", version: "1" } ) + @TypeSpec.service( { title: "Test", version: "1" } ) namespace Azure.Test { model Foo {}; } @@ -48,7 +48,7 @@ describe("apiview-options: tests", () => { model SomeGlobal {} } - @Cadl.service( + @TypeSpec.service( { title: "Test"; version: "1"; @@ -67,12 +67,12 @@ describe("apiview-options: tests", () => { it("emits error if multi-service package tries to specify version", async () => { const input = ` - @Cadl.service( { title: "Test", version: "1" } ) + @TypeSpec.service( { title: "Test", version: "1" } ) namespace Azure.Test { model Foo {}; } - @Cadl.service( { title: "OtherTest", version: "1" } ) + @TypeSpec.service( { title: "OtherTest", version: "1" } ) namespace Azure.OtherTest { model Foo {}; } @@ -80,11 +80,11 @@ describe("apiview-options: tests", () => { const diagnostics = await diagnosticsFor(input, {"version": "1"}); expectDiagnostics(diagnostics, [ { - code: "@azure-tools/cadl-apiview/invalid-option", + code: "@azure-tools/typespec-apiview/invalid-option", message: `Option "--output-file" cannot be used with multi-service specs unless "--service" is also supplied.` }, { - code: "@azure-tools/cadl-apiview/invalid-option", + code: "@azure-tools/typespec-apiview/invalid-option", message: `Option "--version" cannot be used with multi-service specs unless "--service" is also supplied.` } ]); @@ -92,12 +92,12 @@ describe("apiview-options: tests", () => { it("allows options if multi-service package specifies --service", async () => { const input = ` - @Cadl.service( { title: "Test", version: "1" } ) + @TypeSpec.service( { title: "Test", version: "1" } ) namespace Azure.Test { model Foo {}; } - @Cadl.service( { title: "OtherTest", version: "1" } ) + @TypeSpec.service( { title: "OtherTest", version: "1" } ) namespace Azure.OtherTest { model Foo {}; } diff --git a/tools/apiview/emitters/cadl-apiview/test/apiview.test.ts b/tools/apiview/emitters/typespec-apiview/test/apiview.test.ts similarity index 94% rename from tools/apiview/emitters/cadl-apiview/test/apiview.test.ts rename to tools/apiview/emitters/typespec-apiview/test/apiview.test.ts index 97f9689bb489..770af72c10b4 100644 --- a/tools/apiview/emitters/cadl-apiview/test/apiview.test.ts +++ b/tools/apiview/emitters/typespec-apiview/test/apiview.test.ts @@ -35,7 +35,7 @@ describe("apiview: tests", () => { it("describes model", async () => { const input = ` - @Cadl.service( { title: "Test", version: "1" } ) + @TypeSpec.service( { title: "Test", version: "1" } ) namespace Azure.Test { model Animal { species: string; @@ -89,7 +89,7 @@ describe("apiview: tests", () => { it("describes scalar", async () => { const input = ` - @Cadl.service( { title: "Test", version: "1" } ) + @TypeSpec.service( { title: "Test", version: "1" } ) namespace Azure.Test { scalar Password extends string; @@ -116,7 +116,7 @@ describe("apiview: tests", () => { it("describes alias", async () => { const input = ` - @Cadl.service( { title: "Test", version: "1" } ) + @TypeSpec.service( { title: "Test", version: "1" } ) namespace Azure.Test { model Animal { species: string; @@ -142,7 +142,7 @@ describe("apiview: tests", () => { it("describes augment decorator", async () => { const input = ` - @Cadl.service( { title: "Test", version: "1" } ) + @TypeSpec.service( { title: "Test", version: "1" } ) namespace Azure.Test { model Animal { species: string; @@ -169,7 +169,7 @@ describe("apiview: tests", () => { it("describes templated model", async () => { const input = ` - @Cadl.service( { title: "Test", version: "1" } ) + @TypeSpec.service( { title: "Test", version: "1" } ) namespace Azure.Test { model Thing { property: T; @@ -241,7 +241,7 @@ describe("apiview: tests", () => { it("describes enum", async () => { const input = ` - @Cadl.service( { title: "Test", version: "1" } ) + @TypeSpec.service( { title: "Test", version: "1" } ) namespace Azure.Test { enum SomeEnum { @@ -284,7 +284,7 @@ describe("apiview: tests", () => { it("describes union", async () =>{ const input = ` - @Cadl.service( { title: "Test", version: "1" } ) + @TypeSpec.service( { title: "Test", version: "1" } ) namespace Azure.Test { union MyUnion { cat: Cat, @@ -335,7 +335,7 @@ describe("apiview: tests", () => { it("describes template operation", async () =>{ const input = ` - @Cadl.service( { title: "Test", version: "1" } ) + @TypeSpec.service( { title: "Test", version: "1" } ) namespace Azure.Test { model FooParams { a: string; @@ -397,7 +397,7 @@ describe("apiview: tests", () => { it("describes operation with anonymous models", async () =>{ const input = ` - @Cadl.service( { title: "Test", version: "1" } ) + @TypeSpec.service( { title: "Test", version: "1" } ) namespace Azure.Test { op SomeOp( param1: { @@ -429,7 +429,7 @@ describe("apiview: tests", () => { it("describes interface", async () => { const input = ` - @Cadl.service( { title: "Test", version: "1" } ) + @TypeSpec.service( { title: "Test", version: "1" } ) namespace Azure.Test { interface Foo { @get @@ -466,7 +466,7 @@ describe("apiview: tests", () => { it("describes string literals", async () => { const input = ` - @Cadl.service( { title: "Test", version: "1" } ) + @TypeSpec.service( { title: "Test", version: "1" } ) namespace Azure.Test { @doc("Short string") model Foo {}; diff --git a/tools/apiview/emitters/cadl-apiview/test/test-host.ts b/tools/apiview/emitters/typespec-apiview/test/test-host.ts similarity index 81% rename from tools/apiview/emitters/cadl-apiview/test/test-host.ts rename to tools/apiview/emitters/typespec-apiview/test/test-host.ts index 6f030ba197b8..d19f75362311 100644 --- a/tools/apiview/emitters/cadl-apiview/test/test-host.ts +++ b/tools/apiview/emitters/typespec-apiview/test/test-host.ts @@ -1,12 +1,12 @@ -import { createTestHost, createTestWrapper } from "@cadl-lang/compiler/testing"; -import { RestTestLibrary } from "@cadl-lang/rest/testing"; -import { VersioningTestLibrary } from "@cadl-lang/versioning/testing"; -import { AzureCoreTestLibrary } from "@azure-tools/cadl-azure-core/testing"; +import { createTestHost, createTestWrapper } from "@typespec/compiler/testing"; +import { RestTestLibrary } from "@typespec/rest/testing"; +import { VersioningTestLibrary } from "@typespec/versioning/testing"; +import { AzureCoreTestLibrary } from "@azure-tools/typespec-azure-core/testing"; import { ApiViewTestLibrary } from "../src/testing/index.js"; -import "@azure-tools/cadl-apiview"; +import "@azure-tools/typespec-apiview"; import { ApiViewEmitterOptions } from "../src/lib.js"; import { ApiViewDocument, ApiViewTokenKind } from "../src/apiview.js"; -import { Diagnostic, resolvePath } from "@cadl-lang/compiler"; +import { Diagnostic, resolvePath } from "@typespec/compiler"; import { strictEqual } from "assert"; export async function createApiViewTestHost() { @@ -20,16 +20,16 @@ export async function createApiViewTestRunner({ }: { withVersioning?: boolean } = {}) { const host = await createApiViewTestHost(); const autoUsings = [ - "Cadl.Rest", - "Cadl.Http", + "TypeSpec.Rest", + "TypeSpec.Http", ] if (withVersioning) { - autoUsings.push("Cadl.Versioning"); + autoUsings.push("TypeSpec.Versioning"); } return createTestWrapper(host, { autoUsings: autoUsings, compilerOptions: { - emit: ["@azure-tools/cadl-apiview"], + emit: ["@azure-tools/typespec-apiview"], } }); } @@ -39,7 +39,7 @@ export async function diagnosticsFor(code: string, options: ApiViewEmitterOption const outPath = resolvePath("/apiview.json"); const diagnostics = await runner.diagnose(code, { noEmit: false, - emitters: { "@azure-tools/cadl-apiview": { ...options, "output-file": outPath } }, + emitters: { "@azure-tools/typespec-apiview": { ...options, "output-file": outPath } }, miscOptions: { "disable-linter": true }, }); return diagnostics; @@ -50,7 +50,7 @@ export async function apiViewFor(code: string, options: ApiViewEmitterOptions): const outPath = resolvePath("/apiview.json"); await runner.compile(code, { noEmit: false, - emitters: { "@azure-tools/cadl-apiview": { ...options, "output-file": outPath } }, + emitters: { "@azure-tools/typespec-apiview": { ...options, "output-file": outPath } }, miscOptions: { "disable-linter": true }, }); diff --git a/tools/apiview/emitters/cadl-apiview/tsconfig.json b/tools/apiview/emitters/typespec-apiview/tsconfig.json similarity index 100% rename from tools/apiview/emitters/cadl-apiview/tsconfig.json rename to tools/apiview/emitters/typespec-apiview/tsconfig.json