Skip to content

Commit

Permalink
Add YAML frontmatter to bootstapped permissions include file (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
millicentachieng authored Dec 4, 2023
1 parent a990589 commit 9d9914c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ApiDoctor.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2788,9 +2788,13 @@ private static async Task<bool> GeneratePermissionFilesAsync(GeneratePermissionF
}
break;
case PermissionsInsertionState.InsertPermissionBlock:
var permissionFileContents = !isBootstrapped
? ConvertToThreeColumnPermissionsTable(originalFileContents.Skip(insertionStartLine + 2).Take(insertionEndLine - insertionStartLine - 1))
: string.Empty;
var includeFileMetadata = "---\r\ndescription: \"Automatically generated file. DO NOT MODIFY\"\r\nms.topic: include\r\nms.localizationpriority: medium\r\n---\r\n\r\n";
var permissionFileContents = string.Empty;
if (!isBootstrapped)
{
var existingPermissionsTable = originalFileContents.Skip(insertionStartLine + 2).Take(insertionEndLine - insertionStartLine - 1);
permissionFileContents = $"{includeFileMetadata}{ConvertToThreeColumnPermissionsTable(existingPermissionsTable)}";
}

if (!options.BootstrappingOnly)
{
Expand All @@ -2805,7 +2809,7 @@ private static async Task<bool> GeneratePermissionFilesAsync(GeneratePermissionF
var newPermissionFileContents = GetPermissionsMarkdownTableForHttpRequestBlock(httpRequests, permissionsDocument); // get from Kibali
if (!string.IsNullOrWhiteSpace(newPermissionFileContents))
{
permissionFileContents = $"---\r\ndescription: \"Automatically generated file. DO NOT MODIFY\"\r\nms.topic: include\r\nms.localizationpriority: medium\r\n---\r\n\r\n{newPermissionFileContents}";
permissionFileContents = $"{includeFileMetadata}{newPermissionFileContents}";
FancyConsole.WriteLine(FancyConsole.ConsoleSuccessColor, $"Permissions table ({foundPermissionTablesOrBlocks}) updated for {docFile.DisplayName}");
}
else
Expand Down

0 comments on commit 9d9914c

Please sign in to comment.