Skip to content

Commit c2a8656

Browse files
authored
Workaround to enable OpenAI documentation on learn.microsoft.com (#31788)
Work item to undo the workaround when proper support is implemented in `type2docfx`: #31787 Docs with changes in place: https://review.learn.microsoft.com/en-us/javascript/api/overview/azure/openai-readme?view=azure-node-preview&branch=djurek%2Fopenai-readme The change in `Docs-Toc.ps1` adds the OpenAI entry and then sorts the packages in Cognitive Services so that OpenAI ends up in the right place.
1 parent a179d22 commit c2a8656

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

eng/scripts/docs/Docs-ToC.ps1

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
function GetOnboardingFile($docRepoLocation, $moniker) {
1+
function GetOnboardingFile($docRepoLocation, $moniker) {
22
$packageOnboardingFile = "$docRepoLocation/ci-configs/packages-latest.json"
33
if ("preview" -eq $moniker) {
44
$packageOnboardingFile = "$docRepoLocation/ci-configs/packages-preview.json"
55
}
6-
elseif ("legacy" -eq $moniker) {
6+
elseif ("legacy" -eq $moniker) {
77
$packageOnboardingFile = "$docRepoLocation/ci-configs/packages-legacy.json"
88
}
99

@@ -36,7 +36,7 @@ function Get-javascript-OnboardedDocsMsPackagesForMoniker($DocRepoLocation, $mon
3636
$packageOnboardingFile = GetOnboardingFile `
3737
-docRepoLocation $DocRepoLocation `
3838
-moniker $moniker
39-
39+
4040
$onboardedPackages = @{}
4141
$onboardingSpec = ConvertFrom-Json (Get-Content $packageOnboardingFile -Raw)
4242
foreach ($spec in $onboardingSpec.npm_package_sources) {
@@ -46,7 +46,7 @@ function Get-javascript-OnboardedDocsMsPackagesForMoniker($DocRepoLocation, $mon
4646
# Package has an '@' symbol deliminting the end of the package name
4747
$packageName = $packageName.Substring(0, $packageName.LastIndexOf('@'))
4848
}
49-
49+
5050
$jsStylePkgName = $packageName.Replace("@", "").Replace("/", "-")
5151
$jsonFile = "$DocRepoLocation/metadata/$moniker/$jsStylePkgName.json"
5252
if (Test-Path $jsonFile) {
@@ -66,11 +66,11 @@ function GetPackageReadmeName($packageMetadata) {
6666
if ($packageMetadata.PSObject.Members.Name -contains "FileMetadata") {
6767
$readmeMetadata = &$GetDocsMsMetadataForPackageFn -PackageInfo $packageMetadata.FileMetadata
6868

69-
# Packages released outside of our EngSys will have an empty string for
69+
# Packages released outside of our EngSys will have an empty string for
7070
# DirectoryPath which will result in an empty string for DocsMsReadMeName.
7171
# In those cases, do not return the empty name and instead use the fallback
7272
# logic below.
73-
if ($readmeMetadata.DocsMsReadMeName) {
73+
if ($readmeMetadata.DocsMsReadMeName) {
7474
return $readmeMetadata.DocsMsReadMeName
7575
}
7676
}
@@ -110,6 +110,8 @@ function Get-javascript-RepositoryLink ($packageInfo) {
110110
return "$PackageRepositoryUri/$($packageInfo.Package)"
111111
}
112112

113+
# Defined in common.ps1 as:
114+
# $UpdateDocsMsTocFn = "Get-${Language}-UpdatedDocsMsToc"
113115
function Get-javascript-UpdatedDocsMsToc($toc) {
114116
$services = $toc[0].items
115117
for ($i = 0; $i -lt $services.Count; $i++) {
@@ -135,6 +137,22 @@ function Get-javascript-UpdatedDocsMsToc($toc) {
135137
)
136138
}
137139
}
140+
141+
if ($services[$i].name -eq 'Cognitive Services') {
142+
# Add OpenAI to the ToC for Cognitive Services
143+
$services[$i].items += [PSCustomObject]@{
144+
name = "OpenAI";
145+
href = "~/docs-ref-services/{moniker}/openai-readme.md";
146+
}
147+
148+
# Sort the items in the Cognitive Services ToC so OpenAI ends up in the
149+
# correct place. The "Management" item should always be at the end of the
150+
# list.
151+
$management = $services[$i].items | Where-Object { $_.name -eq 'Management' }
152+
$sortedItems = $services[$i].items | Where-Object { $_.name -ne 'Management' } | Sort-Object -Property name
153+
154+
$services[$i].items = $sortedItems + $management
155+
}
138156
}
139157

140158
# PowerShell outputs a single object if the output is an array with only one

sdk/openai/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file.
2-
2+
33
trigger:
44
branches:
55
include:
@@ -27,3 +27,7 @@ extends:
2727
Artifacts:
2828
- name: azure-openai
2929
safeName: azureopenai
30+
# Disable publishing to learn.microsoft.com until support is added
31+
# to type2docfx tooling for this kind of package layout
32+
# https://github.com/Azure/azure-sdk-for-js/issues/31787
33+
skipPublishDocMs: true

0 commit comments

Comments
 (0)