Skip to content

Commit

Permalink
Add TypeSpec Definition for APIView TreeStyle Parser
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Jul 22, 2024
1 parent c9cad29 commit 172bfc3
Show file tree
Hide file tree
Showing 11 changed files with 459 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"$schema": "https://json-schema.org/draft/2020-12/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": {
"type": "string",
"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": "The kind of node"
},
"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,11 @@
{
"$schema": "https://json-schema.org/draft/2020-12/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"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://json-schema.org/draft/2020-12/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."
},
{
"type": "string",
"const": "CrossLangDefId",
"description": "The cross language definitionId for the node."
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "CodeDiagnostic.json",
"type": "object",
"properties": {
"DiagnosticId": {
"type": "string"
},
"Text": {
"type": "string"
},
"HelpLinkUri": {
"type": "string"
},
"TargetId": {
"type": "string",
"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,12 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "CodeDiagnosticLevel.json",
"type": "string",
"enum": [
"Default",
"Info",
"Warning",
"Error",
"Fatal"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "StructuredToken.json",
"type": "object",
"properties": {
"Id": {
"type": "string",
"description": "Token Id. Previously known as DefinitionId."
},
"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,12 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "StructuredTokenKind.json",
"type": "string",
"enum": [
"Content",
"LineBreak",
"NonBreakingSpace",
"TabSpace",
"ParameterSeparator"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "StructuredTokenProperties.json",
"type": "object",
"properties": {
"GroupId": {
"type": "string",
"const": "doc",
"description": "Group a sequence of consecutive StructuredTokens. doc indicates that the group of tokens is documentation."
},
"NavigateToId": {
"type": "string",
"description": "Id to navigate to when StructuredToken is clicked."
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "StructuredTokenRenderClasses.json",
"anyOf": [
{
"type": "string",
"const": "comment"
},
{
"type": "string",
"const": "keyword"
},
{
"type": "string",
"const": "keyword"
},
{
"type": "string",
"const": "literal"
},
{
"type": "string",
"const": "sliteral",
"description": "string literal"
},
{
"type": "string",
"const": "mname",
"description": "member name"
},
{
"type": "string",
"const": "tname",
"description": "type name"
},
{
"type": "string",
"const": "punc",
"description": "punctuation"
},
{
"type": "string",
"const": "text"
},
{
"type": "string"
}
],
"description": "Classes used to render the StructuredTokens. Extendable by contributing styles at https://github.com/Azure/azure-sdk-tools/blob/main/src/dotnet/APIView/ClientSPA/src/app/_components/code-panel/code-panel.component.scss"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "StructuredTokenTags.json",
"anyOf": [
{
"type": "string",
"const": "Deprecated",
"description": "Mark a token as deprecated"
},
{
"type": "string",
"const": "SkipDiff",
"description": "Indicate that a Token should not be used in computing diff"
}
]
}
Loading

0 comments on commit 172bfc3

Please sign in to comment.