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

📄 updfdoc.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 5 页
字号:
           for j := 0 to List.Count - 1 do    //write each identifier
            WriteParsedText(GetExportsDeclaration(TExportIdentifier(List[j])));

           WriteNewLine;                      //write an empty line
          end; //if not List.IsEmpty
        end; //if not AFile.Exporteds.IsEmpty
      end; //for i := 0 to FFiles.Count - 1


     Result := True;                   //documentation written
    end //if not List.IsEmpty
   else
    Result := False;                 //no long functions found
 finally
  List.RemoveAll(False);           //remove all identifiers (don't free them)
  List.Free;                       //free list of the exported identifiers
 end;
end;





















{Starts the list of long functions. Not used!
~param TheFile the file to write the list to (is opened here)
~param Pre     the text before an entry is returned with this parameter
~param Middle  the text is an entry between the number of lines and the
               link to the function is returned with this parameter
~param Post    the text after an entry is returned with this parameter }
procedure TPDFDoc.StartLongFunctionsLists(var TheFile: TextFile;
                                          var Pre, Middle, Post: String);
begin
 assert(False);     //not called
end;

{Ends the list of long functions. Not used!
~param TheFile the file the list has been written to (is closed here) }
procedure TPDFDoc.EndLongFunctionsLists(var TheFile: TextFile);
begin
 assert(False);     //not called
end;


{Write a list of all long functions.
~result if a list was generated (if there are some long functions) }
function TPDFDoc.WriteLongFunctionList: Boolean;
var      List                  :TIdentifierList; //list of long functions
         i                     :Integer;      //counter through the list
         EndTab1               :TPDFValue;    //end of the first column
         Tab2                  :TPDFValue;    //positions of the second columns
         Ident                 :TIdentifier;  //each function
         NumberOfLines         :String;       //number of lines of the function
begin
 List := TIdentifierList.Create;       //create list for all long functions
 try
   GetAllLongFunctions(List);         //get the list
   if not List.IsEmpty then           //if it is not empty
    begin
     List.SortFunctionLength;           //sort list by the length

     //write the section of the list of long functions
     WriteNewSection(Localize(dtDocumentationLongFunctions), 'LongFunctions');

     //use a bold font for the header and write it
     SetFont(DefaultFontType, NormalFontSize, [pfsBold]);
     WriteText(Localize(dtDocumentationLongFunctionsLinesMiddle), nil, False);
     EndTab1 := FXPos - FPageRect.Left; //get position of the columns
     Tab2 := EndTab1 + FWriter.TextWidth('  ');
     WriteSimpleLine('  ' + Localize(dtDocumentationLongFunctionsNames),
                     False);
     SetFont(DefaultFontType, NormalFontSize);

     for i := 0 to List.Count - 1 do    //for each long function
      begin
       Ident := List[i];                  //get it

       //get the number of lines
       NumberOfLines := IntToStr(TFunction(Ident).BodySize.Row);
       SetLeftMargin(EndTab1 - FWriter.TextWidth(NumberOfLines));
       WriteText(NumberOfLines, nil, False); //and write it right-aligned
       SetLeftMargin(Tab2);               //go to the second column
       if assigned(Ident.MemberOf) then   //write the link to the function
        WriteRecordFieldNameLink(Ident, True)
       else
        WriteIdentNameLink(Ident);
       WriteNewLine;                      //end the line
       SetLeftMargin(0);                  //reset margin
      end;

     Result := True;                    //list have been writte
    end
   else
    Result := False;                    //no long functions
 finally
  List.RemoveAll(False);           //remove all identifiers (don't free them)
  List.Free;                          //free list of the long functions
 end;
end;













{Generates an index about all identifiers and files beginning with the
 character.
~param List       the list of all identifiers and files to generate the index
                  of
~param EntryIndex the index of the first entry with the letter
~param Index      the character to generate the index for
~result the first entry not in the index (i.e. EntryIndex for the next letter)}
function TPDFDoc.DoGenerateIndex(List: TIdentifierFileList;
                                 EntryIndex: Integer; Index: Char): Integer;
var      Tab2           :TPDFValue;    //position of the second column
         Tab3           :TPDFValue;    //position of the third column
         Count          :Integer;      //number of identifiers in the list
         EndReached     :Boolean;      //if end of the index has been reached
         S              :String;       //general string
         Ident          :TIdentifier;  //identifier in the list
         FileParser     :TPascalFile;  //file of the identifier
begin
 //start the section for the index with this character
 WriteNewSection(Localize(dtDocumentationIndexPre) + Index +
                 Localize(dtDocumentationIndexPost),
                 'Index_' + Index);

 //calculate positions of the columns
 Tab2 := (FPageRect.Right - FPageRect.Left) * 0.4;
 Tab3 := Tab2 * 1.75;

 //use bold font for writing the header
 SetFont(DefaultFontType, NormalFontSize, [pfsBold]);
 //write the header of the table
 WriteText(Localize(dtDocumentationIndexIdentifier), nil, False);
 SetLeftMargin(Tab2);
 WriteText(Localize(dtDocumentationIndexFile), nil, False);
 SetLeftMargin(Tab3);
 WriteText(Localize(dtDocumentationIndexClass), nil, False);
 SetFont(DefaultFontType, NormalFontSize);  //reset font
 WriteNewLine;                              //end the line
 SetLeftMargin(0);                          //reset the margin


 EndReached := False;                  //so far not the end reached
 Count := List.Count;                  //get number of identifiers in the index
 while (EntryIndex < Count) and not EndReached do //while end not reached
  begin
   Ident := List.GetIdentIndex(EntryIndex, FileParser); //get entry
   if assigned(Ident) then               //is an identifier?
    S := Ident.Name                        //use its name for index
   else
    S := FileParser.InternalFileName;      //it is a file, use its name
   assert(S <> '');

   EndReached := UpCase(S[1]) <> Index;  //entry is still in index
   if not EndReached then                //of this character?
    begin
     if assigned(Ident) then               //not just a file?
      begin
       FileParser := Ident.InFile;
       if assigned(Ident.MemberOf) then       //write link to the identifier
        WriteRecordFieldNameLink(Ident)
       else
        WriteIdentNameLink(Ident);
      end;

     SetLeftMargin(Tab2);                  //go to the second column
     if DoNotDocumentIdentifier(nil, FileParser) then //not documented?
      //write just the name of the file
      WriteText(IdentifierText(FileParser.InternalFileName), nil, False)
     else
      WriteFileNameLink(FileParser);           //or link to it

     //in a record-like type?
     if assigned(Ident) and assigned(Ident.MemberOf) then
      begin
       assert(not DoNotDocumentIdentifier(Ident.MemberOf));
       SetLeftMargin(Tab3);                  //go to the third column and write
       WriteIdentNameLink(Ident.MemberOf);   //and write it
      end;
     WriteNewLine;                         //end the line
     SetLeftMargin(0);                     //and reset the position

     inc(EntryIndex)                       //next entry in the list
    end; //if not EndReached
  end; //while not EndReached

 if Index <> '_' then                  //not the last index section?
  begin
   WriteNewLine;                         //insert additional vertical space
   WriteNewLine;
  end;

 Result := EntryIndex;                 //return index of next entry in the list
end;


{Writes the current page of the user documentation. Will be called by
 ~[link CreateUserDocumentation] for each page. }
procedure TPDFDoc.CreateUserDocPage;
var       Title    :String;      //the title of the page
          Content  :String;      //and its content
begin
 //get title and content of the page of user documentation
 Content := GetUserDocumentationPage(CurrentUserDocPage, Title);

 //write a section for the page of user documentation
 WriteNewSection(ParseCommentText(Title), GetPageURI(CurrentUserDocPage));

 //write the content of the page of user documentation
 WriteParsedText(InternFormatCharacter + InternFormatAlignBlock +
                 ParseCommentText(Content) +
                 InternFormatCharacter + InternFormatParagraph);
end;

























{Writes a list of identifiers.
~param Description the description of the list
~param TopicName   the (internal) name of the page to create
~param List        the list to write }
procedure TPDFDoc.WriteListSection(const Description, TopicName: String;
                                   List: TIdentifierFileList);

 {Writes the lists of identifiers in the list.
 ~param Idents the list of identifiers }
 procedure WriteIdentifierList(Idents: TIdentifierList);
 var       i                  :Integer;             //counter through the lists
           Ident              :TIdentifier;         //each identifier
           //all identifiers directly in files (no members of record-like
           NoRecord           :TIdentifierList;    // types)
 begin
  //write a new topic

  WriteNewSubSection(Localize(dtDocumentationIdentListListOfIdentsAlphaPre) +
                     Description +
                     Localize(dtDocumentationIdentListListOfIdentsAlphaPost),
                     TopicName + '.idents');
  Idents.Sort;                      //sort the list
  for i := 0 to Idents.Count - 1 do //write each identifier in the list
   begin
    Ident := Idents[i];
    if assigned(Ident.MemberOf) then
     WriteRecordFieldNameLink(Ident, True)
    else
     WriteIdentNameLink(Ident);
    WriteNewLine;
   end;
  WriteNewLine;
  WriteNewLine;


  //write another topic
  WriteNewSubSection(Localize(dtDocumentationIdentListListOfIdentsByClassPre) +
                     Description +
                     Localize(dtDocumentationIdentListListOfIdentsByClassPost),
                     TopicName + '.identsbyclasses');

  //create lists for identifiers not in record-like types (no members)
  NoRecord := TIdentifierList.Create;
  try
    for i := Idents.Count - 1 downto 0 do //split list in two
     begin
      Ident := Idents[i];
      if not assigned(Idents[i].MemberOf) then //all identifiers directly in files
       begin
        NoRecord.AddIdent(Ident);
        Idents.Remove(i, False);            //are moved to the other list
       end;
     end;

    if not NoRecord.IsEmpty then          //are two lists?
     begin
      NoRecord.Sort;                        //sort list of identifiers in files
      for i := 0 to NoRecord.Count - 1 do   //write the list
       begin
        WriteIdentNameLink(NoRecord[i]);
        WriteNewLine;
       end;
      if not Idents.IsEmpty then            //other list follows?
       WriteNewLine;                          //add an extra space
     end;
  finally
   NoRecord.RemoveAll(False);             //don't free identifiers
   NoRecord.Free;                         //free the list
  end;

  if not Idents.IsEmpty then              //are two lists?
   begin
    Idents.SortByClass;                     //sort the list of members
    for i := 0 to Idents.Count - 1 do       //write the list
     begin
      WriteRecordFieldNameLink(Idents[i], True);
      WriteNewLine;
     end;
   end;
  WriteNewLine;
  WriteNewLine;
 end;


var       Files                  :TIdentifierFileList; //all files of the list
          Classes, Idents        :TIdentifierList; //identifiers of the list
          i                      :Integer;      //counter through the lists
          Ident                  :TIdentifier;  //each identifier
          FilePa

⌨️ 快捷键说明

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