Last active
April 10, 2020 19:21
-
-
Save scbedd/b1b507cfb7b81616b651843f51824fcd to your computer and use it in GitHub Desktop.
Copy Readmes To Docs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example Usage: ./copy_readmes.ps1 -CodeRepo C:/repo/sdk-for-python -DocRepo C:/repo/azure-docs-sdk-python | |
# Highly recommended that you use Powershell Core. | |
# git reset --hard origin/smoke-test on the doc repo prior to running this | |
param ( | |
[String]$CodeRepo, | |
[String]$DocRepo, | |
[String]$TargetServices = "keyvault,storage" | |
) | |
$PACKAGE_README_REGEX = ".*[\/\\]sdk[\\\/][^\/\\]+[\\\/][^\/\\]+[\/\\]README\.md" | |
if ($CodeRepo -Match "net") | |
{ | |
$TARGET_FOLDER = Join-Path -Path $DocRepo -ChildPath "api/overview/azure" | |
} | |
else { | |
$TARGET_FOLDER = Join-Path -Path $DocRepo -ChildPath "docs-ref-services" | |
} | |
$selectedServices = $TargetServices -Split "," | % { return $_.Trim() } | |
foreach($service in $selectedServices){ | |
$readmePath = Join-Path -Path $CodeRepo -ChildPath "sdk/$service" | |
Write-Host "Examining: $readmePath" | |
$readmeFiles = gci -r $readmePath/* -Include "*README.md" | ? { return $_.FullName -match $PACKAGE_README_REGEX -and !($_ -like "nspkg")} | |
foreach($file in $readmeFiles){ | |
Write-Host "`tOutputting $($file.FullName)" | |
$fileContent = Get-Content $file | |
$readmeName = "$($file.Directory.Name.Replace('azure-','').Replace('Azure.', '').ToLower())-readme.md" | |
$readmeOutputLocation = Join-Path $TARGET_FOLDER -ChildPath $readmeName | |
Set-Content -Path $readmeOutputLocation -Value $fileContent | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment