Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 4 additions & 1 deletion src/Common/MergeUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,15 @@ internal static bool TryGetMergedParameters(List<Parameter>fromHelp, List<Parame

var description = helpParam.Description;

var templateDescription = string.Format(Constants.FillInParameterDescriptionTemplate, helpParam.Name);

if (string.Equals(helpParam.Description, checkTemplate, StringComparison.OrdinalIgnoreCase))
{
diagnosticMessages.Add(new DiagnosticMessage(DiagnosticMessageSource.Merge, $"Parameter {pName} has no description in the help.", DiagnosticSeverity.Warning, "TryGetMergedParameters", -1));
description = cmdParam.Description;
}
else if (!string.Equals(helpParam.Description, cmdParam.Description, StringComparison.OrdinalIgnoreCase))
else if (!string.Equals(cmdParam.Description, templateDescription, StringComparison.OrdinalIgnoreCase)
&& !string.Equals(helpParam.Description, cmdParam.Description, StringComparison.OrdinalIgnoreCase))
{
diagnosticMessages.Add(new DiagnosticMessage(DiagnosticMessageSource.Merge, $"Parameter {pName} has the different description in the help and the command. Concatinating.", DiagnosticSeverity.Information, "TryGetMergedParameters", -1));
description = string.Join(Environment.NewLine, helpParam.Description, cmdParam.Description);
Expand Down
5 changes: 5 additions & 0 deletions test/Pester/UpdateCommandHelp.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ Describe "Tests for Update-CommandHelp" {
$ch.AliasHeaderFound | Should -Be $true
}

It "Should not append parameter descriptions with boiler plate if description is not boilerplate" {
$ch = Update-CommandHelp -Path ([io.path]::Combine($PSScriptRoot, "assets", "Export-Csv.md"))
$ch.Parameters.Where({$_.Name -eq "LiteralPath"}).Description | Should -Not -BeLike "*{{ Fill LiteralPath Description }}*"
}

Context "Parameter attribute updates" {
BeforeAll {
function test-update {
Expand Down
Loading
Loading