Update apiview token prefix (#9230)
* Update APIView token schema to include hasPrefixSpace property and process this when rendering API view
This commit is contained in:
Родитель
5ea3eeeefa
Коммит
7e93b2ea0f
|
@ -104,10 +104,13 @@ namespace APIView.Model.V2
|
|||
return string.Empty;
|
||||
}
|
||||
StringBuilder sb = new();
|
||||
bool spaceAdded = false;
|
||||
foreach (var token in filterdTokens)
|
||||
{
|
||||
sb.Append(token.HasPrefixSpace == true && !spaceAdded ? " " : string.Empty);
|
||||
sb.Append(token.Value);
|
||||
sb.Append(token.HasSuffixSpace == true ? " " : string.Empty);
|
||||
spaceAdded = token.HasSuffixSpace == true;
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
|
|
@ -48,6 +48,10 @@ namespace APIView.Model.V2
|
|||
/// Set this to false if there is no suffix space required before next token. For e.g, punctuation right after method name
|
||||
/// </summary>
|
||||
public bool HasSuffixSpace { get; set; } = true;
|
||||
/// <summary>
|
||||
/// Set this to true if there is a prefix space required before current token.
|
||||
/// </summary>
|
||||
public bool HasPrefixSpace { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Set isDocumentation to true if current token is part of documentation
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -250,9 +250,16 @@ namespace APIViewWeb.Helpers
|
|||
}
|
||||
}
|
||||
|
||||
bool spaceAdded = false;
|
||||
// Convert ReviewToken to UI required StructuredToken
|
||||
foreach (var token in reviewLine.Tokens)
|
||||
{
|
||||
if (token.HasPrefixSpace == true && !spaceAdded)
|
||||
{
|
||||
var spaceToken = StructuredToken.CreateSpaceToken();
|
||||
spaceToken.Value = " ";
|
||||
tokensInRow.Add(spaceToken);
|
||||
}
|
||||
var structuredToken = new StructuredToken(token);
|
||||
tokensInRow.Add(structuredToken);
|
||||
|
||||
|
@ -268,6 +275,11 @@ namespace APIViewWeb.Helpers
|
|||
var spaceToken = StructuredToken.CreateSpaceToken();
|
||||
spaceToken.Value = " ";
|
||||
tokensInRow.Add(spaceToken);
|
||||
spaceAdded = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
spaceAdded = false;
|
||||
}
|
||||
}
|
||||
return codePanelRowData;
|
||||
|
|
|
@ -241,6 +241,11 @@
|
|||
"default": true,
|
||||
"description": "Set this to false if there is no suffix space required before next token. For e.g, punctuation right after method name"
|
||||
},
|
||||
"HasPrefixSpace": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Set this to true if there is a prefix space required before current token. For e.g, space before token for ="
|
||||
},
|
||||
"IsDocumentation": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
|
|
|
@ -67,6 +67,8 @@ model ReviewToken {
|
|||
IsDeprecated?: boolean = false;
|
||||
/** Set this to false if there is no suffix space required before next token. For e.g, punctuation right after method name */
|
||||
HasSuffixSpace?: boolean = true;
|
||||
/** Set this to true if there is a prefix space required before current token. For e.g, space before token for = */
|
||||
HasPrefixSpace?: boolean = false;
|
||||
/** Set isDocumentation to true if current token is part of documentation */
|
||||
IsDocumentation?: boolean = false;
|
||||
/** Language specific style css class names */
|
||||
|
@ -87,13 +89,22 @@ model CodeDiagnostic {
|
|||
}
|
||||
|
||||
enum TokenKind {
|
||||
/** Text: Token kind should be set as Text for any plan text token. for e.g documentation, namespace value, or attribute or decorator tokens **/
|
||||
Text: 0,
|
||||
/** Punctuation **/
|
||||
Punctuation: 1,
|
||||
/** Keyword **/
|
||||
Keyword: 2,
|
||||
/** TypeName: Kind should be set as TypeName for class definitions, base class token, parameter types etc **/
|
||||
TypeName: 3,
|
||||
/** MemberName: Kind should be set as MemberName for method name tokens, member variable tokens **/
|
||||
MemberName: 4,
|
||||
/** StringLiteral: Token kind for any metadata or string literals to show in API view **/
|
||||
StringLiteral: 5,
|
||||
/** Literal: Token kind for any literals, for e.g. enum value or numerical constant literal or default value **/
|
||||
Literal: 6,
|
||||
/** Comment: Comment text within the code that's really a documentation.
|
||||
* Few languages wants to show comments within API review that's not tagged as documentation **/
|
||||
Comment: 7
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче