src/Private/Get-TaskDescription.ps1

<#
.SYNOPSIS
    Converts task declaration comments into description text.
#>

function Get-TaskDescription {
    [CmdletBinding()]
    [OutputType([string])]
    param(
        [Parameter(Mandatory)]
        [AllowEmptyCollection()]
        [string[]] $Comments
    )

    $DescriptionParts = foreach ($Comment in $Comments) {
        if ($Comment.StartsWith('<#') -and $Comment.EndsWith('#>')) {
            $Comment.Substring(2, $Comment.Length - 4).Trim()
        } else {
            ($Comment -replace '^# ?', '').TrimEnd()
        }
    }

    $Description = ($DescriptionParts -join [Environment]::NewLine).Trim()
    if ([string]::IsNullOrWhiteSpace($Description)) {
        return
    }

    return $Description
}