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

📄 uhtmldoc.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 5 页
字号:
 end;



 {Write lists of all inherited members of the kind.
 ~param ListBegan if the documentation of this kind has already begun }
 function WriteInheritedList(ListBegan: Boolean): Boolean;
 var      TheRec       :TRecordType;         //the type of inherited members

  {Writes the entry of an inherited member.
  ~param Member     the member (in TheRec and TheFile) to write
  ~param WriteClass if the class should also be written }
  procedure WriteInheritedMember(Member: TIdentifier; WriteClass: Boolean);
  var       Port         :TIdentPortabilities; //portability issues of member
  begin
   Write(F, GetScope(Member.Scope));           //write scope of the member

   //if it is a read-only property, write an icon indicating that
   if (Kind = mkProperty) and TProperty(Member).IsReadOnly then
    Write(F, FCommentFormats.FReadOnlyIconText);

   //if it is an abstract method, write an icon indicating that
   if (Kind = mkMethod) and
      (faAbstract in TFunction(Member).Attributes) then
    Write(F, FCommentFormats.FAbstractIconText);

   Port := Member.Portability;
   if FDeprecatedList.IsIn(Member) then        //get its portability issues
    Include(Port, ipDeprecated);
   //write the portability issues
   Write(F, GetPortabilityIssues(Port));

   Write(F, ' ');
   //if it is a class method, write the indicating reserved word "class"
   if (Kind = mkMethod) and
      (faClassMethod in TFunction(Member).Attributes) then
    Write(F, ReservedWord('class'), ' ');

   //write link to the member
   Write(F, GetRecordFieldNameLink(Member, WriteClass));
  end;

 var       AllList :TIdentifierList;   //list of all inherited members
           i       :Integer;           //counter through the lists
           Member  :TIdentifier;       //each property
           LastRec :TRecordType;       //the type of the previous member
 begin
  TheRec := Ident.GetParent;                 //get parent class
  if assigned(TheRec) then                   //has a known parent class?
   begin
    AllList := TIdentifierList.Create;         //create list for all members
    try
      //get all inherited members
      GetInheritedList(TheRec, AllList, MemberKindClasses[Kind]);

      //if it is a not empty list of methods, filter the incorrect out
      if not AllList.IsEmpty and (Kind = mkMethod) then
       for i := AllList.Count - 1 downto 0 do               //for each method
        begin
         Member := AllList[i];                                //get it
         if ((TFunction(Member).FuncKind <> FuncKind) and     //is not the
             ((FuncKind <> fkFunction) or                     //correct kind?
              (TFunction(Member).FuncKind <> fkProcedure))) or
            DoNotDocumentIdentifier(Member) then
          AllList.RemoveIdent(Member, False);                   //remove it
        end;

      if not AllList.IsEmpty then              //some inherited members?
       begin
        if not ListBegan then                    //no new member in this class?
         WriteLn(F, '<h2 class=member>', Heading, ':</h2>'); //write header now
        ListBegan := True;

        //write header of the inherited members
        WriteLn(F, '<h3 class=member>',
                   Localize(dtDocumentationClassInheritedMembersPrefix),
                   Heading, ':</h3>');

        AllList.SortTo(Ident);                   //sort the list
        LastRec := nil;
        for i := 0 to AllList.Count - 1 do       //for each inherited member
         begin
          Member := AllList[i];                    //get it

          if LastRec <> Member.MemberOf then       //in a new class?
           begin
            if assigned(LastRec) then                //not the first one?
             WriteLn(F, '<br>');                       //start a new line

            LastRec := Member.MemberOf;              //save this class
            //write header for the new class
            WriteLn(F, '<b class=member>', Heading,
                       Localize(dtDocumentationClassInheritedInMiddle),
                       LastRec.Name, ':</b><br>');
           end
          else
           Write(F, ', ');                           //just write a separator

          WriteInheritedMember(Member, False);     //write the member
         end; //for i := 0 to AllList.Count - 1
        WriteLn(F);


        //write header of sorted list
        WriteLn(F, '<h3 class=member>',
                   Localize(dtDocumentationClassInheritedMembersPrefix),
                   Heading,
                   Localize(dtDocumentationClassMembersByNamePostFix),
                   ':</h3>');

        AllList.Sort;                            //sort only by the name
        for i := 0 to AllList.Count - 1 do       //for each inherited member
         begin
          if i <> 0 then                           //if not the first property
           Write(F, ', ');                           //write a spearator
          WriteInheritedMember(AllList[i], True);  //write the member
         end;
        WriteLn(F);
       end; //if not AllList.IsEmpty
    finally
     AllList.RemoveAll(False);
     AllList.Free;                           //free list of inherited member
    end;
   end; //if assigned(TheRec)
  Result := ListBegan;            //return if some members have been documented
 end;

begin
 //if there are some members in this type, direct or inherited,
 if WriteInheritedList(WriteThisList) then //write them
  WriteLn(F, '<hr>');                        //and write a separator
end;


{Writes the documentation of the record-like type.
~param Ident the record-like type whose data should be written }
procedure THTMLDoc.WriteClassDocumentation(Ident: TRecordType);

 {Gets all methods of the kind of the record-like type.
 ~param List  the list to add the methods to
 ~param Kinds the kinds of methods to add to the list }
 procedure GetMethods(List: TIdentifierList; Kinds: TFunctionKinds);
 var       i         :Integer;               //counter through all members
           Func      :TIdentifier;           //each member
 begin
  for i := 0 to Ident.IdentList.Count - 1 do //for each member
   begin
    Func := Ident.IdentList[i];                //get it
    if (Func is TFunction) and                 //is a method and of the
       (TFunction(Func).FuncKind in Kinds) and //searched kind?
       not DoNotDocumentIdentifier(Func) then  //and documented?
     List.AddIdent(Func);                        //add it to the list
   end;
 end;

var       F               :TextFile;        //the file of the documentation
          List            :TIdentifierList; //the list of members

 {Writes a list of the methods of the kinds.
 ~param Kinds  the kinds of the method to include in the list
 ~param Header the header/title of the list}
 procedure WriteMethodList(Kinds: TFunctionKinds; const Header: String);
 begin
  GetMethods(List, Kinds);                      //get the list of the methods
  if not List.IsEmpty then                      //if the list is not empty
   begin
    WriteLn(F, '<h2 class=methodlist>',
               Localize(dtDocumentationClassMemberListHeaderPrefix), Header,
               ':</h2>');                         //write the header of it
    ShowFunctionList(F, List);                    //write the list
    WriteLn(F, '<hr>');                           //insert a separator
    List.RemoveAll(False);                        //remove all methods
   end;
 end;

var       NameIndex       :String;          //internal index of the identifier
begin
 if Ident.InternalNameIndex <> 0 then       //get index of the file
  NameIndex := IntToStr(Ident.InternalNameIndex)
 else
  NameIndex := '';

 //create the file for the documentation
 CreateFile(F, DescFilePreFix[Ident.Kind] + '_' + NameIndex + Ident.Name,
               DescFilePreFix[Ident.Kind] + ' ' + Ident.Name,
               Ident.Name);
 try
   SetCommentIdent(Ident, Ident.InFile);    //set record-like type for comment


   //write type and name of the record-like type
   WriteLn(F, '<h1 class=class>', DescFilePreFix[Ident.Kind], ' ', Ident.Name,
              '</h1>');


   //write the general documentation about the record-like type
   WritePartOfClassDocumentation(Ident, F);

   WriteLn(F, '<hr>');




   List := TIdentifierList.Create;         //create list for methods
   try
     //write a list for each kind of methods
     WriteMethodList([fkConstructor],
                     Localize(dtDocumentationClassMembersConstructors));
     WriteMethodList([fkDestructor],
                     Localize(dtDocumentationClassMembersDestructors));
     WriteMethodList([fkFunction, fkProcedure],
                     Localize(dtDocumentationClassMembersMethods));
   finally
    List.RemoveAll(False);                 //free list for methods
    List.Free;
   end;

   //write documentation about all fields, properties and methods
   WriteMembers(F, Localize(dtDocumentationClassMembersFields),
                   mkField, fkFunction, Ident);
   WriteMembers(F, Localize(dtDocumentationClassMembersProperties),
                   mkProperty, fkFunction, Ident);
   WriteMembers(F, Localize(dtDocumentationClassMembersConstructors),
                   mkMethod, fkConstructor, Ident);
   WriteMembers(F, Localize(dtDocumentationClassMembersDestructors),
                   mkMethod, fkDestructor, Ident);
   WriteMembers(F, Localize(dtDocumentationClassMembersMethods),
                   mkMethod, fkFunction, Ident);

 finally
  EndFile(F);                              //close the file
 end;
end;
















































































{Begins the documentation. }
procedure THTMLDoc.StartDocumentation;
begin
 PrepareForDocumentation;             //prepare for creating the documentation

 //initialize progress "shower"
 Progress.Reset;
 Progress.SetThrowExceptionOnStepIfAbort(True);

 //create Cascading Style-Sheets file if necessary
 Progress.SetWorkText('Creating Cascading Style-Sheets-File...');
 CreateCSSFile;

 if GenerationKind = dgkDelphiDoc then
  begin
   Progress.SetWorkText('Creating Dot-Images...');
   CreateImageFiles;                          //create image files
  end;
end;


{Ends the documentation. }
procedure THTMLDoc.EndDocumentation;
begin
 //let progress "shower" show: the documentaton is finished
 Progress.Reset;
 Progress.SetWorkText('Finished creating documentation!');
 Progress.SetProgressText('Finished!');
 Progress.SetProcessText('');
 Progress.SetMaximum(1);
 Progress.StepProgress;


{$IFNDEF LINUX}

 //if possible: launch the main index file
 if AutoLaunchDocumentation and
    (ShellExecute(0, 'open', PChar(FDestPath + 'index.html'), nil, nil,
                  SW_SHOWNORMAL) <= 32) then
  raise Exception.CreateFmt('Can''t launch index-page: GetLastError: %d'#13'%s',
                            [GetLastError, SysErrorMessage(GetLastError)]);
{$ENDIF}

⌨️ 快捷键说明

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