Skip to content

Commit

Permalink
Add TypeSpec Definition for APIView TreeStyle Parser (#8657)
Browse files Browse the repository at this point in the history
* Add TypeSpec Definition for APIView TreeStyle Parser

* Update TreeStyleParser Schema

* Update StructuredToken id documentation, and update json schema
  • Loading branch information
chidozieononiwu committed Aug 1, 2024
1 parent c9853b6 commit 2e2e0a6
Show file tree
Hide file tree
Showing 14 changed files with 600 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "APITreeNode.json",
"type": "object",
"properties": {
"Name": {
"type": "string",
"description": "The name of the tree node which will be used as label for the API Navigation. Generally this is the name of the module (class, method)."
},
"Id": {
"$ref": "APITreeNodeId.json",
"description": "Id of the node, which should be unique at the node level. i.e. unique among its siblings. This was previously represented by the DefinitionId for the main Token of the node."
},
"Kind": {
"anyOf": [
{
"type": "string",
"const": "assembly"
},
{
"type": "string",
"const": "namespace"
},
{
"type": "string",
"const": "class"
},
{
"type": "string",
"const": "delegate"
},
{
"type": "string",
"const": "enum"
},
{
"type": "string",
"const": "interface"
},
{
"type": "string",
"const": "method"
},
{
"type": "string",
"const": "package"
},
{
"type": "string",
"const": "struct"
},
{
"type": "string",
"const": "type"
}
],
"description": "Descriptor for the kind of the node. Currently used to select navigation icons"
},
"TopTokens": {
"type": "array",
"items": {
"$ref": "StructuredToken.json"
},
"description": "The main data of the node. This is all the tokens that actually define the node. When rendering, TopTokens are rendered first, followed by any Children, and then finally BottomTokens"
},
"BottomTokens": {
"type": "array",
"items": {
"$ref": "StructuredToken.json"
},
"description": "Tokens which are rendered after all child nodes. Depending on the language this would include the closing curly brace and/or empty lines."
},
"Children": {
"type": "array",
"items": {
"$ref": "APITreeNode.json"
},
"description": "The nodes immediate children. For a namespace this would be classes, for a class this would be the class constructors and methods. Children are rendered after TopTokens but before BottomTokens, and are automatically indented."
},
"Properties": {
"$ref": "APITreeNodeProperties.json",
"description": "Properties of the APITreeNode."
},
"Tags": {
"type": "array",
"items": {
"$ref": "APITreeNodeTags.json"
},
"description": "Tags of the APITreeNode."
}
},
"required": [
"Name",
"Id",
"Kind"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "APITreeNodeId.json",
"type": "string"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "APITreeNodeProperties.json",
"type": "object",
"properties": {
"IconName": {
"type": "string",
"description": "Use this only if you are looking to add a custom icon different from language wide defaults set by APITreeNode kind"
},
"CrossLangDefId": {
"type": "string",
"description": "The cross language definitionId for the node."
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "APITreeNodeTags.json",
"anyOf": [
{
"type": "string",
"const": "Deprecated",
"description": "Mark a token as deprecated."
},
{
"type": "string",
"const": "Hidden",
"description": "Mark a node as Hidden."
},
{
"type": "string",
"const": "HideFromNav",
"description": "Indicate that a node should be hidden from the page navigation."
},
{
"type": "string",
"const": "SkipDiff",
"description": "Indicate that a node should not be used in computation of diff."
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "CodeDiagnostic.json",
"type": "object",
"properties": {
"DiagnosticId": {
"type": "string",
"description": "String associated with a given diagnostic usieally produced by an analyzer"
},
"Text": {
"type": "string"
},
"HelpLinkUri": {
"type": "string"
},
"TargetId": {
"$ref": "APITreeNodeId.json",
"description": "Maps to the APITreeNode id"
},
"Level": {
"$ref": "CodeDiagnosticLevel.json"
}
},
"required": [
"DiagnosticId",
"Text",
"HelpLinkUri",
"TargetId",
"Level"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "CodeDiagnosticLevel.json",
"type": "number",
"enum": [
1,
2,
3,
4
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "CodeFile.json",
"type": "object",
"properties": {
"VersionString": {
"type": "string",
"description": "The version of the parser"
},
"Name": {
"type": "string",
"description": "Name the ocde file. Usually just the package name and version"
},
"Language": {
"anyOf": [
{
"type": "string",
"const": "C"
},
{
"type": "string",
"const": "C#"
},
{
"type": "string",
"const": "C++"
},
{
"type": "string",
"const": "Go"
},
{
"type": "string",
"const": "Java"
},
{
"type": "string",
"const": "JavaScript"
},
{
"type": "string",
"const": "Json"
},
{
"type": "string",
"const": "Kotlin"
},
{
"type": "string",
"const": "Python"
},
{
"type": "string",
"const": "Swagger"
},
{
"type": "string",
"const": "Swift"
},
{
"type": "string",
"const": "TypeSpec"
},
{
"type": "string",
"const": "Xml"
}
]
},
"LanguageVariant": {
"anyOf": [
{
"type": "string",
"const": "Default"
},
{
"type": "string",
"const": "Spring"
},
{
"type": "string",
"const": "Android"
}
],
"default": "Default"
},
"PackageName": {
"type": "string"
},
"ServiceName": {
"type": "string"
},
"PackageVersion": {
"type": "string"
},
"CrossLanguagePackageId": {
"type": "string",
"description": "Maps related packages across Languages"
},
"APIForest": {
"type": "array",
"items": {
"$ref": "APITreeNode.json"
},
"description": "The API Tree(s)"
},
"Diagnostics": {
"type": "array",
"items": {
"$ref": "CodeDiagnostic.json"
}
}
},
"required": [
"VersionString",
"Name",
"Language",
"PackageName",
"PackageVersion",
"APIForest",
"Diagnostics"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "StructuredToken.json",
"type": "object",
"properties": {
"Id": {
"$ref": "StructuredTokenId.json",
"description": "Token Id. Previously known as DefinitionId. Also the id used to place APIView comments. Needs to be deterministic"
},
"Kind": {
"$ref": "StructuredTokenKind.json",
"description": "Represents the type of a structured token"
},
"Value": {
"type": "string",
"description": "The token value which will be displayed. Spacing tokens (LineBreak, NonBreakingSpace, TabSpace, and ParameterSeparator) don't need to have value"
},
"Properties": {
"$ref": "StructuredTokenProperties.json",
"description": "Properties of the StructuredToken."
},
"Tags": {
"type": "array",
"items": {
"$ref": "StructuredTokenTags.json"
},
"description": "Tags of the StructuredToken."
},
"RenderClasses": {
"type": "array",
"items": {
"$ref": "StructuredTokenRenderClasses.json"
},
"description": "Classes used to render the StructuredTokens."
}
},
"required": [
"Id",
"Kind"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "StructuredTokenId.json",
"type": "string"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "StructuredTokenKind.json",
"type": "number",
"enum": [
0,
1,
2,
3,
4
]
}
Loading

0 comments on commit 2e2e0a6

Please sign in to comment.