public/Write-CmdletSynopsis.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

function Write-CmdletSynopsis() {
    Param(
        [Parameter(Position = 0)]
        [PsCustomObject] $Model,

        [Parameter(Position = 1)]
        [String] $Template
    )

    
    #Syntax & Synopsis are confusing
    $synopsis = $Model.Synopsis
    $name = $Model.Name.Trim()
    if($synopsis -is [string]) {
        if([String]::IsNullOrWhiteSpace($Template)){
            $Template = "`n## Synopsis`n`n{0}`n"
        }
        $synopsis = ($synopsis | Out-String).Trim() 
        
        return [String]::Format($Template, (Write-EscapedMarkdownString $synopsis))
    }

    return "";
}