Scripts/Get-ExportSummary.ps1
<#
.SYNOPSIS Displays a summary of exported module data .DESCRIPTION Reads exported module JSON/Markdown/XML files and displays key statistics .PARAMETER FilePath Path to the exported file .EXAMPLE .\Get-ExportSummary.ps1 -FilePath ".\TestOutput\QuickTest.json" #> param( [Parameter(Mandatory = $false)] [string]$FilePath = ".\TestOutput\QuickTest.json" ) if (-not (Test-Path $FilePath)) { Write-Host "File not found: $FilePath" -ForegroundColor Red exit 1 } $extension = [System.IO.Path]::GetExtension($FilePath).ToLower() try { switch ($extension) { ".json" { $content = Get-Content $FilePath | Out-String | ConvertFrom-Json Write-Host "`n=== Module Export Summary ===" -ForegroundColor Cyan Write-Host "Module Name: $($content.ModuleName)" -ForegroundColor White Write-Host "Module Version: $($content.ModuleVersion)" -ForegroundColor White Write-Host "Generated On: $($content.GeneratedOn)" -ForegroundColor Gray Write-Host "Generated By: $($content.GeneratedBy)" -ForegroundColor Gray Write-Host "Total Commands: $($content.ExportedCommands)" -ForegroundColor Green if ($content.CommandTypes) { Write-Host "`nCommand Types:" -ForegroundColor Yellow $content.CommandTypes.PSObject.Properties | ForEach-Object { Write-Host " $($_.Name): $($_.Value)" -ForegroundColor Gray } } if ($content.Commands -and $content.Commands.Count -gt 0) { Write-Host "`nSample Commands (first 5):" -ForegroundColor Yellow $content.Commands | Select-Object -First 5 | ForEach-Object { Write-Host " - $($_.Name)" -ForegroundColor Gray if ($_.Synopsis -and $_.Synopsis -ne "No synopsis available") { $synopsis = $_.Synopsis if ($synopsis.Length -gt 60) { $synopsis = $synopsis.Substring(0, 57) + "..." } Write-Host " $synopsis" -ForegroundColor DarkGray } } # Statistics $withSynopsis = ($content.Commands | Where-Object { $_.Synopsis -and $_.Synopsis -ne "No synopsis available" }).Count $withDescription = ($content.Commands | Where-Object { $_.Description -and $_.Description -ne "No description available" }).Count $withExamples = ($content.Commands | Where-Object { $_.Examples -and $_.Examples.Count -gt 0 }).Count $withParameters = ($content.Commands | Where-Object { $_.Parameters -and $_.Parameters.Count -gt 0 }).Count $withErrors = ($content.Commands | Where-Object { $_.ProcessingError }).Count Write-Host "`nDocumentation Coverage:" -ForegroundColor Yellow Write-Host " Synopsis: $withSynopsis/$($content.Commands.Count) ($([Math]::Round($withSynopsis/$content.Commands.Count*100, 1))%)" -ForegroundColor Gray Write-Host " Description: $withDescription/$($content.Commands.Count) ($([Math]::Round($withDescription/$content.Commands.Count*100, 1))%)" -ForegroundColor Gray Write-Host " Examples: $withExamples/$($content.Commands.Count) ($([Math]::Round($withExamples/$content.Commands.Count*100, 1))%)" -ForegroundColor Gray Write-Host " Parameters: $withParameters/$($content.Commands.Count) ($([Math]::Round($withParameters/$content.Commands.Count*100, 1))%)" -ForegroundColor Gray if ($withErrors -gt 0) { Write-Host " Processing Errors: $withErrors" -ForegroundColor Red } } } ".xml" { $content = Import-Clixml $FilePath Write-Host "`n=== Module Export Summary (XML) ===" -ForegroundColor Cyan Write-Host "Module Name: $($content.ModuleName)" -ForegroundColor White Write-Host "Module Version: $($content.ModuleVersion)" -ForegroundColor White Write-Host "Total Commands: $($content.ExportedCommands)" -ForegroundColor Green } ".md" { $content = Get-Content $FilePath | Out-String $lines = $content -split "`n" $moduleName = if ($lines[0] -match "^# PowerShell Module: (.+)") { $matches[1] } else { "Unknown" } $commandCount = ([regex]::Matches($content, "^### ", "Multiline")).Count Write-Host "`n=== Module Export Summary (Markdown) ===" -ForegroundColor Cyan Write-Host "Module Name: $moduleName" -ForegroundColor White Write-Host "Commands Found: $commandCount" -ForegroundColor Green Write-Host "File Size: $([Math]::Round((Get-Item $FilePath).Length / 1KB, 2)) KB" -ForegroundColor Gray } default { Write-Host "Unsupported file type: $extension" -ForegroundColor Red } } # Show file info $fileInfo = Get-Item $FilePath Write-Host "`nFile Information:" -ForegroundColor Yellow Write-Host " Path: $($fileInfo.FullName)" -ForegroundColor Gray Write-Host " Size: $([Math]::Round($fileInfo.Length / 1KB, 2)) KB" -ForegroundColor Gray Write-Host " Modified: $($fileInfo.LastWriteTime)" -ForegroundColor Gray } catch { Write-Host "Error reading file: $_" -ForegroundColor Red } |