Преглед на файлове

* Refactor HTML engine so it can more easily be extended

git-svn-id: trunk@48010 -
(cherry picked from commit 7ee4954b0b14278ddb80ab8f63cf25e4ece27bdf)
michael преди 4 години
родител
ревизия
489bd30b82
променени са 8 файла, в които са добавени 125 реда и са изтрити 982 реда
  1. 2 2
      utils/fpdoc/dglobals.pp
  2. 20 7
      utils/fpdoc/dw_basemd.pp
  3. 6 6
      utils/fpdoc/dw_chm.pp
  4. 70 962
      utils/fpdoc/dw_html.pp
  5. 2 3
      utils/fpdoc/dw_markdown.pp
  6. 19 0
      utils/fpdoc/dwriter.pp
  7. 5 1
      utils/fpdoc/fpdoc.lpi
  8. 1 1
      utils/fpdoc/fpdoc.pp

+ 2 - 2
utils/fpdoc/dglobals.pp

@@ -158,8 +158,8 @@ resourcestring
   SMDImageUrl = 'Prefix image URLs with url';
   SMDTheme = 'Use name as theme name';
   SMDNavigation = 'Use scheme for navigation tree, here scheme is one of:';
-  SMDNavSubtree = 'UnitSubTree : put all units in a sub tree of a Units node';
-  SMDNavTree = 'UnitTree : put every units as a node on the same level as packages node';
+  SMDNavSubtree = '    UnitSubTree : put all units in a sub tree of a Units node';
+  SMDNavTree =    '    UnitTree : put every units as a node on the same level as packages node';
 
 
 

+ 20 - 7
utils/fpdoc/dw_basemd.pp

@@ -1,3 +1,16 @@
+{
+    FPDoc  -  Free Pascal Documentation Tool
+    Copyright (C) 2021 by Michael Van Canneyt
+
+    * Basic Markdown output generator. No assumptions about document/documentation structure
+
+    See the file COPYING, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+}
 unit dw_basemd;
 
 {$mode objfpc}{$H+}
@@ -32,7 +45,6 @@ Type
     FFileRendering: TRender;
     FIndentSize: Byte;
     FKeywordRendering: TRender;
-    FModule: TPasModule;
     FPrefix : string;
     FMetadata,
     FMarkDown: TStrings;
@@ -486,7 +498,7 @@ end;
 procedure TBaseMarkdownWriter.DescrWriteImageEl(const AFileName, ACaption, ALinkName : DOMString);
 
 Var
-  D,FN : String;
+  aLink,D,FN : String;
   L : integer;
 begin
   // Determine URL for image.
@@ -498,15 +510,16 @@ begin
   If (L>0) and (D[L]<>'/') then
     D:=D+'/';
 
-  FN:=UTF8Decode(D + BaseImageURL) + AFileName;
+  FN:=D + BaseImageURL+ Utf8Encode(AFileName);
   EnsureEmptyLine;
-  AppendToLine('!['+aCaption+']('+FN+')',False);
+  aLink:='!['+UTF8Encode(aCaption)+']('+FN+')';
+  AppendToLine(aLink,False);
 end;
 
 procedure TBaseMarkdownWriter.DescrWriteFileEl(const AText: DOMString);
 
 begin
-  AppendRendered(aText,FileRendering);
+  AppendRendered(UTF8Encode(aText),FileRendering);
 end;
 
 procedure TBaseMarkdownWriter.DescrWriteKeywordEl(const AText: DOMString);
@@ -516,7 +529,7 @@ end;
 
 procedure TBaseMarkdownWriter.DescrWriteVarEl(const AText: DOMString);
 begin
-  AppendRendered(aText,VarRendering);
+  AppendRendered(UTF8Encode(aText),VarRendering);
 end;
 
 procedure TBaseMarkdownWriter.DescrBeginLink(const AId: DOMString);
@@ -556,7 +569,7 @@ end;
 
 procedure TBaseMarkdownWriter.DescrBeginURL(const AURL: DOMString);
 begin
-  FLink:=aURL;
+  FLink:=UTF8Encode(aURL);
   AppendToLine('[');
 end;
 

+ 6 - 6
utils/fpdoc/dw_chm.pp

@@ -2,7 +2,7 @@ unit dw_chm;
 
 interface
 
-uses Classes, DOM, DOM_HTML,
+uses Classes, DOM,
     dGlobals, PasTree, dwriter, dw_html, chmwriter, chmtypes, chmsitemap;
 
 type
@@ -63,7 +63,7 @@ type
 
 implementation
 
-uses SysUtils, HTMWrite;
+uses SysUtils, HTMWrite, dw_basehtml;
 
 { TCHmFileNameAllocator }
 
@@ -179,12 +179,12 @@ begin
     DoLog('Note: --index-page not assigned. Using default "index.html"');
   end;
   
-  if FCSSFile <> '' then
+  if CSSFile <> '' then
   begin
-    if not FileExists(FCSSFile) Then
-      Raise Exception.CreateFmt('Can''t find CSS file "%S"',[FCSSFILE]);
+    if not FileExists(CSSFile) Then
+      Raise Exception.CreateFmt('Can''t find CSS file "%S"',[CSSFILE]);
     TempStream := TMemoryStream.Create;
-    TempStream.LoadFromFile(FCSSFile);
+    TempStream.LoadFromFile(CSSFile);
     TempStream.Position := 0;
     FChm.AddStreamToArchive('fpdoc.css', '/', TempStream, True);
     TempStream.Free;

Файловите разлики са ограничени, защото са твърде много
+ 70 - 962
utils/fpdoc/dw_html.pp


+ 2 - 3
utils/fpdoc/dw_markdown.pp

@@ -1,9 +1,8 @@
 {
     FPDoc  -  Free Pascal Documentation Tool
-    Copyright (C) 2000 - 2005 by
-      Areca Systems GmbH / Sebastian Guenther, [email protected]
+    Copyright (C) 2021 by Michael Van Canneyt
 
-    * HTML/XHTML output generator
+    * Markdown generator, multi-file
 
     See the file COPYING, included in this distribution,
     for details about the copyright.

+ 19 - 0
utils/fpdoc/dwriter.pp

@@ -186,10 +186,12 @@ type
     procedure DescrEndTableRow; virtual; abstract;
     procedure DescrBeginTableCell; virtual; abstract;
     procedure DescrEndTableCell; virtual; abstract;
+
     Property CurrentContext : TPasElement Read FContext ;
   public
     Constructor Create(APackage: TPasPackage; AEngine: TFPDocEngine); virtual;
     destructor Destroy;  override;
+    procedure AddModuleIdentifiers(AModule: TPasModule; L: TStrings);
     property Engine : TFPDocEngine read FEngine;
     Property Package : TPasPackage read FPackage;
     Property Topics : TList Read FTopics;
@@ -526,6 +528,7 @@ begin
          and (AModule.InterfaceSection.Classes.Count>0);
 end;
 
+
 procedure TMultiFileDocWriter.AddPages(AElement: TPasElement; ASubpageIndex: Integer;
   AList: TFPList);
 var
@@ -1028,6 +1031,22 @@ begin
   Inherited;
 end;
 
+procedure TFPDocWriter.AddModuleIdentifiers(AModule : TPasModule; L : TStrings);
+
+begin
+  if assigned(AModule.InterfaceSection) Then
+   begin
+      AddElementsFromList(L,AModule.InterfaceSection.Consts);
+      AddElementsFromList(L,AModule.InterfaceSection.Types);
+      AddElementsFromList(L,AModule.InterfaceSection.Functions);
+      AddElementsFromList(L,AModule.InterfaceSection.Classes);
+      AddElementsFromList(L,AModule.InterfaceSection.Variables);
+      AddElementsFromList(L,AModule.InterfaceSection.ResStrings);
+   end;
+end;
+
+
+
 function TFPDocWriter.InterpretOption(const Cmd, Arg: String): Boolean;
 begin
   Result:=False;

+ 5 - 1
utils/fpdoc/fpdoc.lpi

@@ -48,7 +48,7 @@
         <PackageName Value="FCL"/>
       </Item1>
     </RequiredPackages>
-    <Units Count="19">
+    <Units Count="20">
       <Unit0>
         <Filename Value="fpdoc.pp"/>
         <IsPartOfProject Value="True"/>
@@ -132,6 +132,10 @@
         <Filename Value="dw_basemd.pp"/>
         <IsPartOfProject Value="True"/>
       </Unit18>
+      <Unit19>
+        <Filename Value="dw_basehtml.pp"/>
+        <IsPartOfProject Value="True"/>
+      </Unit19>
     </Units>
   </ProjectOptions>
   <CompilerOptions>

+ 1 - 1
utils/fpdoc/fpdoc.pp

@@ -37,7 +37,7 @@ uses
   dw_man,    // Man page writer
   dw_linrtf, // linear RTF writer
   dw_txt,    // TXT writer
-  fpdocproj, mkfpdoc, dw_basemd;
+  fpdocproj, mkfpdoc, dw_basemd, dw_basehtml;
 
 
 Type

Някои файлове не бяха показани, защото твърде много файлове са промени