* 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; return string.Empty;
} }
StringBuilder sb = new(); StringBuilder sb = new();
bool spaceAdded = false;
foreach (var token in filterdTokens) foreach (var token in filterdTokens)
{ {
sb.Append(token.HasPrefixSpace == true && !spaceAdded ? " " : string.Empty);
sb.Append(token.Value); sb.Append(token.Value);
sb.Append(token.HasSuffixSpace == true ? " " : string.Empty); sb.Append(token.HasSuffixSpace == true ? " " : string.Empty);
spaceAdded = token.HasSuffixSpace == true;
} }
return sb.ToString(); 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 /// Set this to false if there is no suffix space required before next token. For e.g, punctuation right after method name
/// </summary> /// </summary>
public bool HasSuffixSpace { get; set; } = true; 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> /// <summary>
/// Set isDocumentation to true if current token is part of documentation /// 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 // Convert ReviewToken to UI required StructuredToken
foreach (var token in reviewLine.Tokens) 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); var structuredToken = new StructuredToken(token);
tokensInRow.Add(structuredToken); tokensInRow.Add(structuredToken);
@ -268,6 +275,11 @@ namespace APIViewWeb.Helpers
var spaceToken = StructuredToken.CreateSpaceToken(); var spaceToken = StructuredToken.CreateSpaceToken();
spaceToken.Value = " "; spaceToken.Value = " ";
tokensInRow.Add(spaceToken); tokensInRow.Add(spaceToken);
spaceAdded = true;
}
else
{
spaceAdded = false;
} }
} }
return codePanelRowData; return codePanelRowData;

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

@ -241,6 +241,11 @@
"default": true, "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" "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": { "IsDocumentation": {
"type": "boolean", "type": "boolean",
"default": false, "default": false,

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

@ -67,6 +67,8 @@ model ReviewToken {
IsDeprecated?: boolean = false; 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 */ /** 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; 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 */ /** Set isDocumentation to true if current token is part of documentation */
IsDocumentation?: boolean = false; IsDocumentation?: boolean = false;
/** Language specific style css class names */ /** Language specific style css class names */
@ -78,7 +80,7 @@ model ReviewToken {
model CodeDiagnostic { model CodeDiagnostic {
/** Diagnostic ID is auto generated ID by CSharp analyzer. */ /** Diagnostic ID is auto generated ID by CSharp analyzer. */
DiagnosticId?: string; DiagnosticId?: string;
/** Id of ReviewLine object where this diagnostic needs to be displayed */ /** Id of ReviewLine object where this diagnostic needs to be displayed */
TargetId: string; TargetId: string;
/** Auto generated system comment to be displayed under targeted line. */ /** Auto generated system comment to be displayed under targeted line. */
Text: string; Text: string;
@ -87,13 +89,22 @@ model CodeDiagnostic {
} }
enum TokenKind { 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, Text: 0,
/** Punctuation **/
Punctuation: 1, Punctuation: 1,
/** Keyword **/
Keyword: 2, Keyword: 2,
/** TypeName: Kind should be set as TypeName for class definitions, base class token, parameter types etc **/
TypeName: 3, TypeName: 3,
/** MemberName: Kind should be set as MemberName for method name tokens, member variable tokens **/
MemberName: 4, MemberName: 4,
/** StringLiteral: Token kind for any metadata or string literals to show in API view **/
StringLiteral: 5, StringLiteral: 5,
/** Literal: Token kind for any literals, for e.g. enum value or numerical constant literal or default value **/
Literal: 6, 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 Comment: 7
} }