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

📄 uichtmldoc.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 5 页
字号:
         rk        :TRecordKind;
begin
 if FProjectName <> '' then            //name of project defined?
  //append it to the title
  Title := TitlePart + ' - ' + HandleRawText(FProjectName)
 else
  Title := TitlePart;

 Keys := ReformatKeyWords(KeyWords);

 //open the file
 Result := TBufferStream.CreateFile(FDestPath + FileName + FileExtension);
 try
   if TextHeaderFile <> '' then        //custom header supplied?
    WriteFileHeader(Result, Title, Keys, '', HeaderContentProc) //write it
   else
    begin
     if UseXHTMLHeader then              //write the DTD of the file
      begin
       Result.WriteString('<?xml version="1.0" encoding="');
       Result.WriteString(CharacterEncoding);
       Result.WriteString('"?>');
       Result.WriteString(NewLine);
       Result.WriteString(DTD_XHTML_Text);
       Result.WriteString(NewLine);
       Result.WriteString('<html xmlns="http://www.w3.org/1999/xhtml">')
      end
     else
      begin
       Result.WriteString(DTD_HTMLTrans_Text);
       Result.WriteString(NewLine);
       Result.WriteString('<html>');
      end;
     Result.WriteString(NewLine);
     Result.WriteString('<head>');
     Result.WriteString(NewLine);
     Result.WriteString('  <meta http-equiv="Content-Type" content="text/html; charset=');
     Result.WriteString(CharacterEncoding);
     Result.WriteCharacter('"');
     Result.WriteString(EmptyTagEnd[XMLConformity]);
     Result.WriteCharacter('>');
     Result.WriteString(NewLine);
     Result.WriteString('  <meta http-equiv="Content-Style-Type" content="text/css"');
     Result.WriteString(EmptyTagEnd[XMLConformity]);
     Result.WriteCharacter('>');
     Result.WriteString(NewLine);
     Result.WriteString('  <title>');
     Result.WriteString(Title);          //write the title of the page
     Result.WriteString(' - JADD - Just Another DelphiDoc</title>');
     Result.WriteString(NewLine);
     if Keys <> '' then
      begin
       Result.WriteString('  <meta name="keywords" content="');
       Result.WriteString(Keys);
       Result.WriteCharacter('"');
       Result.WriteString(EmptyTagEnd[XMLConformity]);
       Result.WriteCharacter('>');
       Result.WriteString(NewLine);
      end;
     Result.WriteString('  <meta name="Generator" content="JADD - Just Another DelphiDoc"');
     Result.WriteString(EmptyTagEnd[XMLConformity]);
     Result.WriteCharacter('>');
     Result.WriteString(NewLine);
     Result.WriteString('  <link rel="stylesheet" type="text/css" href="');
     Result.WriteString(CSSFileName);    //include the CSS file
     Result.WriteString('" title="Style"');
     Result.WriteString(EmptyTagEnd[XMLConformity]);
     Result.WriteCharacter('>');
     Result.WriteString(NewLine);

     if Assigned(HeaderContentProc) then //additional content for the header?
      HeaderContentProc(Result);           //let it be written

     Result.WriteString('</head>');
     Result.WriteString(NewLine);
     Result.WriteString('<body>');
     Result.WriteString(NewLine);
     //write links to main files
     Result.WriteString('<table width="100%" class="headerlinks"><tbody><tr>');
     Result.WriteString(NewLine);
     //link to main index
     Result.WriteString('<td');
     if not UseCSS then
      Result.WriteString(' align="center"');
     Result.WriteString('><a href="index');
     Result.WriteString(FileExtension);
     Result.WriteString('">');
     Result.WriteString(Localize(dtDocumentationLinkIndex));
     Result.WriteString('</a></td>');
     Result.WriteString(NewLine);

     //only if this kind of documentation is generated
     if GenerationKind = dgkDelphiDoc then
      begin                              //generate links to files and types
       //link to list of files
       Result.WriteString('<td');
       if not UseCSS then
        Result.WriteString(' align="center"');
       Result.WriteString('><a href="FileList');
       Result.WriteString(FileExtension);
       Result.WriteString('">');
       Result.WriteString(Localize(dtDocumentationLinkFiles));
       Result.WriteString('</a></td>');
       Result.WriteString(NewLine);
       //links to lists of all record-like types
       for rk := low(rk) to high(rk) do
        begin
         Result.WriteString('<td');
         if not UseCSS then
          Result.WriteString(' align="center"');
         Result.WriteString('><a href="');
         Result.WriteString(DescFilePreFix[rk]);
         Result.WriteString('List');
         Result.WriteString(FileExtension);
         Result.WriteString('">');
         Result.WriteString(Localize(Plurals[rk]));
         Result.WriteString('</a></td>');
         Result.WriteString(NewLine);
        end;
      end;

     Result.WriteString('</tr></tbody></table>');
     Result.WriteString(NewLine);
     Result.WriteString(TagConstants.hr);   //end the header
     if UseXHTMLHeader then            //if it has to conform to XHTML
      begin
       Result.WriteString('<div>');      //create a block element to allow text
       Result.WriteString(NewLine);       //outside of paragraphs
      end;
    end;
 except                             //in case of an error
   Result.Free;                       //close the file, then
   raise;                             //forward the error
 end;
end;




{Writes the footer of a HTML file and closes it.
~param F the HTML file to end and close }
procedure TICHTMLDoc.EndFile(F: TBufferStream);
begin
 try
   if TextFooterFile <> '' then       //custom footer supplied?
    F.WriteString(FTextFooter)          //just write it
   else
    begin
     if UseXHTMLHeader then            //if it has to conform to XHTML
      begin
       F.WriteString('</div>');          //end the block element with all the
       F.WriteString(NewLine);            //content
      end;

//     F.WriteString('<div align="center"><font size="-2">Generated by JADD - Just Another DelphiDoc</font></div>');
//     F.WriteString(NewLine);
     F.WriteString('</body>');
     F.WriteString(NewLine);
     F.WriteString('</html>');          //end the HTML file
    end;
   F.WriteString(NewLine);
 finally
  F.Free;                             //finally close the file
 end;
end;































{Writes a list of the functions in the current file or of the methods in the
 current class or interface.
~param F     the file to write the documentation to
~param List  the list of functions to generate a list from }
procedure TICHTMLDoc.ShowFunctionList(F: TBufferStream; List: TIdentifierList);
var       Visitor   :TICSummaryVisitor;    //the extractor of summaries
          i         :Integer;              //counter through all identifiers
          Func      :TIdentifier;          //each identifier
          Comment   :TICIdentifierComment; //comment of the identifier
          Port      :TIdentPortabilities;  //its portability issues
begin
 if not List.IsEmpty then           //if the list is not empty
  begin
   List.Sort;                         //sort it

   F.WriteString('<dl class="funclist">'); //start the list
   F.WriteString(NewLine);

   //create the object to extract the summaries
   Visitor := TICSummaryVisitor.Create;
   try
     for i := 0 to List.Count - 1 do  //for each function in the list
      begin
       Func := List[i];                      //get it
       Assert(Func is TFunction);
       Assert(not DoNotDocumentIdentifier(Func));

       F.WriteString('  <dt>');              //start its entry
       F.WriteString(GetScope(Func.Scope));  //write its scope

       SetCommentIdent(Func, Func.InFile);
       Comment := Comments.Comment[Func];    //get comment of the function

       //write its portability issues
       Port := Func.Portability;
       if Comment.Deprecateds.HasChildren then
        Include(Port, ipDeprecated);
       F.WriteString(GetPortabilityIssues(Port));

       if faAbstract in TFunction(Func).Attributes then //if it is abstract
        F.WriteString(GetAbstractIcon);                 //write indicating icon
       F.WriteCharacter(' ');

       if faClassMethod in TFunction(Func).Attributes then //if it is a class
        begin
         F.WriteString(AsReservedWord('class')); //method, write it
         F.WriteCharacter(' ');
        end;

       //write the kind of the function and its linked name
       F.WriteString(AsReservedWord(FuncNames[TFunction(Func).FuncKind]));
       F.WriteString(' <a href="#I_');
       if Func.InternalNameIndex <> 0 then
        F.WriteString(IntToStr(Func.InternalNameIndex));
       F.WriteString(Func.Name);
       F.WriteString('">');
       F.WriteString(Func.Name);
       F.WriteString('</a>');
       F.WriteString('</dt>');             //end the definition
       F.WriteString(NewLine);

       F.WriteString('  <dd>');            //start the short description


       //check whether it is deprecated
       if (ipDeprecated in Func.Portability) or
          Comment.Deprecateds.HasChildren then
        begin
         F.WriteString('<strong>');
         F.WriteString(Localize(dtSpecialDeprecated));
         F.WriteString('</strong> ');
        end;

       //main comment available?
       if Assigned(Comment.MainDocumentation) then
        //write the summary
        F.WriteString(HandleRawText(Visitor.GetSummary(Comment)));

       F.WriteString('</dd>');             //end the short description
       F.WriteString(NewLine);
      end; //for i := 0 to List.Count - 1
    finally
     Visitor.Free;                       //free extractor of summaries
    end;

   F.WriteString('</dl>');               //end the list of the functions
   F.WriteString(NewLine);
  end; //if not List.IsEmpty
end;





































          //header titles of the lists of different kinds of identifiers in
          //files
const     DeclName: array[TWriteKind] of TDocumentationTexts =
                    (dtDocumentationFileDeclarationsHeaderVar,
                     dtDocumentationFileDeclarationsHeaderThreadVar,
                     dtDocumentationFileDeclarationsHeaderConst,
                     dtDocumentationFileDeclarationsHeaderResourceString,
                     dtDocumentationFileDeclarationsHeaderSimpleTypes,
                     dtDocumentationFileDeclarationsHeaderFunctions);
          //the classes of the lists of different kinds of identifiers in files
          DeclTypeClass: array[TWriteKind] of TIdentifierClass =
             (TVariable,       TVariable, TConstant,
              TResourceString, TType,     TFunction);
          //the name of anchors to the beginning of the lists of different
          //kinds of identifiers in files
          AnchorDeclName: array[TWriteKind] of String =
             ('Variables',       'ThreadVariables', 'Constants',
              'ResourceStrings', 'SimpleTypes',     'Functions');



{Writes a short, linked list of the identifiers in the file of the specified
 kind.

⌨️ 快捷键说明

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