Skip to content

Commit f92dabd

Browse files
author
Kapil Borle
authored
Merge pull request #761 from PowerShell/kapilmb/help-completion
Add suggested corrections for ProvideCommentHelp rule
2 parents 27e05c3 + 2954583 commit f92dabd

File tree

6 files changed

+747
-57
lines changed

6 files changed

+747
-57
lines changed

Engine/Settings.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -416,14 +416,15 @@ private Hashtable GetHashtableFromHashTableAst(HashtableAst hashTableAst)
416416
var strConstExprAst = constExprAst as StringConstantExpressionAst;
417417
if (strConstExprAst != null)
418418
{
419-
rhsList.Add(strConstExprAst.Value);
419+
// it is a string literal
420+
output[key] = strConstExprAst.Value;
420421
}
421422
else
422423
{
423424
// it is either an integer or a float
424425
output[key] = constExprAst.Value;
425-
continue;
426426
}
427+
continue;
427428
}
428429
else if (pureExp is HashtableAst)
429430
{

RuleDocumentation/ProvideCommentHelp.md

+42-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,49 @@ Comment based help should be provided for all PowerShell commands. This test onl
88

99
For assistance on comment based help, use the command ```Get-Help about_comment_based_help``` or the article, "How to Write Cmdlet Help" (http://go.microsoft.com/fwlink/?LinkID=123415).
1010

11-
## How
11+
## Configuration
1212

13-
Include comment based help for each command identified.
13+
```powershell
14+
Rules = @{
15+
PSProvideCommentHelp = @{
16+
Enable = $true
17+
ExportedOnly = $false
18+
BlockComment = $true
19+
VSCodeSnippetCorrection = $false
20+
Placement = "before"
21+
}
22+
}
23+
```
24+
25+
### Parameters
26+
27+
#### Enable: bool (Default valus is `$true`)
28+
29+
Enable or disable the rule during ScriptAnalyzer invocation.
30+
31+
#### ExportedOnly: bool (Default value is `$true`)
32+
33+
If enabled, throw violation only on functions/cmdlets that are exported using the 'Export-ModuleMember' cmdlet.
34+
35+
#### BlockComment: bool (Default value is `$true`)
36+
37+
If enabled, returns comment help in block comment style, i.e., `<#...#>`. Otherwise returns
38+
comment help in line comment style, i.e., each comment line starts with `#`.
39+
40+
#### VSCodeSnippetCorrection: bool (Default value is `$false`)
41+
42+
If enabled, returns comment help in vscode snippet format.
43+
44+
#### Placement: string (Default value is `before`)
45+
46+
Represents the position of comment help with respect to the function definition.
47+
48+
Possible values are: `before`, `begin` and `end`. If any invalid value is given, the
49+
property defaults to `before`.
50+
51+
`before` means the help is placed before the function definition.
52+
`begin` means the help is placed at the begining of the function definition body.
53+
`end` means the help is places the end of the function definition body.
1454

1555
## Example
1656

0 commit comments

Comments
 (0)