#Import System.Web in order to use HtmlEncode functionality [System.Reflection.Assembly]::LoadWithPartialName("System.Web") | out-null function encode($str) { [System.web.httputility]::HtmlEncode($str).Trim() } function New-HtmlHelp { param($commands = $null, $outputDir = "./help", $title = "") $commandsHelp = $commands | sort-object name | get-help -full #create an output directory md $outputDir | Out-Null cp doc-style.css $outputDir #Generate frame page $frameFileName = $outputDir + "/index.html" "$title" | out-file -encoding ascii $frameFileName #Generate index $indexFileName = $outputDir + "/left-frame.html" $indexData = "" foreach ($c in $commandsHelp) { $name = encode($c.Name) $indexData += "$name
" } $indexData += "" $indexData | out-file -encoding ascii $indexFileName #Generate all single help files $outputText = $null foreach ($c in $commandsHelp) { $fileName = ( $outputDir + "/" + $c.Name + ".html" ) $data = "$(encode($c.Name))" # Name $data += "

$(encode($c.Name))

" # Synopsis $data += "

Synopsis

$(encode($c.synopsis))" # Syntax $data += "

Syntax

$(encode(&{$c.syntax | out-string -width 2000}))" # Related Commands $data += "

Related Commands

" foreach ($relatedLink in $c.relatedLinks.navigationLink) { if($relatedLink.linkText -ne $null -and $relatedLink.linkText.StartsWith("about") -eq $false){ $uri = "" if( $relatedLink.uri -ne "" ) { $uri = $relatedLink.uri } else{ $uri = $relatedLink.linkText } $data += "$(encode($relatedLink.linkText))
" } } # Detailed Description $data += "

Detailed Description

$(encode(&{$c.Description | out-string -width 2000}))" # Parameters $data += "

Parameters

" + "" + "" $paramNum = 0 $c.parameters.parameter | %{ $param = $_ $data += "" $data += "" $data += "" $data += "" } $data += "
NameDescriptionRequired?Pipeline InputDefault Value
$(encode($param.Name))$(encode(&{$param.Description | out-string -width 2000}))$(encode($param.Required))$(encode($param.PipelineInput))$(encode($param.DefaultValue))
" # Input Type $data += "

Input Type

$(encode(&{$c.inputTypes | out-string -width 2000}))" # Return Type $data += "

Return Type

$(encode(&{$c.returnValues | out-string -width 2000}))" # Notes $data += "

Notes

$(encode(&{$c.alertSet | out-string}))
" # Examples $data += "

Examples

$(encode(&{$c.Examples | out-string -width 80}))
" $data += "" $data | out-file -encoding ascii $fileName } }