Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling the metadata #3642

Merged
1 commit merged into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions eng/common/scripts/Helpers/Metadata-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ function GenerateDocsMsMetadata($originalMetadata, $language, $languageDisplayNa
"ms.service"= $msService
}
$updatedMetadata = compare-and-merge-metadata -original $originalMetadata -updated $metadataTable
return "---
$updatedMetadata---`r`n"
return "---`r`n$updatedMetadata---`r`n"
}

function ServiceLevelReadmeNameStyle($serviceName) {
Expand Down
16 changes: 6 additions & 10 deletions eng/common/scripts/Service-Level-Readme-Automation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,12 @@ function update-metadata-table($readmeFolder, $readmeName, $serviceName, $msServ
$readmePath = Join-Path $readmeFolder -ChildPath $readmeName
$readmeContent = Get-Content -Path $readmePath -Raw
$match = $readmeContent -match "^---\n*(?<metadata>(.*\n?)*?)---\n*(?<content>(.*\n?)*)"
if (!$match) {
# $Language, $LanguageDisplayName are the variables globally defined in Language-Settings.ps1
$metadataString = GenerateDocsMsMetadata -language $Language -languageDisplayName $LanguageDisplayName -serviceName $serviceName `
-tenantId $TenantId -clientId $ClientId -clientSecret $ClientSecret `
-msService $msService
Set-Content -Path $readmePath -Value "$metadataString$readmeContent" -NoNewline
return
$restContent = $readmeContent
$metadata = ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just be sure that your help method correctly handles metadata if it is empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the code to handle empty case:
image

Will test it as well.

if ($match) {
$restContent = $Matches["content"].trim()
$metadata = $Matches["metadata"].trim()
}
$restContent = $Matches["content"].trim()
$metadata = $Matches["metadata"].trim()
# $Language, $LanguageDisplayName are the variables globally defined in Language-Settings.ps1
$metadataString = GenerateDocsMsMetadata -originalMetadata $metadata -language $Language -languageDisplayName $LanguageDisplayName -serviceName $serviceName `
-tenantId $TenantId -clientId $ClientId -clientSecret $ClientSecret `
Expand All @@ -98,7 +94,7 @@ function generate-markdown-table($readmeFolder, $readmeName, $packageInfo, $moni
$tableContent = ""
# Here is the table, the versioned value will
foreach ($pkg in $packageInfo) {
$repositoryLink = "$RepositoryUri/$($pkg.Package)"
$repositoryLink = "$PackageRepositoryUri/$($pkg.Package)"
if (Test-Path "Function:$GetRepositoryLinkFn") {
$repositoryLink = &$GetRepositoryLinkFn -packageInfo $pkg
}
Expand Down