Skip to content

Commit 4e4d430

Browse files
authored
Onboarding v2 (Azure#31457)
* Onboarding v2 * docindex changes to test v2 onboarding * azure-mgmt-mixedreality is properly onboarded to ToC via metadata/preview/azure-mgmt-mixedreality * Remove the rest of the function * Add changes in eng/common * DocRepoLocation * Include package source override in eng/common * Revert eng/common changes, use intended docindex.yml * Revert "Revert eng/common changes, use intended docindex.yml" This reverts commit 4b37573. * Use . accessor instead of dictionary accessor. Works well for both dictionary and pscustomobject * Remove eng/common changes used for testing * Remove testing changes from docindex.yml * Remvoe comment * Use Update-DocsMsPackages.ps1
1 parent a794256 commit 4e4d430

File tree

3 files changed

+86
-35
lines changed

3 files changed

+86
-35
lines changed

eng/scripts/Language-Settings.ps1

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ $GithubUri = "https://github.com/Azure/azure-sdk-for-python"
88
$PackageRepositoryUri = "https://pypi.org/project"
99

1010
."$PSScriptRoot/docs/Docs-ToC.ps1"
11+
."$PSScriptRoot/docs/Docs-Onboarding.ps1"
1112

1213
function Get-AllPackageInfoFromRepo ($serviceDirectory)
1314
{
@@ -487,8 +488,7 @@ function UpdateDocsMsPackages($DocConfigFile, $Mode, $DocsMetadata, $PackageSour
487488
};
488489
exclude_path = @("test*","example*","sample*","doc*");
489490
}
490-
}
491-
else {
491+
} else {
492492
$package = [ordered]@{
493493
package_info = [ordered]@{
494494
name = $packageName;
@@ -612,10 +612,15 @@ function Validate-Python-DocMsPackages ($PackageInfo, $PackageInfos, $PackageSou
612612
}
613613

614614
$allSucceeded = $true
615-
foreach ($package in $PackageInfos) {
615+
foreach ($item in $PackageInfos) {
616+
# Some packages
617+
if ($item.Version -eq 'IGNORE') {
618+
continue
619+
}
620+
616621
$result = ValidatePackage `
617-
-packageName $package.Name `
618-
-packageVersion $package.Version `
622+
-packageName $item.Name `
623+
-packageVersion "==$($item.Version)" `
619624
-PackageSourceOverride $PackageSourceOverride `
620625
-DocValidationImageId $DocValidationImageId
621626

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
. "$PSScriptRoot/Docs-ToC.ps1"
2+
3+
# $SetDocsPackageOnboarding = "Set-${Language}-DocsPackageOnboarding"
4+
function Set-python-DocsPackageOnboarding($moniker, $metadata, $docRepoLocation, $packageSourceOverride) {
5+
$onboardingFile = GetOnboardingFileForMoniker $docRepoLocation $moniker
6+
7+
$onboardingSpec = Get-Content $onboardingFile -Raw | ConvertFrom-Json -AsHashtable
8+
9+
$packagesToOnboard = @()
10+
foreach ($package in $metadata) {
11+
$packageSpec = [ordered]@{
12+
package_info = [ordered]@{
13+
name = $package.Name
14+
install_type = 'pypi'
15+
prefer_source_distribution = 'true'
16+
version = "==$($package.Version)"
17+
}
18+
exclude_path = @("test*","example*","sample*","doc*")
19+
}
20+
21+
if ($packageSourceOverride) {
22+
$packageSpec['package_info']['extra_index_url'] = $packageSourceOverride
23+
}
24+
25+
if ($package.ContainsKey('DocsCiConfigProperties')) {
26+
$overrides = $package['DocsCiConfigProperties']
27+
28+
# Merge properties from package_info object (duplicate values will)
29+
# be overwritten
30+
if ($overrides.ContainsKey('package_info')) {
31+
foreach ($key in $overrides['package_info'].Keys) {
32+
$packageSpec['package_info'][$key] = $overrides['package_info'][$key]
33+
}
34+
}
35+
36+
# Directly override other keys like exlcude_path
37+
foreach ($key in $overrides.Keys) {
38+
if ($key -in @('package_info')) {
39+
# Skip over keys that have already been processed
40+
continue
41+
}
42+
43+
$packageSpec[$key] = $overrides[$key]
44+
}
45+
}
46+
47+
$packagesToOnboard += $packageSpec
48+
}
49+
50+
$onboardingSpec['packages'] = $packagesToOnboard
51+
52+
Set-Content `
53+
-Path $onboardingFile `
54+
-Value ($onboardingSpec | ConvertTo-Json -Depth 100)
55+
}
56+
57+
# $GetDocsPackagesAlreadyOnboarded = "Get-${Language}-DocsPackagesAlreadyOnboarded"
58+
function Get-python-DocsPackagesAlreadyOnboarded($docRepoLocation, $moniker) {
59+
return &$GetOnboardedDocsMsPackagesForMonikerFn `
60+
-DocRepoLocation $docRepoLocation `
61+
-moniker $moniker
62+
}

eng/scripts/docs/Docs-ToC.ps1

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
function Get-python-OnboardedDocsMsPackagesForMoniker($DocRepoLocation, $moniker) {
2-
$packageOnboardingFile = ""
3-
if ("latest" -eq $moniker) {
4-
$packageOnboardingFile = "$DocRepoLocation/ci-configs/packages-latest.json"
5-
}
6-
if ("preview" -eq $moniker) {
7-
$packageOnboardingFile = "$DocRepoLocation/ci-configs/packages-preview.json"
1+
function GetOnboardingFileForMoniker($docRepoLocation, $moniker) {
2+
$packageOnboardingFile = 'ci-configs/packages-latest.json'
3+
if ($moniker -eq 'preview') {
4+
$packageOnboardingFile = 'ci-configs/packages-preview.json'
5+
} elseif ($moniker -eq 'legacy') {
6+
$packageOnboardingFile = 'ci-configs/packages-legacy.json'
87
}
98

9+
return (Join-Path $docRepoLocation $packageOnboardingFile)
10+
}
11+
12+
function Get-python-OnboardedDocsMsPackagesForMoniker($DocRepoLocation, $moniker) {
13+
$packageOnboardingFile = GetOnboardingFileForMoniker `
14+
-docRepoLocation $DocRepoLocation `
15+
-moniker $moniker
16+
1017
$onboardedPackages = @{}
1118
$onboardingSpec = ConvertFrom-Json (Get-Content $packageOnboardingFile -Raw)
1219
foreach ($spec in $onboardingSpec.packages) {
@@ -85,23 +92,6 @@ function Get-python-DocsMsTocChildrenForManagementPackages($packageMetadata, $do
8592
return @($packageMetadata.Package)
8693
}
8794

88-
function addManagementPackage($serviceEntry, $packageName) {
89-
for ($i = 0; $i -lt $serviceEntry.items.Count; $i++) {
90-
if ($serviceEntry.items[$i].name -eq "Management") {
91-
$serviceEntry.items[$i].children += @($packageName)
92-
return $serviceEntry
93-
}
94-
}
95-
96-
$serviceEntry.items += [PSCustomObject]@{
97-
name = "Management";
98-
landingPageType = 'Service';
99-
children = @($packageName)
100-
}
101-
102-
return $serviceEntry
103-
}
104-
10595
function Get-python-RepositoryLink($packageInfo) {
10696
return "$PackageRepositoryUri/$($packageInfo.Package)"
10797
}
@@ -118,12 +108,6 @@ function Get-python-UpdatedDocsMsToc($toc) {
118108
children = @("adal")
119109
}
120110
}
121-
122-
# azure-mgmt-mixedreality is not onboarded in an obvious manner, it is
123-
# onboarded using a URL to a specific dist.
124-
if ($services[$i].name -eq 'Mixed Reality') {
125-
$services[$i] = addManagementPackage $services[$i] 'azure-mgmt-mixedreality'
126-
}
127111
}
128112

129113
$functionService = [PSCustomObject]@{

0 commit comments

Comments
 (0)