I'm having a really weird problem with help in my module. (this is the third one I'm building and the first time I'm seeing this.)
Pertinent section:
Having a weird comment-based help issue in a module i’m building. Currently, the help looks like:
#!/usr/bin/env pwsh
<#
.DESCRIPTION
This script is a bridge between PowerShell and the AppleScript Choose File UI primitive. It allows the use of the standard macOS Choose File dialog inside a PowerShell script and returns a string array of POSIX-Compliant file paths.
#>
<rest of module>
But when I run Get-Help on it, it says it can’t find the help. I’m at a real loss here.
This is current PowerShell running on macOS, and the other two modules i've done, I've never seen this issue before.
I'm having a really weird problem with help in my module. (this is the third one I'm building and the first time I'm seeing this.)
Pertinent section:
Having a weird comment-based help issue in a module i’m building. Currently, the help looks like:
#!/usr/bin/env pwsh
<#
.DESCRIPTION
This script is a bridge between PowerShell and the AppleScript Choose File UI primitive. It allows the use of the standard macOS Choose File dialog inside a PowerShell script and returns a string array of POSIX-Compliant file paths.
#>
<rest of module>
But when I run Get-Help on it, it says it can’t find the help. I’m at a real loss here.
This is current PowerShell running on macOS, and the other two modules i've done, I've never seen this issue before.
As stated in the helpful comments from mklement0:
The comment base help might be either prior the concerned function:
Remove-Module Get-DisplayDialog -ErrorAction SilentlyContinue
{
<#
.DESCRIPTION
This script is a bridge between PowerShell and the AppleScript Choose File UI primitive. It allows the use of the standard macOS Choose File dialog inside a PowerShell script and returns a string array of POSIX-Compliant file paths.
#>
function Get-DisplayDialog { }
Export-ModuleMember -Function Get-DisplayDialog
} | Set-Content -Path .\Get-DisplayDialog.psm1
Import-Module .\Get-DisplayDialog.psm1
or embedded in the the top of the function:
Remove-Module Get-DisplayDialog -ErrorAction SilentlyContinue
{
function Get-DisplayDialog {
<#
.DESCRIPTION
This script is a bridge between PowerShell and the AppleScript Choose File UI primitive. It allows the use of the standard macOS Choose File dialog inside a PowerShell script and returns a string array of POSIX-Compliant file paths.
#>
}
Export-ModuleMember -Function Get-DisplayDialog
} | Set-Content -Path .\Get-DisplayDialog.psm1
Import-Module .\Get-DisplayDialog.psm1
After pasting either of the examples above into a PowerShell host or terminal, you might get the help of the specific exported function:
Get-Help Get-DisplayDialog
NAME
Get-DisplayDialog
SYNOPSIS
SYNTAX
Get-DisplayDialog [<CommonParameters>]
DESCRIPTION
This script is a bridge between PowerShell and the AppleScript Choose File UI primitive. It allows the use of the standard macOS Choose File dialog
inside a PowerShell script and returns a string array of POSIX-Compliant file paths.
...
There are two pitfalls to mention here that might have lead to some confusion:
If the module is already imported and loaded, you will need to remove it (Remove-Module Get-DisplayDialog -ErrorAction SilentlyContinue
) or open a new PowerShell session in order to see the new result.
Your exported function has the same name as the module (Get-DisplayDialog
), there is nothing wrong with that, but to be clear: you aren't retrieving the help of the module but the help of the exported function(s).
$env:PATH
, which isn't what modules do. If your script is a(n executable) shell script discoverable via$env:PATH
, the comment-based help should work; if it isn't, targeting it by its path should work. Please edit your question to clarify your scenario. – mklement0 Commented Jan 5 at 2:54.psm1
file, ever. And, indeed, the presence or absence of a shebang line is irrelevant in this context. More importantly, you shouldn't expect comment-based help in the top-level scope - as opposed to in the context of functions exported from this module - in such a file to be honored. Please explain why you do have this expectation. – mklement0 Commented Jan 5 at 4:27