Sync eng/common directory with azure-sdk-tools for PR 9177 (#23591)

* Escape parentheses in includes to fix issues in publishing

* Only escape close parens

* Comments

---------

Co-authored-by: Daniel Jurek <djurek@microsoft.com>
This commit is contained in:
Azure SDK Bot 2024-10-17 08:53:08 -07:00 коммит произвёл GitHub
Родитель 068ef3d103
Коммит 546e0996f2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 13 добавлений и 4 удалений

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

@ -11,8 +11,17 @@ function create-service-readme(
$readmePath = Join-Path $readmeFolder -ChildPath $readmeName
$content = ""
if (Test-Path (Join-Path $readmeFolder -ChildPath $indexTableLink)) {
# Escape the close parentheses in the URL. This is required by docs
# https://github.com/Azure/azure-sdk-tools/issues/5433
# This line looks incorrect but the left parameter is a regex and must
# escape the parentheses. The right is a literal string and, since this is
# PowerShell, the backslash does not itself need to be escaped.
# Example: "filename-with-(parens).md" -> "filename-with-(parens\).md"
$escapedIndexTableLink = $indexTableLink -replace '\)', '\)'
$content = "## Packages - $moniker`r`n"
$content += "[!INCLUDE [packages]($indexTableLink)]"
$content += "[!INCLUDE [packages]($escapedIndexTableLink)]"
}
if (!$content) {
LogError "There are no packages under service '$serviceName'. "