@@ -39,7 +39,7 @@ TCompileDocInfo = record
3939
4040type
4141 // / <summary>Array of textual compiler result information.</summary>
42- TCompileDocInfoArray = array of TCompileDocInfo;
42+ TCompileDocInfoArray = TArray< TCompileDocInfo> ;
4343
4444type
4545 // / <summary>Abstract base class for classes that render documents that
@@ -76,10 +76,14 @@ TSnippetDoc = class(TObject)
7676 // / title.</summary>
7777 procedure RenderTitledList (const Title: string; List: IStringList);
7878 virtual ; abstract ;
79- // / <summary>Output given compiler info, preceeded by given heading.
79+ // / <summary>Output given compiler test info, preceded by given heading.
8080 // / </summary>
8181 procedure RenderCompilerInfo (const Heading: string;
8282 const Info: TCompileDocInfoArray); virtual ; abstract ;
83+ // / <summary>Output message stating that there is no compiler test info,
84+ // / preceded by given heading.</summary>
85+ procedure RenderNoCompilerInfo (const Heading, NoCompileTests: string);
86+ virtual ; abstract ;
8387 // / <summary>Output given extra information to document.</summary>
8488 // / <remarks>Active text must be interpreted in a manner that makes sense
8589 // / for document format.</remarks>
@@ -109,6 +113,7 @@ implementation
109113uses
110114 // Delphi
111115 SysUtils,
116+ Generics.Collections,
112117 // Project
113118 Compilers.UCompilers,
114119 DB.UMain,
@@ -136,17 +141,24 @@ function TSnippetDoc.CompilerInfo(const Snippet: TSnippet):
136141var
137142 Compilers: ICompilers; // provided info about compilers
138143 Compiler: ICompiler; // each supported compiler
139- InfoIdx: Integer; // index into output array
144+ ResList: TList<TCompileDocInfo>;
140145begin
141146 Compilers := TCompilersFactory.CreateAndLoadCompilers;
142147 SetLength(Result, Compilers.Count);
143- InfoIdx := 0 ;
144- for Compiler in Compilers do
145- begin
146- Result[InfoIdx] := TCompileDocInfo.Create(
147- Compiler.GetName, Snippet.Compatibility[Compiler.GetID]
148- );
149- Inc(InfoIdx);
148+ ResList := TList<TCompileDocInfo>.Create;
149+ try
150+ for Compiler in Compilers do
151+ begin
152+ if Snippet.Compatibility[Compiler.GetID] <> crQuery then
153+ ResList.Add(
154+ TCompileDocInfo.Create(
155+ Compiler.GetName, Snippet.Compatibility[Compiler.GetID]
156+ )
157+ );
158+ end ;
159+ Result := ResList.ToArray;
160+ finally
161+ ResList.Free;
150162 end ;
151163end ;
152164
@@ -158,7 +170,10 @@ function TSnippetDoc.Generate(const Snippet: TSnippet): TEncodedData;
158170 sUnitListTitle = ' Required units:' ;
159171 sDependListTitle = ' Required snippets:' ;
160172 sXRefListTitle = ' See also:' ;
161- sCompilers = ' Supported compilers:' ;
173+ sCompilers = ' Compiler test results:' ;
174+ sNoCompilerTests = ' No compiler tests were carried out.' ;
175+ var
176+ CompileResults: TCompileDocInfoArray;
162177begin
163178 Assert(Assigned(Snippet), ClassName + ' .Create: Snippet is nil' );
164179 // generate document
@@ -176,7 +191,13 @@ function TSnippetDoc.Generate(const Snippet: TSnippet): TEncodedData;
176191 RenderTitledList(sDependListTitle, SnippetsToStrings(Snippet.Depends));
177192 RenderTitledList(sXRefListTitle, SnippetsToStrings(Snippet.XRef));
178193 if Snippet.Kind <> skFreeform then
179- RenderCompilerInfo(sCompilers, CompilerInfo(Snippet));
194+ begin
195+ CompileResults := CompilerInfo(Snippet);
196+ if Length(CompileResults) > 0 then
197+ RenderCompilerInfo(sCompilers, CompilerInfo(Snippet))
198+ else
199+ RenderNoCompilerInfo(sCompilers, sNoCompilerTests);
200+ end ;
180201 if Snippet.Extra.HasContent then
181202 RenderExtra(Snippet.Extra);
182203 if not Snippet.UserDefined then
0 commit comments