📄 ugenerate.pas
字号:
{Returns whether a generator is available.
~result whether a generator is available }
function TGeneratorManager.GeneratorAvailable: Boolean;
begin
Result := Assigned(FGenerator);
end;
{Returns the description of the generator.
~result the description of the generator }
function TGeneratorManager.GeneratorDescription: TGeneratorDescription;
begin
Result := FGenerator.GetDescription;
end;
{Returns the name of the class of the generator.
~result the name of the class of the generator }
function TGeneratorManager.GeneratorClassName: String;
begin
Result := FGenerator.ClassName;
end;
{Returns whether the generator uses extractors.
~result whether the generator uses extractors. }
function TGeneratorManager.GeneratorUsesCommentExtractors: Boolean;
begin
Result := Assigned(FGenerator) and
(gcExtractsComments in FGenerator.Capabilities);
end;
{Returns whether the generator uses evaluators.
~result whether the generator uses evaluators. }
function TGeneratorManager.GeneratorUsesCommentEvaluators: Boolean;
begin
Result := FGenerator is TCommentDoc;
end;
{Returns whether the generator supports (additional) user documentation.
~result whether the generator supports (additional) user documentation }
function TGeneratorManager.GeneratorSupportsUserDocumentation: Boolean;
begin
Result := gcExtractsComments in FGenerator.Capabilities;
end;
{Returns the capabilities of the generator.
~result the capabilities of the generator }
function TGeneratorManager.GeneratorCapabilities: TGeneratorCapabilities;
begin
Result := FGenerator.Capabilities;
end;
{Returns an object to edit the options of the generator.
~result an object to edit the options of the generator }
function TGeneratorManager.GeneratorOptions: TOptionWrapper;
begin
Result := FGenerator.GetOptions;
end;
{Returns whether the generator writes the documentation to a main file.
~result whether the generator writes the documentation to a main file }
function TGeneratorManager.GeneratorHasFileName: Boolean;
var Dummy :Cardinal;
begin
Result := FGenerator.GetOptions.GetOptionIndex(OptionNameFileName, otString,
Dummy);
end;
{Returns the status text of the generator after generation.
~result the status text of the generator }
function TGeneratorManager.GetGenerateStatusText: String;
begin
Result := FGenerator.StatusText;
end;
{Returns the messages of the generator.
~param Messages the list to add all messages to
~param Descriptions will receive a list of all descriptions of the messages }
procedure TGeneratorManager.GetGeneratorMessages(
Messages: TGeneratorMessageList;
var Descriptions: TMessageDescriptionsList);
begin
FGenerator.GetMessages(Messages, Descriptions);
end;
{Resets the extractor of comments to its default values. }
procedure TGeneratorManager.ResetExtractor;
begin
if (gcExtractsComments in FGenerator.Capabilities) and //extractor available?
Assigned(FExtractorClass) then
begin
try
FGenerator.Extractor.Free; //free the old extractor
finally
FGenerator.Extractor := nil;
end; //and create a new one
FGenerator.Extractor := FExtractorClass.Create(FGenerator);
end;
end;
{Loads the options of the extractor of comments from the file.
~param FileName the name of the file to load the options from }
procedure TGeneratorManager.ExtractorLoadOptionsFromFile(const FileName:
String);
var Ini :TIniFile; //the ini file containing the options
begin
{$IFNDEF LINUX}
Assert((Pos('\', FileName) <> 0) or (Pos(':', FileName) <> 0));
{$ENDIF}
if (gcExtractsComments in FGenerator.Capabilities) and //extractor available?
Assigned(FGenerator.Extractor) then
begin
Ini := TIniFile.Create(FileName); //open the ini file
try //and load the options
FGenerator.Extractor.GetOptions.LoadAllIniOptions(Ini);
FGenerator.Extractor.GetOptions.LoadIniOptions(Ini);
finally
Ini.Free; //close the file
end;
end;
end;
{Returns the description of the extractor of comments.
~result the description of the extractor }
function TGeneratorManager.ExtractorDescription: TExtractorDescription;
begin
if Assigned(FExtractorClass) then //extractor available?
Result := FExtractorClass.GetDescription //return its description
else
begin
Result.Name := ''; //return an empty description
Result.Identification := '';
Result.Description := '';
end;
end;
{Returns the name of the class of the extractor of comments.
~result the name of the class of the extractor }
function TGeneratorManager.ExtractorClassName: String;
begin
if Assigned(FExtractorClass) then
Result := FExtractorClass.ClassName
else
Result := '';
end;
{Returns an object to edit the options of the extractor of comments.
~result an object to edit the options of the extractor }
function TGeneratorManager.ExtractorOptions: TOptionWrapper;
begin
if (gcExtractsComments in FGenerator.Capabilities) and //extractor available?
Assigned(FGenerator.Extractor) then
Result := FGenerator.Extractor.GetOptions //return its options
else
Result := nil; //no options
end;
{Resets the evaluator to its default values. }
procedure TGeneratorManager.ResetEvaluator;
begin //evaluator evailable?
if (FGenerator is TCommentDoc) and assigned(FEvaluatorClass) then
begin
try
TCommentDoc(FGenerator).Evaluator.Free; //free the evaluator
finally
TCommentDoc(FGenerator).Evaluator := nil;
end;
TCommentDoc(FGenerator).Evaluator := //create a new one
FEvaluatorClass.Create(TCommentDoc(FGenerator));
end;
end;
{Loads the options of the evaluator from the file.
~param FileName the name of the file to load the options from }
procedure TGeneratorManager.EvaluatorLoadOptionsFromFile(const FileName:
String);
var Ini :TIniFile; //the ini file containing the options
begin
{$IFNDEF LINUX}
Assert((Pos('\', FileName) <> 0) or (Pos(':', FileName) <> 0));
{$ENDIF}
if (FGenerator is TCommentDoc) and
Assigned(TCommentDoc(FGenerator).Evaluator) then
begin
Ini := TIniFile.Create(FileName); //open the ini file
try //and load the options
TCommentDoc(FGenerator).Evaluator.GetOptions.LoadAllIniOptions(Ini);
TCommentDoc(FGenerator).Evaluator.GetOptions.LoadIniOptions(Ini);
finally
Ini.Free; //close the file
end;
end;
end;
{Returns the description of the evaluator.
~result the description of the evaluator }
function TGeneratorManager.EvaluatorDescription: TEvaluatorDescription;
begin
if Assigned(FEvaluatorClass) then //extractor available?
Result := FEvaluatorClass.GetDescription //return its description
else
begin
Result.Name := ''; //return an empty description
Result.Identification := '';
Result.Description := '';
end;
end;
{Returns the name of the class of the evaluator.
~result the name of the class of the evaluator }
function TGeneratorManager.EvaluatorClassName: String;
begin
if Assigned(FEvaluatorClass) then
Result := FEvaluatorClass.ClassName
else
Result := '';
end;
{Returns an object to edit the options of the evaluator.
~result an object to edit the options of the evaluator }
function TGeneratorManager.EvaluatorOptions: TOptionWrapper;
begin
if (FGenerator is TCommentDoc) and
Assigned(TCommentDoc(FGenerator).Evaluator) then
Result := TCommentDoc(FGenerator).Evaluator.GetOptions
else
Result := nil;
end;
{Returns an object to edit the options of the reader of the data about a GUI.
~result an object to edit the options of the reader }
function TGeneratorManager.GUIHelpReaderOptions: TOptionWrapper;
begin
if (FGenerator is TCommentDoc) and
Assigned(TCommentDoc(FGenerator).GUIHelpReader) then
Result := TCommentDoc(FGenerator).GUIHelpReader.GetOptions
else
Result := nil;
end;
{Returns a list of wrappers for all options of the different objects.
~result a list of wrappers for all options }
function TGeneratorManager.AllOptions: TOptionWrapperList;
begin
Result := FGenerator.GetAllOptions; //just ask the generator for them
end;
{{Loads the options from the ini file and sets them from the list.
~param Ini the ini file to load options from, may be nil to skip this step
~param Options the options to set, may be nil when none are available }
procedure TGeneratorManager.InitAllOptions(Ini: TCustomIniFile;
Options: TStrings);
var List :TOptionWrapperList; //the list of options
i :Integer; //runner through the wrappers
Wrapper :TOptionWrapper; //the encapsulating wrapper
begin
List := AllOptions; //get list of all wrappers
if Assigned(Ini) then //ini file available?
for i := 0 to Length(List) - 1 do //for each wrapper
if Assigned(List[i]) then //available?
begin
List[i].LoadAllIniOptions(Ini); //load the options
List[i].LoadIniOptions(Ini);
end;
if Assigned(Options) then //additional options available?
begin
//wrap the wrappers of all options of the different objects
Wrapper := TCollectionOptionWrapper.Create(List);
try
Wrapper.LoadOptionList(Options); //set the options
finally
Wrapper.Free; //free the wrapper
end;
end;
end;
{Sets an option of one of the generator objects.
~param Name the name of the option to be set
~param Value the new value of the option }
procedure TGeneratorManager.SetOneOption(const Name, Value: String);
var Wrapper :TOptionWrapper; //the encapsulating wrapper
begin
//wrap the wrappers of all options of the different objects
Wrapper := TCollectionOptionWrapper.Create(AllOptions);
try
Wrapper.SetOptionByName(Name, Value); //set the options
finally
Wrapper.Free; //free the wrapper
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -