Skip to content

Commit 3c3723e

Browse files
update tree Token Parser Documentation
1 parent 25ea99e commit 3c3723e

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

tools/apiview/parsers/CONTRIBUTING.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The main idea is to capture the hierachy of the API using a tree data structure,
88

99
![APITree](APITree.svg)
1010

11-
Each tree node has top tokens which should be used to capture the main data on the node. If your language requires it use the bottom tokens to capture data that closes out the node.
11+
Each tree node has top tokens which should be used to capture the main tokens on the node. If your language requires it use the bottom tokens to capture tokens that closes out the node.
1212

1313
- Here are the models needed
1414
```
@@ -26,6 +26,7 @@ Each tree node has top tokens which should be used to capture the main data on t
2626
string Value
2727
string Id
2828
StructuredTokenKind Kind
29+
Set<string> Tags
2930
Dictionary<string, string> Properties
3031
Set<string> RenderClasses
3132
@@ -38,39 +39,44 @@ Each tree node has top tokens which should be used to capture the main data on t
3839
Url
3940
```
4041
### APITreeNode
41-
- `Name` : The name of the tree node which will be used for page navigation.
42-
- `Id` : Id of the node, which should be unique at the node level. i.e. unique among its siblings. Also the id should be [valid HTML id](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).
42+
- `Name` : The name of the tree node which will be used for API navigation.
43+
- `Id` : Id of the node, which should be unique at the node level. i.e. unique among its siblings
4344
- `Kind` : What kind of node is it. (namespace, class, module, method e.t.c)
44-
- `Tags` : Use this for thigs like `Deprecated`, `Hidden`
45-
- `Properties` : If the node needs more specification e.g. Use `SubKind` entry to make the node kind more specific. Feel free to push any other data that you think will be useful here, then file an issue for further implementation in APIView.
45+
- `Tags` : Use this for opt in or opt out boolean properties e.g. `Deprecated`, `Hidden`, `HideFromNavigation`
46+
- `Properties` : Use this for other properties of the node. If the node needs more specification e.g. Use `SubKind` entry to make the node kind more specific.
4647
- `TopTokens` : The main data of the node.
4748
- `BottomToken` : Data that closes out the node.
48-
- `Childrens` : Node immediate descendant
49+
- `Children` : Node immediate descendant
4950

5051
### StructuredToken
5152
- `Value` : The token value which will be dispalyed.
52-
- `Id` : which will be used to navigate and find token on page.
53-
- `Kind` : Could be `LineBreak` `NoneBreakingSpace` `TabSpace` `ParameterSeparator` `Url` `Content`
54-
All tokens should be content except for spacing tokens. ParameterSeparator should be used between method or function parameters. Spacing token dont need to have value.
55-
- `Properties` : Capture any other interesting data here. e.g Use `GroupId` : `documentation` to group consecutive tokens.
56-
- `RenderClasses` : Add css classes for how the tokens will be rendred.
53+
- `Id` : Which will be used to navigate and find token on page.
54+
- `Kind` : Could be `Content` `LineBreak` `NoneBreakingSpace` `TabSpace` `ParameterSeparator` `Url`
55+
All tokens should be content except for spacing tokens and url. ParameterSeparator should be used between method or function parameters. Spacing token dont need to have value.
56+
- `Tags` : Use this for opt in or opt out boolean properties e.g. `SkippDiff`
57+
- `Properties` : Capture any other interesting data here. e.g Use `GroupId` : `documentation` to group consecutive comment tokens.
58+
- `RenderClasses` : Add css classes for how the tokens will be rendred. Classes currently being used are `text` `keyword` `punctuation` `type-name` `member-name` `literal` `string-literal` `comment` Feel free to add your own custom class. Whatever custom classes you use please provide us the appriopriate css for the class so we can update APIView.
59+
60+
Each module of the API (namespace, class, method) should be its own node.
5761

5862
If you want to have space between the API nodes add an empty token and lineBreak at the end of bottom tokens to simulate one empty line.
5963

6064
Dont worry about indentation that will be handeled by the tree structure, unless you want to have indentation between the tokens then use `TabSpace` token kind.
6165

62-
If your packages contains multiple languages then you will have multiple trees with multiple roots.
66+
If your packages contains multiple assemblies then you will have multiple trees with multiple roots.
6367
Assign the final parsed value to `APIForest` property of the `CodeFile`.
6468

65-
## Commons Scenarios
69+
Serialize the generated code file to JSON `.json` and MessagePack `.msgpack`. MessagePack will be used by APIView as it has way better download / deserilization performance. We will revert to JSON if you don`t provide MessagePack.
70+
71+
## How to handle commons Scenarios
6672
- TEXT, KEYWORD, COMMENT : Add `text`, `keyword`, `comment` to RenderClasses of the token
6773
- NEW_LINE : Create a token with `Kind = LineBreak`
6874
- WHITE_SPACE : Create token with `Kind = NoneBreakingSpace`
6975
- PUNCTUATION : Create a token with `Kind = Content` and the `Value = the punctuation`
7076
- DOCUMENTATION : Add `GroupId = documentation` in the properties of the token. This identifies a range of consecutive tokens as belonging to a group.
71-
- SKIP_DIFF : Add `SkipDiff` to the node Tag to indicate that diff should be skipped.
72-
- LINE_ID_MARKER : You can add a empty token. `Kind = Content` and `Value = Empty String` then give it an Id to make it commentable.
77+
- SKIP_DIFF : Add `SkipDiff` to the Tag to indicate that node or token should not be included in diff computation
78+
- LINE_ID_MARKER : You can add a empty token. `Kind = Content` and `Value = ""` then give it an `Id` to make it commentable.
7379
- EXTERNAL_LINK : Create a single token set `Kind = Url`, `Value = link` then add the link text as a properties `LinkText`;
74-
- Common Tags: `Deprecated`, `Hidden`, `HideFromNavigation`
75-
80+
- Common Tags: `Deprecated`, `Hidden`, `HideFromNavigation`, `SkipDiff`
7681

82+
Please reach out at [APIView Teams Channel](https://teams.microsoft.com/l/channel/19%3A3adeba4aa1164f1c889e148b1b3e3ddd%40thread.skype/APIView?groupId=3e17dcb0-4257-4a30-b843-77f47f1d4121&tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47) if you need more infomation.

0 commit comments

Comments
 (0)