Skip to content

Commit 779a3b0

Browse files
Do not append template if parameter description exists (#783)
1 parent 1c753d3 commit 779a3b0

File tree

4 files changed

+833
-3
lines changed

4 files changed

+833
-3
lines changed

src/Common/MergeUtils.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,15 @@ internal static bool TryGetMergedParameters(List<Parameter>fromHelp, List<Parame
246246

247247
var description = helpParam.Description;
248248

249+
var templateDescription = string.Format(Constants.FillInParameterDescriptionTemplate, helpParam.Name);
250+
249251
if (string.Equals(helpParam.Description, checkTemplate, StringComparison.OrdinalIgnoreCase))
250252
{
251253
diagnosticMessages.Add(new DiagnosticMessage(DiagnosticMessageSource.Merge, $"Parameter {pName} has no description in the help.", DiagnosticSeverity.Warning, "TryGetMergedParameters", -1));
252254
description = cmdParam.Description;
253255
}
254-
else if (!string.Equals(helpParam.Description, cmdParam.Description, StringComparison.OrdinalIgnoreCase))
256+
else if (!string.Equals(cmdParam.Description, templateDescription, StringComparison.OrdinalIgnoreCase)
257+
&& !string.Equals(helpParam.Description, cmdParam.Description, StringComparison.OrdinalIgnoreCase))
255258
{
256259
diagnosticMessages.Add(new DiagnosticMessage(DiagnosticMessageSource.Merge, $"Parameter {pName} has the different description in the help and the command. Concatinating.", DiagnosticSeverity.Information, "TryGetMergedParameters", -1));
257260
description = string.Join(Environment.NewLine, helpParam.Description, cmdParam.Description);

test/Pester/MeasurePlatyPSMarkdown.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Describe "Export-MarkdownModuleFile" {
1313

1414
It "Should identify all the '<fileType>' assets" -TestCases @(
1515
@{ fileType = "unknown"; expectedCount = 2 }
16-
@{ fileType = "CommandHelp"; expectedCount = 41 }
16+
@{ fileType = "CommandHelp"; expectedCount = 42 }
1717
@{ fileType = "ModuleFile"; expectedCount = 16 }
18-
@{ fileType = "V1Schema"; expectedCount = 52 }
18+
@{ fileType = "V1Schema"; expectedCount = 53 }
1919
@{ fileType = "V2Schema"; expectedCount = 5 }
2020
) {
2121
param ($fileType, $expectedCount)

test/Pester/UpdateCommandHelp.Tests.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ Describe "Tests for Update-CommandHelp" {
8989
$ch.AliasHeaderFound | Should -Be $true
9090
}
9191

92+
It "Should not append parameter descriptions with boiler plate if description is not boilerplate" {
93+
$ch = Update-CommandHelp -Path ([io.path]::Combine($PSScriptRoot, "assets", "Export-Csv.md"))
94+
$ch.Parameters.Where({$_.Name -eq "LiteralPath"}).Description | Should -Not -BeLike "*{{ Fill LiteralPath Description }}*"
95+
}
96+
9297
Context "Parameter attribute updates" {
9398
BeforeAll {
9499
function test-update {

0 commit comments

Comments
 (0)