@@ -33,19 +33,53 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules
33
33
#endif
34
34
public class ProvideCommentHelp : ConfigurableRule
35
35
{
36
- // todo rearrange members
37
36
private CommentHelpPlacement placement ;
38
37
38
+ /// <summary>
39
+ /// Construct an object of ProvideCommentHelp type.
40
+ /// </summary>
41
+ public ProvideCommentHelp ( ) : base ( )
42
+ {
43
+ // Enable the rule by default
44
+ Enable = true ;
45
+ }
46
+
47
+ /// <summary>
48
+ /// If enabled, throw violation only on functions/cmdlets that are exported using
49
+ /// the "Export-ModuleMember" cmdlet.
50
+ ///
51
+ /// Default value is true.
52
+ ///</summary>
39
53
[ ConfigurableRuleProperty ( defaultValue : true ) ]
40
54
public bool ExportedOnly { get ; protected set ; }
41
55
56
+ /// <summary>
57
+ /// If enabled, returns comment help in block comment style, i.e., `<#...#>`. Otherwise returns
58
+ /// comment help in line comment style, i.e., each comment line starts with `#`.
59
+ ///
60
+ /// Default value is true.
61
+ /// </summary>
42
62
[ ConfigurableRuleProperty ( defaultValue : true ) ]
43
63
public bool BlockComment { get ; protected set ; }
44
64
65
+ /// <summary>
66
+ /// If enabled, returns comment help in vscode snippet format.
67
+ ///
68
+ /// Default value is false.
69
+ /// </summary>
45
70
[ ConfigurableRuleProperty ( defaultValue : false ) ]
46
71
public bool VSCodeSnippetCorrection { get ; protected set ; }
47
72
48
- // possible options: before, begin, end
73
+ /// <summary>
74
+ /// Represents the position of comment help with respect to the function definition.
75
+ ///
76
+ /// Possible values are: `before`, `begin` and `end`. If any invalid value is given, the
77
+ /// property defaults to `before`.
78
+ ///
79
+ /// `before` means the help is placed before the function definition.
80
+ /// `begin` means the help is placed at the begining of the function definition body.
81
+ /// `end` means the help is places the end of the function definition body.
82
+ ///</summary>
49
83
[ ConfigurableRuleProperty ( defaultValue : "before" ) ]
50
84
public string Placement
51
85
{
@@ -63,12 +97,6 @@ public string Placement
63
97
}
64
98
}
65
99
66
- public ProvideCommentHelp ( ) : base ( )
67
- {
68
- // Enable the rule by default
69
- Enable = true ;
70
- }
71
-
72
100
private enum CommentHelpPlacement { Before , Begin , End } ;
73
101
74
102
/// <summary>
@@ -149,6 +177,12 @@ public override string GetSourceName()
149
177
return string . Format ( CultureInfo . CurrentCulture , Strings . SourceName ) ;
150
178
}
151
179
180
+ // TODO replace with extension version
181
+ private static IEnumerable < string > GetLines ( string text )
182
+ {
183
+ return text . Split ( '\n ' ) . Select ( l => l . Trim ( '\r ' ) ) ;
184
+ }
185
+
152
186
private DiagnosticSeverity GetDiagnosticSeverity ( )
153
187
{
154
188
return DiagnosticSeverity . Information ;
@@ -206,12 +240,6 @@ private string GetCorrectionText(string correction, Ast ast, FunctionDefinitionA
206
240
}
207
241
}
208
242
209
- // TODO replace with extension version
210
- private static IEnumerable < string > GetLines ( string text )
211
- {
212
- return text . Split ( '\n ' ) . Select ( l => l . Trim ( '\r ' ) ) ;
213
- }
214
-
215
243
private void GetCorrectionPosition (
216
244
FunctionDefinitionAst funcDefnAst ,
217
245
out int startLine ,
@@ -280,11 +308,6 @@ public IEnumerable<FunctionDefinitionAst> FunctionDefinitionAsts
280
308
}
281
309
}
282
310
283
- /// <summary>
284
- /// Visit function and checks that it has comment help
285
- /// </summary>
286
- /// <param name="funcAst"></param>
287
- /// <returns></returns>
288
311
public override AstVisitAction VisitFunctionDefinition ( FunctionDefinitionAst funcAst )
289
312
{
290
313
if ( ( ! useFunctionWhitelist || functionWhitelist . Contains ( funcAst . Name ) )
0 commit comments