-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
Generate-DocIndex.ps1
144 lines (129 loc) · 7.02 KB
/
Generate-DocIndex.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Generates an index page for cataloging different versions of the Docs
[CmdletBinding()]
Param (
$RepoRoot,
$DocGenDir
)
$ServiceMapping = @{
"advisor"="Advisor";
"alertsmanagement"="Alerts Management"; "analysisservices"="Analysis Services";
"apimanagement"="API Management"; "appconfiguration"="App Configuration";
"applicationinsights"="Application Insights"; "appplatform"="App Service";
"attestation"="Attestation"; "authorization"="Authorization";
"automation"="Automation"; "azurestack"="Azure Stack";
"batch"="Batch"; "batchai"="Batch AI";
"billing"="Billing"; "blueprint"="Blueprint";
"botservice"="Bot Service"; "cdn"="CDN";
"cognitiveservices"="Cognitive Services"; "compute"="Compute";
"consumption"="Consumption"; "containerinstance"="Container Instance";
"containerregistry"="Container Registry"; "containerservice"="Container Service";
"core"="Core"; "cost-management"="Cost Management";
"customer-insights"="Customer Insights"; "customproviders"="Custom Providers";
"databox"="Data Box"; "databoxedge"="Data Box Edge";
"datafactory"="Data Factory"; "datalake-analytics"="Data Lake Analytics";
"datalake-store"="Data Lake Store"; "datamigration"="Data Migration";
"datashare"="Data Share"; "deploymentmanager"="Deployment Manager";
"deviceprovisioningservices"="Device Provisioning Services"; "devspaces"="Dev Spaces";
"Dev Test Labs"=""; "dns"="DNS";
"edgegateway"="Edge Gateway";
"eventgrid"="Event Grid"; "eventhub"="Event Hub";
"frontdoor"="Front Door"; "graphrbac"="Active Directory";
"guestconfiguration"="Guest Configuration"; "hdinsight"="HDInsight";
"healthcareapis"="Healthcare APIs"; "hybridcompute"="Hybrid Cloud";
"hybriddatamanager"="Hybrid Datamanager"; "identity"="Identity";
"insights"="Insights"; "iotcentral"="IoT Central";
"iothub"="IoT"; "keyvault"="Keyvault";
"kusto"="Kusto"; "labservices"="LabServices";
"locationbasedservices"="Location Based Services"; "logic"="Logic Apps";
"machinelearning"="Machine Learning"; "machinelearningcompute"="Machine Learning Compute";
"maintenance"="Maintenance"; "managednetwork"="Managed Network";
"managedserviceidentity"="Managed Service Identity"; "managedservices"="Managed Services";
"managementgroups"="Management Groups"; "managementpartner"="Management Partner";
"maps"="Maps"; "marketplaceordering"="Market Place Ordering";
"mediaservices"="Media Services";
"mixedreality"="Mixed Reality"; "monitor"="Monitor";
"netapp"="NetApp"; "network"="Network";
"notificationhubs"="Notification Hubs"; "operationalinsights"="Operational Insights";
"peering"="Peering"; "policyinsights"="Policy Insights";
"postgresql"="PostgreSQL"; "powerbidedicated"="PowerBI Dedicated";
"privatedns"="Private DNS"; "recoveryservices"="Recovery Services";
"recoveryservices-backup"="Recovery Services Backup"; "recoveryservices-siterecovery"="Recovery Services Site Recovery";
"redis"="Redis"; "relay"="Relay";
"reservations"="Reservations"; "resourcegraph"="Resource Graph";
"resources"="Resources"; "scheduler"="Scheduler";
"search"="Search"; "securitycenter"="Security Center";
"servermanagement"="Server Management"; "servicebus"="Service Bus";
"servicefabric"="Service Fabric"; "signalr"="signalR";
"sqlmanagement"="SQL Management"; "sqlvirtualmachine"="SQL Virtual Machine";
"storage"="Storage"; "storagecache"="Storage Cache";
"storagesync"="Storage Sync"; "storsimple"="Stor Simple";
"storsimple8000series"="Stor Simple 8000 series"; "streamanalytics"="Stream Analytics";
"subscription"="Subscription"; "textanalytics"="Text Analytics";
"trafficmanager"="Traffic Manager"; "websites"="Websites";
}
Write-Verbose "Name Reccuring paths with variable names"
$DocFxTool = "${RepoRoot}/docfx/docfx.exe"
$DocOutDir = "${RepoRoot}/docfx_project"
Write-Verbose "Initializing Default DocFx Site..."
& "${DocFxTool}" init -q -o "${DocOutDir}"
Write-Verbose "Copying template and configuration..."
New-Item -Path "${DocOutDir}" -Name "templates" -ItemType "directory"
Copy-Item "${DocGenDir}/templates/*" -Destination "${DocOutDir}/templates" -Force -Recurse
Copy-Item "${DocGenDir}/docfx.json" -Destination "${DocOutDir}/" -Force
Write-Verbose "Creating Index using service directory and package names from repo..."
$ServiceList = Get-ChildItem "$($RepoRoot)/sdk" -Directory -Exclude eng, mgmtcommon, template | Sort-Object
$YmlPath = "${DocOutDir}/api"
New-Item -Path $YmlPath -Name "toc.yml" -Force
Write-Verbose "Creating Index for client packages..."
foreach ($Dir in $ServiceList)
{
New-Item -Path $YmlPath -Name "$($Dir.Name).md" -Force
$ServiceName = If ($ServiceMapping.Contains($Dir.Name)) { $ServiceMapping[$Dir.Name] } Else { $Dir.Name }
Add-Content -Path "$($YmlPath)/toc.yml" -Value "- name: $($ServiceName)`r`n href: $($Dir.Name).md"
$PkgList = Get-ChildItem $Dir.FullName -Directory -Exclude .vs, .vscode, Azure.Security.KeyVault.Shared | Where-Object -FilterScript {$_.Name -notmatch ".Management."}
if (($PkgList | Measure-Object).count -eq 0)
{
continue
}
Add-Content -Path "$($YmlPath)/$($Dir.Name).md" -Value "# Client"
Add-Content -Path "$($YmlPath)/$($Dir.Name).md" -Value "---"
Write-Verbose "Operating on Client Packages for $($Dir.Name)"
foreach ($Pkg in $PkgList)
{
if (Test-Path "$($pkg.FullName)\src")
{
$ProjectName = Get-ChildItem "$($pkg.FullName)\src\*" -Include *.csproj
Add-Content -Path "$($YmlPath)/$($Dir.Name).md" -Value "#### $($ProjectName.BaseName)"
}
}
}
Write-Verbose "Creating Index for management packages..."
foreach ($Dir in $ServiceList)
{
$PkgList = Get-ChildItem $Dir.FullName -Directory | Where-Object -FilterScript {$_.Name -match ".Management."}
if (($PkgList | Measure-Object).count -eq 0)
{
continue
}
Add-Content -Path "$($YmlPath)/$($Dir.Name).md" -Value "# Management"
Add-Content -Path "$($YmlPath)/$($Dir.Name).md" -Value "---"
Write-Verbose "Operating on Management Packages for $($Dir.Name)"
foreach ($Pkg in $PkgList)
{
if (Test-Path "$($pkg.FullName)\src")
{
$ProjectName = Get-ChildItem "$($pkg.FullName)\src\*" -Include *.csproj
Add-Content -Path "$($YmlPath)/$($Dir.Name).md" -Value "#### $($ProjectName.BaseName)"
}
}
}
Write-Verbose "Creating Site Title and Navigation..."
New-Item -Path "${DocOutDir}" -Name "toc.yml" -Force
Add-Content -Path "${DocOutDir}/toc.yml" -Value "- name: Azure SDK for NET APIs`r`n href: api/`r`n homepage: api/index.md"
Write-Verbose "Copying root markdowns"
Copy-Item "$($RepoRoot)/README.md" -Destination "${DocOutDir}/api/index.md" -Force
Copy-Item "$($RepoRoot)/CONTRIBUTING.md" -Destination "${DocOutDir}/api/CONTRIBUTING.md" -Force
Write-Verbose "Building site..."
& "${DocFxTool}" build "${DocOutDir}/docfx.json"
Copy-Item "${DocGenDir}/assets/logo.svg" -Destination "${DocOutDir}/_site/" -Force
Copy-Item "${DocGenDir}/assets/toc.yml" -Destination "${DocOutDir}/_site/" -Force