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

📄 updfdoc.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 5 页
字号:
 //write list of ancestors of the record-like type and
 Text := GetAncestorList(Ident) +
         //write link to the file containing the record-like type
         FileTypeNames[Ident.InFile.FileType] + ' ' +
         GetFileNameLink(Ident.InFile) +
         InternFormatCharacter + InternFormatNewLine;
 //if availabe, write its GUID
 if { (Ident.Kind in [rkInterface, rkDispInterface]) and }
      (Ident.GUID <> '') then
  Text := Text + Localize(dtDocumentationClassGUID) + Ident.GUID +
          InternFormatCharacter + InternFormatNewLine;
 //if packed, write this
 if Ident.IsPacked then
  Text := Text + Localize(dtDocumentationClassPackedPre) +
                 InternFormatCharacter + InternFormatBold +
                 'packed' + InternFormatEndCharacter +
                 Localize(dtDocumentationClassPackedPost) +
                 InternFormatCharacter + InternFormatNewLine;
 //if abstract, write this
 if Ident.IsAbstract then
  Text := Text + Localize(dtDocumentationClassAbstractPre) +
                 InternFormatCharacter + InternFormatItalic +
                 'abstract' + InternFormatEndCharacter +
                 Localize(dtDocumentationClassAbstractPost) +
                 InternFormatCharacter + InternFormatNewLine;
 Text := Text + InternFormatCharacter + InternFormatNewLine;


 if Ident.Kind = rkClass then               //is a class?
  begin
   Interf := GetInterfaceLinks(Ident);        //get implemented interfaces
   PInterf := GetParentInterfaceLinks(Ident);

   if (Interf <> '') or (PInterf <> '') then  //implements some interfaces?
    begin
     Text := Text + InternFormatCharacter + InternFormatBold +
                    Localize(dtDocumentationClassImplementedInterfaces) + ':' +
                    InternFormatEndCharacter +
                    InternFormatCharacter + InternFormatNewLine;
     if Interf <> '' then                       //implements in this class?
      Text := Text + Interf                       //add the list
     else
      Text := Text + InternFormatCharacter + InternFormatItalic +
                 Localize(dtDocumentationClassNoDirectImplementedInterfaces) +
                     InternFormatEndCharacter;
     Text := Text + InternFormatCharacter + InternFormatNewLine;
     if PInterf <> '' then                      //implemented by ancestors?
      Text := Text + Localize(dtDocumentationClassImplementedByAncestors) +
                     ': ' + PInterf;
     Text := Text + InternFormatCharacter + InternFormatNewLine;
    end;
  end;

 //if it can have descendants
 if Ident.Kind in RecordKindCanInherit then
  begin
   SubClasses := GetDirectDescendantList(Ident); //get list of sub-classes
   if SubClasses <> '' then                      //does it have some?
    Text := Text + InternFormatCharacter + InternFormatBold +
                   Localize(dtDocumentationClassDirectSubclasses) + ':' +
                   InternFormatEndCharacter +
                   InternFormatCharacter + InternFormatNewLine +

                   SubClasses +                    //add list of sub-classes

                   InternFormatCharacter + InternFormatNewLine +
                   InternFormatCharacter + InternFormatNewLine
   else
    Text := Text + InternFormatCharacter + InternFormatBold +
                   Localize(dtDocumentationClassNoSubclasses) +
                   InternFormatEndCharacter +
                   InternFormatCharacter + InternFormatNewLine +
                   InternFormatCharacter + InternFormatNewLine;
  end;


 //is an interface (can be implemented?)
 if Ident.Kind = rkInterface then
  begin
   //get list of all (documented) implementing classes
   Implementors := GetImplementingClassesList(Ident);
   if Implementors <> '' then           //interface is implemented?
    Text := Text + InternFormatCharacter + InternFormatBold +
                   Localize(dtDocumentationClassImplementingClasses) + ':' +
                   InternFormatEndCharacter +
                   InternFormatCharacter + InternFormatNewLine +

                   Implementors +         //add list of implementing classes

                   InternFormatCharacter + InternFormatNewLine +
                   InternFormatCharacter + InternFormatNewLine
   else
    Text := Text + InternFormatCharacter + InternFormatBold +
                   Localize(dtDocumentationClassNoImplementingClasses) +
                   InternFormatEndCharacter +
                   InternFormatCharacter + InternFormatNewLine +
                   InternFormatCharacter + InternFormatNewLine;
  end;



 //check, if it is used by some (documented) record-like type
 i := Ident.UsedByIdents.Count - 1;
 while (i >= 0) and
       (not (Ident.UsedByIdents[i] is TRecordType) or
        DoNotDocumentIdentifier(Ident.UsedByIdents[i])) do
  dec(i);
 if i >= 0 then          //record-like type used by any other record-like type?
  begin
   Text := Text + InternFormatCharacter + InternFormatBold +
                  Localize(dtDocumentationClassUsedByClasses) + ':' +
                  InternFormatEndCharacter +
                  InternFormatCharacter + InternFormatNewLine;
   First := True;
   for i := 0 to i do                      //for each using identifier
    begin
     User := Ident.UsedByIdents[i];          //get it
     //is a record-like type and documented?
     if (User is TRecordType) and not DoNotDocumentIdentifier(User) then
      begin
       if First then                           //the first identifier to write?
        First := False
       else
        Text := Text + ', ';                     //write a separator
       Text := Text + GetIdentNameLink(User);  //write a link to the identifier
      end;
    end;
   Text := Text + InternFormatCharacter + InternFormatNewLine;
  end
 else
  Text := Text + InternFormatCharacter + InternFormatBold +
                 Localize(dtDocumentationClassNotUsedByClasses) +
                 InternFormatEndCharacter +
                 InternFormatCharacter + InternFormatNewLine;


 //if it is an abstract type, add its abstract methods
 if Ident.IsAbstract then
  Text := Text + InternFormatCharacter + InternFormatBold +
                 Localize(dtDocumentationClassAbstractMethods) + ':' +
                 InternFormatEndCharacter +
                 InternFormatCharacter + InternFormatNewLine +
                 GetStillAbstractMethods(Ident) +
                 InternFormatCharacter + InternFormatNewLine;



 Text := InternFormatCharacter + InternFormatAlignLeft +
         Text +
         InternFormatCharacter + InternFormatNewLine +
         InternFormatCharacter + InternFormatAlignBlock +
         InternFormatCharacter + InternFormatBold +
         Localize(dtCommentsClassComment) + ':' +
         InternFormatEndCharacter +
         InternFormatCharacter + InternFormatNewLine;


 //write documentation of the record-like type
 WriteParsedText(Text + Comment, True);


 //write the documentation of all members of the record-like type
 WriteMembers(mkField, Ident);
 WriteMembers(mkProperty, Ident);
 WriteMembers(mkMethod, Ident);
end;
































{Starts a list of exported identifiers. Not used!
~param TheFile  the file to write the list to (can be opened here)
~param AFile    the file whose exported identifiers are listed; nil for all
                exported identifiers
~param PreFirst if it is before the first file instead of the global list
~param First    the text before an entry is returned with this parameter
~param Second   the text between the identifier and the export index is
                returned with this parameter; ignored if in a file list
~param Third    the text between the export index and the export name is
                returned with this parameter; ignored if in a file list
~param Fourth   the text between the export name and the "resident"
                directive is returned with this parameter; ignored if in a
                file list
~param Fifth    the text between the "resident" directive and and the file
                exporting is returned with this parameter; ignored if in a
                file list
~param Sixth    the last entry after the file is returned with this
                parameter }
procedure TPDFDoc.StartExportsLists(var TheFile: TextFile;
                                    AFile: TPascalFile; PreFirst: Boolean;
                                    var First, Second, Third, Fourth,
                                        Fifth, Sixth: String);
begin
 assert(False);     //not called
end;

{Ends a list of exported identifiers. Not used!
~param TheFile  the file the list has been written to (can be closed here)
~param AFile    the file whose exported identifiers are listed; nil for all
                exported identifiers
~param PostLast after the last file instead of the global list }
procedure TPDFDoc.EndExportsLists(var TheFile: TextFile;
                                  AFile: TPascalFile; PostLast: Boolean);
begin
 assert(False);     //not called
end;

{Writes the lists of all exported identifiers.
~result if a list was generated (if there are some exported identifiers) }
function TPDFDoc.WriteExportsList: Boolean;
var      List          :TIdentifierList;   //all exported identifiers
         i, j          :Integer;           //general counters

         Tab2, Tab3,
         Tab4, Tab5    :TPDFValue;    //end of the columns


         Link          :String;            //link-prefix for files

         Ident         :TExportIdentifier; //the exported identifier
         AFile         :TPascalFile;       //file of exported identifiers

         TheIdent      :TIdentifier;       //the exported identifier
begin
 List := TIdentifierList.Create;     //create list for all long functions
 try
   GetAllExports(List);              //get the list
   if not List.IsEmpty then          //if it is not empty
    begin
     //write a new topic for the list
     WriteNewSection(Localize(dtDocumentationExported), 'Exported');
     //write a new topic for the list
     WriteNewSubSection(Localize(dtDocumentationExported), 'ExportedSub');


     //calculate size of the columns
     Tab5 := FPageRect.Right - FPageRect.Left;
     Tab2 := Tab5 * 0.40;
     Tab3 := Tab5 * 0.51;
     Tab4 := Tab5 * 0.64;
     Tab5 := Tab5 * 0.75;


     //use a bold font for the header and write it
     SetFont(DefaultFontType, NormalFontSize, [pfsBold]);
     WriteText(Localize(dtDocumentationExportedIdent), nil, False);
     SetLeftMargin(Tab2);
     WriteText(Localize(dtDocumentationExportedIndex), nil, False);
     SetLeftMargin(Tab3);
     WriteText(Localize(dtDocumentationExportedName), nil, False);
     SetLeftMargin(Tab4);
     WriteText(Localize(dtDocumentationExportedResident), nil, False);
     SetLeftMargin(Tab5);
     WriteText(Localize(dtDocumentationExportedDefFile), nil, False);
     SetFont(DefaultFontType, NormalFontSize);
     WriteNewLine;                      //end the line
     SetLeftMargin(0);                  //reset margin


     for i := 0 to List.Count - 1 do    //for exported identifier
      begin
       Ident := TExportIdentifier(List[i]);

       //search the exported one
       TheIdent := FindIdentifier(Ident.Name, Ident.InFile, Ident.Position);
       //if found, add link to it
       if assigned(TheIdent) and not DoNotDocumentIdentifier(TheIdent) then
        WriteIdentNameLink(TheIdent, pos('.', Ident.Name) <> 0)
       else
        WriteText(IdentifierText(Ident.Name), nil, False); //or just the text

       if Ident.ExportIndex <> '' then    //index for export specified?
        begin
         SetLeftMargin(Tab2);
         WriteParsedText(ExprText(Ident.ExportIndex, Ident), False);
        end;
       if Ident.ExportName <> '' then     //name for export specified?
        begin
         SetLeftMargin(Tab3);
         WriteParsedText(ExprText(Ident.ExportName, Ident), False);
        end;
       if Ident.Resident then             //directive "resident" specified?
        begin
         SetLeftMargin(Tab4);
         WriteText('resident', nil, False);
        end;
       SetLeftMargin(Tab5);
       //write link to the file it is exported in
       WriteFileNameLink(Ident.InFile);


       WriteNewLine;                      //end the line
       SetLeftMargin(0);                  //reset margin
      end;
     WriteNewLine;                      //write an empty line




     for i := 0 to FFiles.Count - 1 do   //for each file
      begin
       AFile := FFiles[i];                 //get it
       if not AFile.Exporteds.IsEmpty then //exports some identifiers?
        begin
         List.RemoveAll(False);                       //clear the list
         for j := 0 to AFile.Exporteds.Count - 1 do   //add all to the list
          begin
           TheIdent := AFile.Exporteds[j];              //get it
           if not DoNotDocumentIdentifier(TheIdent) then
            List.AddIdent(TheIdent);                     //add it if documented
          end;


         if not List.IsEmpty then //some documented exported identifiers found?
          begin
           List.SortExportIdentifiers;        //sort list

           if AFile.InternalNameIndex <> 0 then
            Link := IntToStr(AFile.InternalNameIndex)
           else
            Link := '';
           //write a new topic for the list
           WriteNewSubSection(Localize(dtDocumentationExportedByFilePre) +
                              IdentifierText(AFile.InternalFileName) +
                              Localize(dtDocumentationExportedByFilePost),
                              'Exported_' + Link + AFile.InternalFileName);

⌨️ 快捷键说明

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