* Update APIView token schema to include hasPrefixSpace property and process this when rendering API view
This commit is contained in:
Praven Kuttappan 2024-10-24 16:56:30 -04:00 коммит произвёл GitHub
Родитель 5ea3eeeefa
Коммит 7e93b2ea0f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
6 изменённых файлов: 54307 добавлений и 2 удалений

Просмотреть файл

@ -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
}