Skip to content

Commit 1f92a39

Browse files
it-praktykvors
authored andcommitted
Update-MarkdownHelp doesn't respect, in some cases, an order of params (#423)
1 parent 8a63310 commit 1f92a39

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

docs/Update-MarkdownHelp.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ You can pipe an array of paths to this cmdlet.
231231
This cmdlet returns a **FileInfo[]** object for updated files.
232232

233233
## NOTES
234+
The module for which you want to update the help should first be imported from the location containing the previous version of the help.
235+
If this condition is not met, the parameter order will be alphabetical in the updated help, even if the parameter *AlphabeticParamsOrder* has not been used.
234236

235237
## RELATED LINKS
236238

docs/Update-MarkdownHelpModule.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ You can pipe an array of paths to this cmdlet.
238238
This cmdlet returns a **FileInfo[]** object for updated and new files.
239239

240240
## NOTES
241+
The module for which you want to update the help should first be imported from the location containing the previous version of the help.
242+
If this condition is not met, the parameter order will be alphabetical in the updated help, even if the parameter *AlphabeticParamsOrder* has not been used.
241243

242244
## RELATED LINKS
243245

src/platyPS/platyPS.Resources.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ WhatIf = Shows what would happen if the cmdlet runs. The cmdlet is not run.
7474
Skip = Ignores the specified number of objects and then gets the remaining objects. Enter the number of objects to skip.
7575
First = Gets only the specified number of objects. Enter the number of objects to get.
7676
IncludeTotalCount = Reports the total number of objects in the data set (an integer) followed by the selected objects. If the cmdlet cannot determine the total count, it displays "Unknown total count." The integer has an Accuracy property that indicates the reliability of the total count value. The value of Accuracy ranges from 0.0 to 1.0 where 0.0 means that the cmdlet could not count the objects, 1.0 means that the count is exact, and a value between 0.0 and 1.0 indicates an increasingly reliable estimate.
77+
ModuleImporteAutomaticaly = The module {0} was imported automatically. It may cause that parameters will be sorted alphabetically even without usage of the parameter AlphabeticParamsOrder. Please be sure that the loaded module instance contains previously generated help to avoid that.
7778
'@

src/platyPS/platyPS.psm1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ function New-MarkdownHelp
240240
if ($PSCmdlet.ParameterSetName -eq 'FromCommand')
241241
{
242242
$command | ForEach-Object {
243-
if (-not (Get-Command $_ -EA SilentlyContinue))
243+
if (-not (Get-Command $_ -ErrorAction SilentlyContinue))
244244
{
245245
throw $LocalizedData.CommandNotFound -f $_
246246
}
@@ -421,6 +421,7 @@ function Update-MarkdownHelp
421421
$oldModel = $oldModels[0]
422422

423423
$name = $oldModel.Name
424+
[Array]$loadedModulesBefore = $(Get-Module | Select-Object -Property Name)
424425
$command = Get-Command $name -ErrorAction SilentlyContinue
425426
if (-not $command)
426427
{
@@ -435,6 +436,10 @@ function Update-MarkdownHelp
435436
return
436437
}
437438
}
439+
elseif (($null -ne $command.ModuleName) -and ($loadedModulesBefore.Name -notcontains $command.ModuleName))
440+
{
441+
log -warning ($LocalizedData.ModuleImporteAutomaticaly -f $($command.ModuleName))
442+
}
438443

439444
# update the help file entry in the metadata
440445
$metadata = Get-MarkdownMetadata $filePath

0 commit comments

Comments
 (0)