Create more helpful version of docs update script (#107)
authorE.Z. Hart <hartez@users.noreply.github.com>
Tue, 19 Apr 2016 06:58:16 +0000 (00:58 -0600)
committerJason Smith <jason.smith@xamarin.com>
Tue, 19 Apr 2016 06:58:16 +0000 (23:58 -0700)
update-docs.ps1 [new file with mode: 0644]

diff --git a/update-docs.ps1 b/update-docs.ps1
new file mode 100644 (file)
index 0000000..86b3eb8
--- /dev/null
@@ -0,0 +1,79 @@
+param(
+    [Parameter(Position = 0)]
+    [String]$MdocPath = ".\tools\mdoc\mdoc.exe",
+    [Parameter(Position = 1)]
+    [String]$ProfilePath = "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile259"
+)
+
+function Update
+{
+    param
+    ( 
+        [string]$dllPath, 
+        [string]$docsPath
+    )
+    
+    Write-Host "Updating docs for $dllPath ..."
+    & $MdocPath update --delete $dllPath -L $ProfilePath --out $docsPath
+}
+
+function ParseChanges
+{
+    param
+    ( 
+        [string]$dllPath, 
+        [string]$docsPath,
+        [string[]]$changes
+    )
+
+    $suggestedCommands = @()
+
+    $changes | % {$n=0} { 
+        if($changes[$n+1] -match "Member Added:" -or $changes[$n+1] -match "Member Removed:"){
+        
+            if($changes[$n] -match "^Updating: (.*)"){
+                $modified = "$($docsPath.Replace("\", "/"))/$(ClassToXMLPath($matches[1]))"
+                Write-Host "$modified was modified"
+                $suggestedCommands += "git add $modified"
+            }
+
+        } 
+        $n = $n + 1
+    }
+
+    if($suggestedCommands.Length -gt 0) {
+        Write-Host "Suggested git commands:"
+        $suggestedCommands | % { Write-Host $_ }
+    } else {
+        Write-Host "No actual docs changes were made."
+    }
+}
+
+function ClassToXMLPath
+{
+    param( [string]$class )
+    $lastDot = $class.LastIndexOf(".")
+    return $class.Substring(0, $lastDot) + "/" + $class.Substring($lastDot + 1, $class.Length - $lastDot - 1) + ".xml"
+}
+
+# Core
+$dllPath = "Xamarin.Forms.Core\bin\Debug\Xamarin.Forms.Core.dll"
+$docsPath = "docs\Xamarin.Forms.Core"
+$changes = Update $dllPath $docsPath
+ParseChanges $dllPath $docsPath $changes
+
+Write-Host
+
+# Xaml
+$dllPath = "Xamarin.Forms.Xaml\bin\Debug\Xamarin.Forms.Xaml.dll"
+$docsPath = "docs\Xamarin.Forms.Xaml"
+$changes = Update $dllPath $docsPath
+ParseChanges $dllPath $docsPath $changes
+
+Write-Host
+
+# Maps
+$dllPath = "Xamarin.Forms.Maps\bin\Debug\Xamarin.Forms.Maps.dll"
+$docsPath = "docs\Xamarin.Forms.Maps"
+$changes = Update $dllPath $docsPath
+ParseChanges $dllPath $docsPath $changes
\ No newline at end of file