@@ -192,6 +192,7 @@ function New-MarkdownHelp
192
192
}
193
193
194
194
$commandName = $mamlObject.Name
195
+
195
196
# create markdown
196
197
if ($NoMetadata )
197
198
{
@@ -206,10 +207,20 @@ function New-MarkdownHelp
206
207
}
207
208
else
208
209
{
209
- $a = @ {
210
- Name = $commandName
210
+ # Get-Command requires that script input be a path
211
+ if ($mamlObject.Name.EndsWith (" .ps1" ))
212
+ {
213
+ $getCommandName = Resolve-Path $Command
214
+ }
215
+ # For cmdlets, nothing needs to be done
216
+ else
217
+ {
218
+ $getCommandName = $commandName
211
219
}
212
220
221
+ $a = @ {
222
+ Name = $getCommandName
223
+ }
213
224
if ($module ) {
214
225
# for module case, scope it just to this module
215
226
$a [' Module' ] = $module
@@ -1810,39 +1821,42 @@ function GetHelpFileName
1810
1821
return $CommandInfo.HelpFile
1811
1822
}
1812
1823
}
1813
-
1814
- # overwise, lets guess it
1815
- $module = @ ($CommandInfo.Module ) + ($CommandInfo.Module.NestedModules ) |
1816
- Where-Object {$_.ModuleType -ne ' Manifest' } |
1817
- Where-Object {$_.ExportedCommands.Keys -contains $CommandInfo.Name }
1818
-
1819
- if (-not $module )
1824
+ # only run module evaluations if the input command isn't a script
1825
+ if ($CommandInfo.CommandType -ne " ExternalScript" )
1820
1826
{
1821
- Write-Warning - Message ($LocalizedData.ModuleNotFoundFromCommand -f ' [GetHelpFileName]' , $CommandInfo.Name )
1822
- return
1823
- }
1827
+ # overwise, lets guess it
1828
+ $module = @ ($CommandInfo.Module ) + ($CommandInfo.Module.NestedModules ) |
1829
+ Where-Object {$_.ModuleType -ne ' Manifest' } |
1830
+ Where-Object {$_.ExportedCommands.Keys -contains $CommandInfo.Name }
1824
1831
1825
- if ($module .Count -gt 1 )
1826
- {
1827
- Write-Warning - Message ($LocalizedData.MultipleModulesFoundFromCommand -f ' [GetHelpFileName]' , $CommandInfo.Name )
1828
- $module = $module | Select-Object - First 1
1829
- }
1832
+ if (-not $module )
1833
+ {
1834
+ Write-Warning - Message ($LocalizedData.ModuleNotFoundFromCommand -f ' [GetHelpFileName]' , $CommandInfo.Name )
1835
+ return
1836
+ }
1830
1837
1831
- if (Test-Path $module.Path - Type Leaf)
1832
- {
1833
- # for regular modules, we can deduct the filename from the module path file
1834
- $moduleItem = Get-Item - Path $module.Path
1835
- if ($moduleItem.Extension -eq ' .psm1' ) {
1836
- $fileName = $moduleItem.BaseName
1837
- } else {
1838
- $fileName = $moduleItem.Name
1838
+ if ($module.Count -gt 1 )
1839
+ {
1840
+ Write-Warning - Message ($LocalizedData.MultipleModulesFoundFromCommand -f ' [GetHelpFileName]' , $CommandInfo.Name )
1841
+ $module = $module | Select-Object - First 1
1842
+ }
1843
+
1844
+ if (Test-Path $module.Path - Type Leaf)
1845
+ {
1846
+ # for regular modules, we can deduct the filename from the module path file
1847
+ $moduleItem = Get-Item - Path $module.Path
1848
+ if ($moduleItem.Extension -eq ' .psm1' ) {
1849
+ $fileName = $moduleItem.BaseName
1850
+ } else {
1851
+ $fileName = $moduleItem.Name
1852
+ }
1853
+ }
1854
+ else
1855
+ {
1856
+ # if it's something like Dynamic module,
1857
+ # we guess the desired help file name based on the module name
1858
+ $fileName = $module.Name
1839
1859
}
1840
- }
1841
- else
1842
- {
1843
- # if it's something like Dynamic module,
1844
- # we guess the desired help file name based on the module name
1845
- $fileName = $module.Name
1846
1860
}
1847
1861
1848
1862
return " $fileName -help.xml"
0 commit comments