⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ucommentdoc.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 5 页
字号:
function TGUIHelpReaderOptionWrapper.GetOption(Index: Cardinal): TOptionValue;
begin
 Result := FGUIHelpReader.GetOption(Index);    //get the option of the reader
end;

{Sets the value of an option. Call ~[link Description] to get the type and
 the meaning of the option.
~param Index index of the option to set the value
~param Value the new value of the option}
procedure TGUIHelpReaderOptionWrapper.SetOption(Index: Cardinal;
                                                const Value: TOptionValue);
begin
 FGUIHelpReader.SetOption(Index, Value);       //set the option of the reader
end;


{Gets the topic of an option, the name of the class of the reader the option
 is defined in.
~param Index index of the option to get the topic of
~result the topic of the option }
function TGUIHelpReaderOptionWrapper.Topic(Index: Cardinal): String;
var      AClass       :TGUIHelpReaderClass; //runner through all classes
begin
 if Index >= FGUIHelpReader.GetOptionCount then
  raise EInvalidOption.Create('Invalid index for option supplied!');

 //get the parent class of the evaluator introducing the option
 AClass := TGUIHelpReaderClass(FGUIHelpReader.ClassType);
 while (AClass <> TGUIHelpReader) and
       (TGUIHelpReaderClass(AClass.ClassParent).GetOptionCount > Index) do
  AClass := TGUIHelpReaderClass(AClass.ClassParent);

 Result := AClass.ClassName;                      //return name of the class
end;

































































   { * * *  ***  * * *  ***   TCommentEvaluator   ***  * * *  ***  * * *  }


{Creates the object and saves the reference on the generator.
~param Generator the generator to evaluate the comments for }
constructor TCommentEvaluator.Create(Generator: TCommentDoc);
begin
 assert(Supports(TMakeDocClass(Generator.ClassType)));

 inherited Create;                          //create the object

 FGenerator := Generator;                   //save the generator
end;

{Frees the object. }
destructor TCommentEvaluator.Destroy;
begin
 FOptionAccessor.Free;                      //free the accessor for the options

 inherited Destroy;                         //free the object
end;


{Checks if the evaluator can work with the generator.
~param GeneratorClass the class of the generator to check against
~result if the evaluator can evaluate comments for generators of that class }
class function TCommentEvaluator.Supports(GeneratorClass: TMakeDocClass):
                                                                       Boolean;
begin
 //generator has to support the comments
 Result := GeneratorClass.InheritsFrom(TCommentDoc);
end;


{Returns the number of available options in evaluators of this class.
~result the number of available options
~see GetOptionDescription
~see GetOption
~see SetOption }
class function TCommentEvaluator.GetOptionCount: Cardinal;
begin
 Result := 0;                        //no options in this abstract class
end;

{Gets a description of an option.
~param Index index of the option to get data of
~param Desc  out: the description of the option (name, type, default value,
                  etc.)
~see GetOptionCount }
class procedure TCommentEvaluator.GetOptionDescription(Index: Cardinal;
                                                 var Desc: TOptionDescription);
begin
 Assert(False);
 raise EInvalidOption.Create('Invalid index for option supplied!');
end;

{Gets the value of an option. Call ~[link GetOptionDescription] to get the type
 and the meaning of the option.
~param Index index of the option to get the value of
~result the value of the option
~see GetOptionCount
~see GetOptionDescription
~see SetOption }
function TCommentEvaluator.GetOption(Index: Cardinal): TOptionValue;
begin
 Assert(False);
 raise EInvalidOption.Create('Invalid index for option supplied!');
end;

{Sets the value of an option. Call ~[link GetOptionDescription] to get the type
 and the meaning of the option.
~param Index index of the option to set the value
~param Value the new value of the option
~see GetOptionCount
~see GetOptionDescription
~see GetOption }
procedure TCommentEvaluator.SetOption(Index: Cardinal;
                                      const Value: TOptionValue);
begin
 Assert(False);
 raise EInvalidOption.Create('Invalid index for option supplied!');
end;

{Returns an object to edit the options of the evaluator of comments. The object
 must not be freed.
~result an object to edit the options of the evaluator of comments }
function TCommentEvaluator.GetOptions: TOptionWrapper;
begin
 if not Assigned(FOptionAccessor) then          //accessor does not exist yet?
  FOptionAccessor := TCommentEvaluatorOptionWrapper.Create(Self); //create it
 Result := FOptionAccessor;                     //return the wrapper
end;


{Resets the attributes to ready the evaluator for a new generation. }
procedure TCommentEvaluator.ResetForNewGeneration;
begin

end;


{Gets the first name of a parameter in the text and removes it.
~param Text  the text to read and delete the name of the parameter from
~param Param the name of the read parameter
~result if the name of another parameter follows }
function TCommentEvaluator.ExtractParamName(var Text: String;
                                            var Param: String): Boolean;
var      p          :PChar;    //runner through the string
begin
 Param := '';                  //no parameter read so far
 Result := False;              //no parameter follows so far

 if Text <> '' then            //some text to contain the name of a parameter?
  begin
   p := Pointer(Text);
   if p^ in StartIdentifierChars then //is a correct name for an identifier?
    begin
     inc(p);
     while p^ in IdentifierChars do  //skip the name
      inc(p);
     //and extract it and delete it from the text
     Param := copy(Text, 1,  Cardinal(p) - Cardinal(Pointer(Text)));
     Delete(Text, 1,  Cardinal(p) - Cardinal(Pointer(Text)));

     if Text <> '' then              //some text follows?
      begin                            //a "," follow directly?
       Result := (length(Text) > 1) and (Text[1] = ',');
       if Result then                  //this means another parameter follows
        Delete(Text, 1, 1);              //delete the ","

       p := Pointer(Text);
       while p^ in [#1..' '] do        //skip and delete all whitespaces
        inc(p);
       Delete(Text, 1,  Cardinal(p) - Cardinal(Pointer(Text)));
      end; //if Text <> ''
    end; //if p^ in StartIdentifierChars
  end; //if Text <> ''
end;





















   { * * *  ***  * * *  ***   TGUIHelpReader   ***  * * *  ***  * * *  }

{Creates reader of the data of the GUI to generate documentation about.
~param Generator the generator that will generate the help about the GUI }
constructor TGUIHelpReader.Create(Generator: TCommentDoc);
begin
 inherited Create;                       //create the object

 FGUIHelpFiles := TStringList.Create;    //create list of files
 FGUIHelpData := TList.Create;           //create the list for TGUIHelpData's

 FGenerator := Generator;                //save the parameters
end;

{Frees the object and the read date of the GUI. }
destructor TGUIHelpReader.Destroy;
var        i             :Integer;       //counter through FGUIHelpData
begin
 FGUIHelpFiles.Free;                     //free the list of the files

 if assigned(FGUIHelpData) then          //list was created?
  begin
   for i := 0 to FGUIHelpData.Count - 1 do //for each entry
    TOldGUIHelpData(FGUIHelpData[i]).Free;   //free the object
   FGUIHelpData.Free;                      //free the list
  end;

 FOptionAccessor.Free;                   //free the accessor for the options

 inherited Destroy;                      //free the object
end;



{Returns the current file of the GUI the help is generated about.
~result the current file of the GUI }
function TGUIHelpReader.GetCurrentGUIHelpFile: TOldGUIHelpData;
begin
 assert(assigned(FGUIHelpData));
 assert(FCurrentGUIHelpFileIndex > -1);
 Result := FGUIHelpData[FCurrentGUIHelpFileIndex];
end;




{Returns the number of available options in readers of this class.
~result the number of available options
~see GetOptionDescription
~see GetOption
~see SetOption }
class function TGUIHelpReader.GetOptionCount: Cardinal;
begin
 Result := 0;                        //no options in this abstract class
end;

{Gets a description of an option.
~param Index index of the option to get data of
~param Desc  out: the description of the option (name, type, default value,
                  etc.)
~see GetOptionCount }
class procedure TGUIHelpReader.GetOptionDescription(Index: Cardinal;
                                                 var Desc: TOptionDescription);
begin
 Assert(False);
 raise EInvalidOption.Create('Invalid index for option supplied!');
end;

{Gets the value of an option. Call ~[link GetOptionDescription] to get the type
 and the meaning of the option.
~param Index index of the option to get the value of
~result the value of the option
~see GetOptionCount
~see GetOptionDescription
~see SetOption }
function TGUIHelpReader.GetOption(Index: Cardinal): TOptionValue;
begin
 Assert(False);
 raise EInvalidOption.Create('Invalid index for option supplied!');
end;

{Sets the value of an option. Call ~[link GetOptionDescription] to get the type
 and the meaning of the option.
~param Index index of the option to set the value
~param Value the new value of the option
~see GetOptionCount
~see GetOptionDescription
~see GetOption }
procedure TGUIHelpReader.SetOption(Index: Cardinal;
                                   const Value: TOptionValue);
begin
 Assert(False);
 raise EInvalidOption.Create('Invalid index for option supplied!');
end;

{Returns an object to edit the options of the reader of data about a GUI. The
 object must not be freed.
~result an object to edit the options of the evaluator of comments }
function TGUIHelpReader.GetOptions: TOptionWrapper;
begin
 if not Assigned(FOptionAccessor) then          //accessor does not exist yet?
  FOptionAccessor := TGUIHelpReaderOptionWrapper.Create(Self); //create it
 Result := FOptionAccessor;                     //return the wrapper
end;



{Resets the reader of the data of the GUI.}
procedure TGUIHelpReader.ResetForNewGeneration;
var       i             :Integer;       //counter through GUI help data
begin
 //clear data for generating help on a GUI
 for i := 0 to FGUIHelpData.Count - 1 do
  TOldGUIHelpData(FGUIHelpData[i]).Free;
 FGUIHelpData.Clear;
end;






⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -