forked from PowerShell/PSReadLine
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCheckHelp.ps1
More file actions
91 lines (77 loc) · 2.97 KB
/
CheckHelp.ps1
File metadata and controls
91 lines (77 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
param($Configuration = 'Release')
$ourAssembly = "$PSScriptRoot\PSReadLine\bin\$Configuration\Microsoft.PowerShell.PSReadLine2.dll"
$t ='Microsoft.PowerShell.PSConsoleReadLine' -as [type]
if ($null -ne $t -and $t.Assembly.Location -ne $ourAssembly)
{
# Make sure we're runnning in a non-interactive session by relaunching
powershell -NoProfile -NonInteractive -File $PSCommandPath $Configuration
exit $LASTEXITCODE
}
$save_PSModulePath = $env:PSModulePath
$env:PSModulePath = "$PSScriptRoot\bin\$Configuration;${env:PSModulePath}"
Import-Module PSReadLine
$errorCount = 0
function ReportError
{
[CmdletBinding()]
param([string]$msg)
$script:errorCount++
$host.UI.WriteErrorLine($msg)
}
$about_topic = Get-Content -Raw "$PSScriptRoot\bin\$Configuration\PSReadLine\en-US\about_PSReadLine.help.txt"
$methods = [Microsoft.PowerShell.PSConsoleReadLine].GetMethods('public,static') |
Where-Object {
$method = $_
$parameters = $method.GetParameters()
$parameters.Count -eq 2 -and
$parameters[0].ParameterType -eq [Nullable[ConsoleKeyInfo]] -and
$parameters[1].ParameterType -eq [object]
}
foreach ($method in $methods)
{
$parameters = $method.GetParameters()
if ($parameters[0].Name -ne 'key' -or $parameters[1].Name -ne 'arg')
{
ReportError "Function $($method.Name) parameter names should be key and arg"
}
if (!$parameters[1].HasDefaultValue -or ($null -ne $parameters[1].DefaultValue))
{
ReportError "Function $($method.Name) arg parameter missing default"
}
if (!$parameters[0].HasDefaultValue -or ($null -ne $parameters[0].DefaultValue))
{
ReportError "Function $($method.Name) key parameter missing default"
}
}
$methods.Name | ForEach-Object {
if ($about_topic -cnotmatch $_)
{
ReportError "Function not documented: $_"
}
}
$commonParameters = Write-Output Debug Verbose OutVariable OutBuffer ErrorAction WarningAction ErrorVariable WarningVariable PipelineVariable InformationAction InformationVariable
Get-Command -Type Cmdlet -Module PSReadLine |
ForEach-Object {
$cmdletInfo = $_
$cmdletName = $cmdletInfo.Name
$cmdletHelp = Get-Help -Detailed $cmdletName
$cmdletInfo.Parameters.Keys |
ForEach-Object {
$parameterName = $_
if ($parameterName -notin $commonParameters)
{
$parameterHelp = $cmdletHelp.Parameters.parameter | Where-Object Name -eq $parameterName
if ($parameterHelp -eq $null)
{
ReportError "Parameter $parameterName not documented in cmdlet $cmdletName"
}
}
}
}
Get-PSReadLineKeyHandler -Bound -Unbound |
Where-Object { $_.Function -eq $_.Description } |
ForEach-Object {
ReportError "Function missing description: $($_.Function)"
}
$env:PSModulePath = $save_PSModulePath
exit $errorCount