@@ -33,9 +33,14 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules
33
33
public class ProvideCommentHelp : ConfigurableRule
34
34
{
35
35
36
+ // todo add option for comment type
37
+ // todo add option for help placement (beforeFuntion, BodyStart, BodyEnd:)
36
38
[ ConfigurableRuleProperty ( defaultValue : true ) ]
37
39
public bool ExportedOnly { get ; protected set ; }
38
40
41
+ [ ConfigurableRuleProperty ( defaultValue : true ) ]
42
+ public bool BlockComment { get ; protected set ; }
43
+
39
44
public ProvideCommentHelp ( ) : base ( )
40
45
{
41
46
// Enable the rule by default
@@ -143,7 +148,7 @@ private IEnumerable<CorrectionExtent> GetCorrection(FunctionDefinitionAst funcDe
143
148
funcDefnAst . Extent . StartLineNumber ,
144
149
funcDefnAst . Extent . StartColumnNumber ,
145
150
funcDefnAst . Extent . StartColumnNumber ,
146
- helpBuilder . GetCommentHelp ( ) + Environment . NewLine ,
151
+ helpBuilder . GetCommentHelp ( BlockComment ) + Environment . NewLine ,
147
152
funcDefnAst . Extent . File ) ;
148
153
}
149
154
@@ -215,13 +220,28 @@ public void AddParameter(string paramName)
215
220
parameters . Add ( new ParameterHelpNode ( paramName , "Parameter description" ) ) ;
216
221
}
217
222
218
- // todo add option for comment type
219
- public string GetCommentHelp ( )
223
+ public string GetCommentHelp ( bool blockComment )
220
224
{
221
225
var sb = new StringBuilder ( ) ;
222
- sb . AppendLine ( "<#" ) ;
223
- sb . AppendLine ( this . ToString ( ) ) ;
224
- sb . Append ( "#>" ) ;
226
+ if ( blockComment )
227
+ {
228
+ sb . AppendLine ( "<#" ) ;
229
+ sb . AppendLine ( this . ToString ( ) ) ;
230
+ sb . Append ( "#>" ) ;
231
+ }
232
+ else
233
+ {
234
+ var boundaryString = new String ( '#' , 30 ) ;
235
+ sb . AppendLine ( boundaryString ) ;
236
+ var lines = this . ToString ( ) . Split ( '\n ' ) . Select ( l => l . Trim ( '\r ' ) ) ;
237
+ foreach ( var line in lines )
238
+ {
239
+ sb . Append ( "#" ) ;
240
+ sb . AppendLine ( line ) ;
241
+ }
242
+ sb . AppendLine ( boundaryString ) ;
243
+ }
244
+
225
245
return sb . ToString ( ) ;
226
246
}
227
247
0 commit comments