Skip to content

Commit 2e2e0a6

Browse files
Add TypeSpec Definition for APIView TreeStyle Parser (#8657)
* Add TypeSpec Definition for APIView TreeStyle Parser * Update TreeStyleParser Schema * Update StructuredToken id documentation, and update json schema
1 parent c9853b6 commit 2e2e0a6

14 files changed

Lines changed: 600 additions & 0 deletions
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "APITreeNode.json",
4+
"type": "object",
5+
"properties": {
6+
"Name": {
7+
"type": "string",
8+
"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)."
9+
},
10+
"Id": {
11+
"$ref": "APITreeNodeId.json",
12+
"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."
13+
},
14+
"Kind": {
15+
"anyOf": [
16+
{
17+
"type": "string",
18+
"const": "assembly"
19+
},
20+
{
21+
"type": "string",
22+
"const": "namespace"
23+
},
24+
{
25+
"type": "string",
26+
"const": "class"
27+
},
28+
{
29+
"type": "string",
30+
"const": "delegate"
31+
},
32+
{
33+
"type": "string",
34+
"const": "enum"
35+
},
36+
{
37+
"type": "string",
38+
"const": "interface"
39+
},
40+
{
41+
"type": "string",
42+
"const": "method"
43+
},
44+
{
45+
"type": "string",
46+
"const": "package"
47+
},
48+
{
49+
"type": "string",
50+
"const": "struct"
51+
},
52+
{
53+
"type": "string",
54+
"const": "type"
55+
}
56+
],
57+
"description": "Descriptor for the kind of the node. Currently used to select navigation icons"
58+
},
59+
"TopTokens": {
60+
"type": "array",
61+
"items": {
62+
"$ref": "StructuredToken.json"
63+
},
64+
"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"
65+
},
66+
"BottomTokens": {
67+
"type": "array",
68+
"items": {
69+
"$ref": "StructuredToken.json"
70+
},
71+
"description": "Tokens which are rendered after all child nodes. Depending on the language this would include the closing curly brace and/or empty lines."
72+
},
73+
"Children": {
74+
"type": "array",
75+
"items": {
76+
"$ref": "APITreeNode.json"
77+
},
78+
"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."
79+
},
80+
"Properties": {
81+
"$ref": "APITreeNodeProperties.json",
82+
"description": "Properties of the APITreeNode."
83+
},
84+
"Tags": {
85+
"type": "array",
86+
"items": {
87+
"$ref": "APITreeNodeTags.json"
88+
},
89+
"description": "Tags of the APITreeNode."
90+
}
91+
},
92+
"required": [
93+
"Name",
94+
"Id",
95+
"Kind"
96+
]
97+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "APITreeNodeId.json",
4+
"type": "string"
5+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "APITreeNodeProperties.json",
4+
"type": "object",
5+
"properties": {
6+
"IconName": {
7+
"type": "string",
8+
"description": "Use this only if you are looking to add a custom icon different from language wide defaults set by APITreeNode kind"
9+
},
10+
"CrossLangDefId": {
11+
"type": "string",
12+
"description": "The cross language definitionId for the node."
13+
}
14+
}
15+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "APITreeNodeTags.json",
4+
"anyOf": [
5+
{
6+
"type": "string",
7+
"const": "Deprecated",
8+
"description": "Mark a token as deprecated."
9+
},
10+
{
11+
"type": "string",
12+
"const": "Hidden",
13+
"description": "Mark a node as Hidden."
14+
},
15+
{
16+
"type": "string",
17+
"const": "HideFromNav",
18+
"description": "Indicate that a node should be hidden from the page navigation."
19+
},
20+
{
21+
"type": "string",
22+
"const": "SkipDiff",
23+
"description": "Indicate that a node should not be used in computation of diff."
24+
}
25+
]
26+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "CodeDiagnostic.json",
4+
"type": "object",
5+
"properties": {
6+
"DiagnosticId": {
7+
"type": "string",
8+
"description": "String associated with a given diagnostic usieally produced by an analyzer"
9+
},
10+
"Text": {
11+
"type": "string"
12+
},
13+
"HelpLinkUri": {
14+
"type": "string"
15+
},
16+
"TargetId": {
17+
"$ref": "APITreeNodeId.json",
18+
"description": "Maps to the APITreeNode id"
19+
},
20+
"Level": {
21+
"$ref": "CodeDiagnosticLevel.json"
22+
}
23+
},
24+
"required": [
25+
"DiagnosticId",
26+
"Text",
27+
"HelpLinkUri",
28+
"TargetId",
29+
"Level"
30+
]
31+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "CodeDiagnosticLevel.json",
4+
"type": "number",
5+
"enum": [
6+
1,
7+
2,
8+
3,
9+
4
10+
]
11+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "CodeFile.json",
4+
"type": "object",
5+
"properties": {
6+
"VersionString": {
7+
"type": "string",
8+
"description": "The version of the parser"
9+
},
10+
"Name": {
11+
"type": "string",
12+
"description": "Name the ocde file. Usually just the package name and version"
13+
},
14+
"Language": {
15+
"anyOf": [
16+
{
17+
"type": "string",
18+
"const": "C"
19+
},
20+
{
21+
"type": "string",
22+
"const": "C#"
23+
},
24+
{
25+
"type": "string",
26+
"const": "C++"
27+
},
28+
{
29+
"type": "string",
30+
"const": "Go"
31+
},
32+
{
33+
"type": "string",
34+
"const": "Java"
35+
},
36+
{
37+
"type": "string",
38+
"const": "JavaScript"
39+
},
40+
{
41+
"type": "string",
42+
"const": "Json"
43+
},
44+
{
45+
"type": "string",
46+
"const": "Kotlin"
47+
},
48+
{
49+
"type": "string",
50+
"const": "Python"
51+
},
52+
{
53+
"type": "string",
54+
"const": "Swagger"
55+
},
56+
{
57+
"type": "string",
58+
"const": "Swift"
59+
},
60+
{
61+
"type": "string",
62+
"const": "TypeSpec"
63+
},
64+
{
65+
"type": "string",
66+
"const": "Xml"
67+
}
68+
]
69+
},
70+
"LanguageVariant": {
71+
"anyOf": [
72+
{
73+
"type": "string",
74+
"const": "Default"
75+
},
76+
{
77+
"type": "string",
78+
"const": "Spring"
79+
},
80+
{
81+
"type": "string",
82+
"const": "Android"
83+
}
84+
],
85+
"default": "Default"
86+
},
87+
"PackageName": {
88+
"type": "string"
89+
},
90+
"ServiceName": {
91+
"type": "string"
92+
},
93+
"PackageVersion": {
94+
"type": "string"
95+
},
96+
"CrossLanguagePackageId": {
97+
"type": "string",
98+
"description": "Maps related packages across Languages"
99+
},
100+
"APIForest": {
101+
"type": "array",
102+
"items": {
103+
"$ref": "APITreeNode.json"
104+
},
105+
"description": "The API Tree(s)"
106+
},
107+
"Diagnostics": {
108+
"type": "array",
109+
"items": {
110+
"$ref": "CodeDiagnostic.json"
111+
}
112+
}
113+
},
114+
"required": [
115+
"VersionString",
116+
"Name",
117+
"Language",
118+
"PackageName",
119+
"PackageVersion",
120+
"APIForest",
121+
"Diagnostics"
122+
]
123+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "StructuredToken.json",
4+
"type": "object",
5+
"properties": {
6+
"Id": {
7+
"$ref": "StructuredTokenId.json",
8+
"description": "Token Id. Previously known as DefinitionId. Also the id used to place APIView comments. Needs to be deterministic"
9+
},
10+
"Kind": {
11+
"$ref": "StructuredTokenKind.json",
12+
"description": "Represents the type of a structured token"
13+
},
14+
"Value": {
15+
"type": "string",
16+
"description": "The token value which will be displayed. Spacing tokens (LineBreak, NonBreakingSpace, TabSpace, and ParameterSeparator) don't need to have value"
17+
},
18+
"Properties": {
19+
"$ref": "StructuredTokenProperties.json",
20+
"description": "Properties of the StructuredToken."
21+
},
22+
"Tags": {
23+
"type": "array",
24+
"items": {
25+
"$ref": "StructuredTokenTags.json"
26+
},
27+
"description": "Tags of the StructuredToken."
28+
},
29+
"RenderClasses": {
30+
"type": "array",
31+
"items": {
32+
"$ref": "StructuredTokenRenderClasses.json"
33+
},
34+
"description": "Classes used to render the StructuredTokens."
35+
}
36+
},
37+
"required": [
38+
"Id",
39+
"Kind"
40+
]
41+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "StructuredTokenId.json",
4+
"type": "string"
5+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "StructuredTokenKind.json",
4+
"type": "number",
5+
"enum": [
6+
0,
7+
1,
8+
2,
9+
3,
10+
4
11+
]
12+
}

0 commit comments

Comments
 (0)