@@ -198,18 +198,23 @@ TSourceGen = class(TObject)
198198 // / <summary>Generates source code of a Pascal unit containing all the
199199 // / specified snippets along with any other snippets that are required to
200200 // / compile the code.</summary>
201- // / <param name="UnitName">string [in] Name of unit.</param>
202- // / <param name="CommentStyle">TCommentStyle [in] Style of commenting used
203- // / in documenting snippets.</param>
204- // / <param name="TruncateComments">Boolean [in] Flag indicating whether or
205- // / not documentation comments are to be truncated at the end of the first
206- // / paragraph of multi-paragraph text.</param>
207- // / <param name="HeaderComments">IStringList [in] List of comments to be
208- // / included at top of unit.</param>
209- // / <returns>string. Unit source code.</returns>
201+ // / <param name="UnitName"><c>string</c> [in] Name of unit.</param>
202+ // / <param name="CommentStyle"><c>TCommentStyle</c> [in] Style of
203+ // / commenting used in documenting snippets.</param>
204+ // / <param name="TruncateComments"><c>Boolean</c> [in] Flag indicating
205+ // / whether or not documentation comments are to be truncated at the end of
206+ // / the first paragraph of multi-paragraph text.</param>
207+ // / <param name="UseCommentsInImplmentation"><c>Boolean</c> [in] Flag
208+ // / indicating whether or not comments are to be included in the
209+ // / implementation section. Has no effect when <c>CommentStyle</c> =
210+ // / <c>csNone</c>.</param>
211+ // / <param name="HeaderComments"><c>IStringList</c> [in] List of comments
212+ // / to be included at top of unit.</param>
213+ // / <returns><c>string</c>. Unit source code.</returns>
210214 function UnitAsString (const UnitName: string;
211215 const CommentStyle: TCommentStyle = csNone;
212216 const TruncateComments: Boolean = False;
217+ const UseCommentsInImplementation: Boolean = False;
213218 const HeaderComments: IStringList = nil ): string;
214219
215220 // / <summary>Generates source code of a Pascal include file containing all
@@ -585,14 +590,23 @@ class function TSourceGen.IsFileNameValidUnitName(const FileName: string):
585590function TSourceGen.UnitAsString (const UnitName: string;
586591 const CommentStyle: TCommentStyle = csNone;
587592 const TruncateComments: Boolean = False;
593+ const UseCommentsInImplementation: Boolean = False;
588594 const HeaderComments: IStringList = nil ): string;
589595var
590- Writer: TStringBuilder; // used to build source code string
591- Snippet: TSnippet; // reference to a snippet object
592- Warnings: IWarnings; // object giving info about any inhibited warnings
596+ Writer: TStringBuilder; // used to build source code string
597+ Snippet: TSnippet; // reference to a snippet object
598+ Warnings: IWarnings; // object giving info about any inhibited warnings
599+ ImplCommentStyle: TCommentStyle; // style of comments in implementation
593600begin
601+ // Set comment style for implementation section
602+ if UseCommentsInImplementation then
603+ ImplCommentStyle := CommentStyle
604+ else
605+ ImplCommentStyle := csNone;
606+
594607 // Generate the unit data
595608 fSourceAnalyser.Generate;
609+
596610 // Create writer object onto string stream that receives output
597611 Writer := TStringBuilder.Create;
598612 try
@@ -681,11 +695,14 @@ function TSourceGen.UnitAsString(const UnitName: string;
681695 for Snippet in fSourceAnalyser.AllRoutines do
682696 begin
683697 Writer.AppendLine(
684- TRoutineFormatter.FormatRoutine(CommentStyle, TruncateComments, Snippet)
698+ TRoutineFormatter.FormatRoutine(
699+ ImplCommentStyle, TruncateComments, Snippet
700+ )
685701 );
686702 Writer.AppendLine;
687703 end ;
688704
705+ // class & records-with-methods implementation source code
689706 for Snippet in fSourceAnalyser.TypesAndConsts do
690707 begin
691708 if Snippet.Kind = skClass then
0 commit comments