Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions Public/Convert-HelpToMarkdown.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#
<#
.Synopsis
Formats cmdlet help as MarkDown
.Example
Expand Down Expand Up @@ -113,9 +113,22 @@ function Convert-HelpToMarkDown
# Description
if ($HelpInfo.Description)
{
$DescriptionParts = $HelpInfo.Description.Text -split 'DYNAMIC PARAMETERS'
Write-Output '### Description'
Write-Output ($HelpInfo.Description | Out-String -Width 1200).Trim()
Write-Output ( $DescriptionParts[0] | Out-String -Width 1200).Trim()
Write-Output ''
if ($DescriptionParts[1])
{
Write-Output '### Dynamic Parameters'
$DynParamText = $DescriptionParts[1] # | Out-String -Width 1200
#Write-Debug $ParameterText
$DynParamText = $DynParamText -replace '^\s*-', '#### '
$DynParamText = $DynParamText.Trim()
$DynParamText = [System.Web.HttpUtility]::HtmlEncode($DynParamText)

Write-Output $($DynParamText)
Write-Output ''
}
}

# Syntax
Expand All @@ -124,15 +137,27 @@ function Convert-HelpToMarkDown
Write-Output ($Command | Get-Command -Syntax).Trim()
Write-Output ``````

# Input Types
if ($HelpInfo.InputTypes)
{
Write-Output '### Input Type(s)'
Write-Output ''

foreach ($InputType in $HelpInfo.InputTypes)
{
Write-Output "- $($InputType.InputType.Type.Name)"
}
}

# Output Types
if ($Command.OutputType)
if ($HelpInfo.ReturnValues)
{
Write-Output '### Output Type(s)'
Write-Output ''

foreach ($OutputType in $Command.OutputType)
foreach ($OutputType in $HelpInfo.ReturnValues)
{
Write-Output "- $($OutputType.Name)"
Write-Output "- $($OutputType.ReturnValue.Type.Name)"
}

Write-Output ''
Expand Down Expand Up @@ -192,4 +217,4 @@ function Convert-HelpToMarkDown

Write-Output "<div style='font-size:small; color: #ccc'>Generated $(Get-Date -Format 'dd-MM-yyyy HH:mm')</div>"
}
}
}