Skip to content

Commit 28647f4

Browse files
Limit public help links to function files
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent c434b45 commit 28647f4

3 files changed

Lines changed: 8 additions & 10 deletions

File tree

.github/actions/Test-PSModule/src/tests/SourceCode/PSModule/PSModule.Tests.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ BeforeDiscovery {
4343
Get-ChildItem -Path $publicFunctionsPath -Filter '*.ps1' -Recurse -File |
4444
Sort-Object -Property FullName |
4545
ForEach-Object {
46+
$ast = [System.Management.Automation.Language.Parser]::ParseFile($_.FullName, [ref]$null, [ref]$null)
47+
$functionTokens = $ast.FindAll({ $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] }, $true)
48+
if ($functionTokens.Count -eq 0) {
49+
return
50+
}
51+
4652
$relativePath = [IO.Path]::GetRelativePath($publicFunctionsPath, $_.FullName)
4753
$relativeDirectory = Split-Path -Path $relativePath -Parent
4854
$documentationPath = if ($relativeDirectory) {

tests/srcTestRepo/src/functions/public/completers.ps1

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
<#
2-
.LINK
3-
https://psmodule.io/PSModuleTest2/Functions/completers/
4-
#>
5-
Register-ArgumentCompleter -CommandName New-PSModuleTest -ParameterName Name -ScriptBlock {
1+
Register-ArgumentCompleter -CommandName New-PSModuleTest -ParameterName Name -ScriptBlock {
62
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
73
$null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters
84

tests/srcWithManifestTestRepo/src/functions/public/completers.ps1

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
<#
2-
.LINK
3-
https://psmodule.io/PSModuleTest/Functions/completers/
4-
#>
5-
Register-ArgumentCompleter -CommandName New-PSModuleTest -ParameterName Name -ScriptBlock {
1+
Register-ArgumentCompleter -CommandName New-PSModuleTest -ParameterName Name -ScriptBlock {
62
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
73
$null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters
84

0 commit comments

Comments
 (0)