Skip to content

Commit

Permalink
[CADL APIView] Add cadl-apiview emitter (Azure#4160)
Browse files Browse the repository at this point in the history
* Add cadl-apiview emitter.

* Code review feedback.

* Top-level organization updates.

* Code review feedback.

* Refactoring per Timothee's suggestion.

* Emitter updates.

* Adding tests.

* Support union types. Fix anonymous model formatting.

* Improve inline model display.

* Progress on expanded inline models.

* Add more tests.

* Refactor tests.

* Fix singleton NamespaceStack.

* Add yaml to create pipeline to build, test and release cadl APIView emitter

* Enable cadl emmitter  test

* Fix wonky definition IDs.

* Support rendering template parameters.

* More tests. Verify no duplicate definitionIds.

* Give return types on expanded operation signatures a definition ID.

* Add changelog and fix issue with definition IDs.

Co-authored-by: praveenkuttappan <praveen.kuttappan@gmail.com>
  • Loading branch information
tjprescott and praveenkuttappan authored Oct 5, 2022
1 parent 16c7bc3 commit 1a75b70
Show file tree
Hide file tree
Showing 24 changed files with 2,611 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ root = true
# All files
[*]
indent_style = space
charset = utf-8
end_of_line=lf

# XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
Expand All @@ -15,7 +17,7 @@ indent_size = 2
indent_size = 2

# Code files
[*.{cs,csx,vb,vbx}]
[*.{cs,csx,vb,vbx,ts}]
indent_size = 4
insert_final_newline = true

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -499,3 +499,7 @@ tools/oav-traffic-converter/build/
# ios
src/swift/*.xcworkspace/xcuserdata/
src/swift/**/*.xcodeproj/xcuserdata/

# Cadl APIView
cadl-output/
tools/apiview/emitters/cadl-apiview/temp/
3 changes: 3 additions & 0 deletions tools/apiview/emitters/cadl-apiview/.c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"reporter": ["cobertura", "json", "text"]
}
6 changes: 6 additions & 0 deletions tools/apiview/emitters/cadl-apiview/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require("@cadl-lang/eslint-config-cadl/patch/modern-module-resolution");

module.exports = {
extends: "@cadl-lang/eslint-config-cadl",
parserOptions: { tsconfigRootDir: __dirname },
};
5 changes: 5 additions & 0 deletions tools/apiview/emitters/cadl-apiview/.mocharc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
timeout: 5000
require: source-map-support/register
spec: "dist/test/**/*.test.js"
ignore: "dist/test/manual/**/*.js"

319 changes: 319 additions & 0 deletions tools/apiview/emitters/cadl-apiview/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,319 @@
#-------------------------------------------------------------------------------------------------------------------
# Keep this section in sync with .gitignore
#-------------------------------------------------------------------------------------------------------------------

## Ignore generated code
PackageTest/NugetPackageTest/Generated
src/generator/AutoRest.NodeJS.Tests/AcceptanceTests/*.js

## Ignore user-specific files, temporary files, build results, etc.
compare-results/*

# User-specific files
*.suo
*.user
*.sln.docstates
.vs
launchSettings.json

# Build results
binaries/
[Dd]ebug*/
[Rr]elease/

[Tt]est[Rr]esult*
[Bb]uild[Ll]og.*
[Bb]uild.out

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.vspscc
*.vssscc
.builds

*.pidb

*.log*
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf

# Visual Studio profiler
*.psess
*.vsp

# VS Code settings
*.vscode

# Code analysis
*.CodeAnalysisLog.xml

# Guidance Automation Toolkit
*.gpState

# ReSharper is a Visual Studio add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish

# Publish Web Output
*.[Pp]ublish.xml

# Others
[Bb]in
[Oo]bj
sql
*.Cache
ClientBin
[Ss]tyle[Cc]op.*
~$*
*.dbmdl

# Build tasks
[Tt]ools/*.dll
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# Azure Tooling #
node_modules
.ntvs_analysis.dat

# Eclipse #
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath

# Xamarin #
*.userprefs

# Other Tooling #
.classpath
.project
target
build
reports
.gradle
.idea
*.iml
Tools/7-Zip
.gitrevision

# Sensitive files
*.keys
*.pfx
*.cer
*.pem
*.jks

# Backup & report files from converting a project to a new version of VS.
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML

# Mac OS #
.DS_Store
.DS_Store?

# Windows #
Thumbs.db

# Mono
*dll.mdb
*exe.mdb

#old nuget restore folder
.nuget/
src/generator/AutoRest.Ruby*Tests/Gemfile.lock
src/generator/AutoRest.Ruby*/*/RspecTests/Generated/*

#netcore
/NetCore
*.lock.json

#dnx installation
dnx-clr-win-x86*/
dnx-coreclr-win-x86*/
/dnx

# Gemfile.lock
Gemfile.lock

# go ignore
src/generator/AutoRest.Go.Tests/pkg/*
src/generator/AutoRest.Go.Tests/bin/*
src/generator/AutoRest.Go.Tests/src/github.com/*
src/generator/AutoRest.Go.Tests/src/tests/generated/*
src/generator/AutoRest.Go.Tests/src/tests/vendor/*
src/generator/AutoRest.Go.Tests/src/tests/glide.lock

autorest/**/*.js
core/**/*.js

*.js.map

# backup files
*~

#client runtime
src/client/**/*

src/extension/old/**/*
*.d.ts

src/bootstrapper
src/extension/out
src/next-gen

package/nuget/tools
package/chocolatey/*.nupkg

Samples/**/*.map

# npm (we do want to test for most recent versions)
**/package-lock.json
**/dist/
src/*/nm
/nm/
*.tgz


# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
packages/*/coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

# Common toolchain intermediate files
temp

# Rush files
common/temp/**
package-deps.json

# Code generation output for regression tests
core/test/regression

#-------------------------------------------------------------------------------------------------------------------
# Prettier-specific overrides
#-------------------------------------------------------------------------------------------------------------------

# Rush files
common/changes/
common/scripts/
CHANGELOG.*

# Package manager files
pnpm-lock.yaml
yarn.lock
package-lock.json
shrinkwrap.json

# Build outputs
dist

# MICROSOFT SECURITY.md
/SECURITY.md
8 changes: 8 additions & 0 deletions tools/apiview/emitters/cadl-apiview/.prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
trailingComma: "all"
printWidth: 120
quoteProps: "consistent"
endOfLine: lf
arrowParens: always
plugins:
- "./node_modules/@cadl-lang/prettier-plugin-cadl"
overrides: [{ "files": "*.cadl", "options": { "parser": "cadl" } }]
4 changes: 4 additions & 0 deletions tools/apiview/emitters/cadl-apiview/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Release History

## Version 0.1.0 (10-5-2022)
Initial release.
Loading

0 comments on commit 1a75b70

Please sign in to comment.