@@ -33,19 +33,53 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules
3333#endif
3434 public class ProvideCommentHelp : ConfigurableRule
3535 {
36- // todo rearrange members
3736 private CommentHelpPlacement placement ;
3837
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>
3953 [ ConfigurableRuleProperty ( defaultValue : true ) ]
4054 public bool ExportedOnly { get ; protected set ; }
4155
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>
4262 [ ConfigurableRuleProperty ( defaultValue : true ) ]
4363 public bool BlockComment { get ; protected set ; }
4464
65+ /// <summary>
66+ /// If enabled, returns comment help in vscode snippet format.
67+ ///
68+ /// Default value is false.
69+ /// </summary>
4570 [ ConfigurableRuleProperty ( defaultValue : false ) ]
4671 public bool VSCodeSnippetCorrection { get ; protected set ; }
4772
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>
4983 [ ConfigurableRuleProperty ( defaultValue : "before" ) ]
5084 public string Placement
5185 {
@@ -63,12 +97,6 @@ public string Placement
6397 }
6498 }
6599
66- public ProvideCommentHelp ( ) : base ( )
67- {
68- // Enable the rule by default
69- Enable = true ;
70- }
71-
72100 private enum CommentHelpPlacement { Before , Begin , End } ;
73101
74102 /// <summary>
@@ -149,6 +177,12 @@ public override string GetSourceName()
149177 return string . Format ( CultureInfo . CurrentCulture , Strings . SourceName ) ;
150178 }
151179
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+
152186 private DiagnosticSeverity GetDiagnosticSeverity ( )
153187 {
154188 return DiagnosticSeverity . Information ;
@@ -206,12 +240,6 @@ private string GetCorrectionText(string correction, Ast ast, FunctionDefinitionA
206240 }
207241 }
208242
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-
215243 private void GetCorrectionPosition (
216244 FunctionDefinitionAst funcDefnAst ,
217245 out int startLine ,
@@ -280,11 +308,6 @@ public IEnumerable<FunctionDefinitionAst> FunctionDefinitionAsts
280308 }
281309 }
282310
283- /// <summary>
284- /// Visit function and checks that it has comment help
285- /// </summary>
286- /// <param name="funcAst"></param>
287- /// <returns></returns>
288311 public override AstVisitAction VisitFunctionDefinition ( FunctionDefinitionAst funcAst )
289312 {
290313 if ( ( ! useFunctionWhitelist || functionWhitelist . Contains ( funcAst . Name ) )
0 commit comments