# Compile-Help.ps1 # by Jeff Hillman # # this script uses the text and XML PowerShell help files to generate HTML help # for all PowerShell Cmdlets, PSProviders, and "about" topics. the help topics # are compiled into a .chm file using HTML Help Workshop. param( [string] $outDirectory = ".\PSHelp", [switch] $GroupByPSSnapIn ) function Html-Encode( [string] $value ) { # System.Web.HttpUtility.HtmlEncode() doesn't quite get everything, and # I don't want to load the System.Web assembly just for this. I'm sure # I missed something here, but these are the characters I saw that needed # to be encoded most often $value = $value -replace "&(?![\w#]+;)", "&" $value = $value -replace "<(?!!--)", "<" $value = $value -replace "(? "@ $helpHash.Keys | Sort-Object | Foreach-Object { switch -regex ( $_ ) { # about topic "about_" { "Creating help for the $_ about topic..." Write-AboutTopic $_ $helpHash[ $_ ] } # Verb-Noun: Cmdlet "\w+-\w+" { "Creating help for the $( $_ -replace '(^\w+-\w+).*', '$1' ) Cmdlet..." Write-CmdletTopic $_ $helpHash[ $_ ] } # PSProvider default { "Creating help for the $( $_ -replace '(^\w+).*', '$1' ) PSProvider..." Write-ProviderTopic $_ $helpHash[ $_ ] } } } Write-DefaultPage Write-Css Write-Hhp if ( Test-Path "C:\Program Files\HTML Help Workshop\hhc.exe" ) { # compile the help "`nCompiling the help manual...`n" Push-Location Set-Location $outDirectory & "C:\Program Files\HTML Help Workshop\hhc.exe" powershell.hhp Pop-Location # open the help file & "$outDirectory\PowerShell.chm" } else { Write-Host -ForegroundColor Red @" HTML Help Workshop is not installed, or it was not installed in its default location of "C:\Program Files\HTML Help Workshop". HTML Help Workshop is required to compile the help manual. It can be downloaded free of charge from Microsoft: http://www.microsoft.com/downloads/details.aspx?familyid=00535334-c8a6-452f-9aa0-d597d16580cc&displaylang=en If you do not want to install HTML Help Workshop on this machine, all of the files necessary to compile the manual have been created here: $( Resolve-Path $outDirectory ) Copy these files to a machine with HTML Help Workshop, and you can compile the manual there, with the following command: \hhc.exe powershell.hhp "@ }