|
30 | 30 | 1.0.0 - Initial release |
31 | 31 | 1.0.1 - Updated for ModuleBuild |
32 | 32 | 1.0.2 - Added SuppressMessageAttribute |
| 33 | + 1.0.3 - Extra Verbose message to check if function had Params |
33 | 34 | #> |
34 | 35 | [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "ScriptText",Scope="Function",Target="New-CommentBasedHelp",Justification="Seems it's here since duo a copy paste from other functions (Add-MissingCBH,Get-Function,Get-FunctionParameter). Leaving it here since it doesn't do any harm.")] |
35 | 36 | [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions","",Scope="Function",Target="New-CommentBasedHelp",Justification="Function does not change system state. Simply outputs a obj with CommentBasedHelp.")] |
|
76 | 77 | } |
77 | 78 | $AllParams = Get-FunctionParameter @FuncParams -Code $Codeblock | Sort-Object -Property FunctionName |
78 | 79 | $AllFunctions = @($AllParams.FunctionName | Select-Object -unique) |
| 80 | + If([string]::IsNullOrEmpty($AllFunctions)) |
| 81 | + { |
| 82 | + Write-Verbose "$($FunctionName): Found no Params in function." |
| 83 | + } else |
| 84 | + { |
| 85 | + foreach ($f in $AllFunctions) { |
| 86 | + $OutCBH = @{} |
| 87 | + $OutCBH.FunctionName = $f |
| 88 | + [string]$OutParams = '' |
| 89 | + $fparams = @($AllParams | Where-Object {$_.FunctionName -eq $f} | Sort-Object -Property Position) |
| 90 | + if ($fparams.count -gt 0) { |
| 91 | + $fparams | ForEach-Object { |
| 92 | + $ParamHelpMessage = if ([string]::IsNullOrEmpty($_.HelpMessage)) { $_.ParameterName + " explanation`n`r`n`r"} else {$_.HelpMessage + "`n`r`n`r"} |
79 | 93 |
|
80 | | - foreach ($f in $AllFunctions) { |
81 | | - $OutCBH = @{} |
82 | | - $OutCBH.FunctionName = $f |
83 | | - [string]$OutParams = '' |
84 | | - $fparams = @($AllParams | Where-Object {$_.FunctionName -eq $f} | Sort-Object -Property Position) |
85 | | - if ($fparams.count -gt 0) { |
86 | | - $fparams | ForEach-Object { |
87 | | - $ParamHelpMessage = if ([string]::IsNullOrEmpty($_.HelpMessage)) { $_.ParameterName + " explanation`n`r`n`r"} else {$_.HelpMessage + "`n`r`n`r"} |
88 | | - |
89 | | - $OutParams += $CBH_PARAM -replace '%%PARAM%%',$_.ParameterName -replace '%%PARAMHELP%%',$ParamHelpMessage |
| 94 | + $OutParams += $CBH_PARAM -replace '%%PARAM%%',$_.ParameterName -replace '%%PARAMHELP%%',$ParamHelpMessage |
| 95 | + } |
90 | 96 | } |
91 | | - } |
92 | | - else { |
| 97 | + else { |
93 | 98 |
|
94 | | - } |
| 99 | + } |
95 | 100 |
|
96 | | - $OutCBH.'CBH' = $CBHTemplate -replace '%%PARAMETER%%',$OutParams |
| 101 | + $OutCBH.'CBH' = $CBHTemplate -replace '%%PARAMETER%%',$OutParams |
97 | 102 |
|
98 | | - New-Object PSObject -Property $OutCBH |
| 103 | + New-Object PSObject -Property $OutCBH |
| 104 | + } |
99 | 105 | } |
100 | 106 |
|
101 | 107 | Write-Verbose "$($FunctionName): End." |
|
0 commit comments