@@ -33,9 +33,14 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules
3333 public class ProvideCommentHelp : ConfigurableRule
3434 {
3535
36+ // todo add option for comment type
37+ // todo add option for help placement (beforeFuntion, BodyStart, BodyEnd:)
3638 [ ConfigurableRuleProperty ( defaultValue : true ) ]
3739 public bool ExportedOnly { get ; protected set ; }
3840
41+ [ ConfigurableRuleProperty ( defaultValue : true ) ]
42+ public bool BlockComment { get ; protected set ; }
43+
3944 public ProvideCommentHelp ( ) : base ( )
4045 {
4146 // Enable the rule by default
@@ -143,7 +148,7 @@ private IEnumerable<CorrectionExtent> GetCorrection(FunctionDefinitionAst funcDe
143148 funcDefnAst . Extent . StartLineNumber ,
144149 funcDefnAst . Extent . StartColumnNumber ,
145150 funcDefnAst . Extent . StartColumnNumber ,
146- helpBuilder . GetCommentHelp ( ) + Environment . NewLine ,
151+ helpBuilder . GetCommentHelp ( BlockComment ) + Environment . NewLine ,
147152 funcDefnAst . Extent . File ) ;
148153 }
149154
@@ -215,13 +220,28 @@ public void AddParameter(string paramName)
215220 parameters . Add ( new ParameterHelpNode ( paramName , "Parameter description" ) ) ;
216221 }
217222
218- // todo add option for comment type
219- public string GetCommentHelp ( )
223+ public string GetCommentHelp ( bool blockComment )
220224 {
221225 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+
225245 return sb . ToString ( ) ;
226246 }
227247
0 commit comments