|
@@ -91,6 +91,7 @@ type
|
|
procedure AddElementsFromList(L: TStrings; List: TFPList; UsePathName : Boolean = False);
|
|
procedure AddElementsFromList(L: TStrings; List: TFPList; UsePathName : Boolean = False);
|
|
Procedure DoLog(Const Msg : String);
|
|
Procedure DoLog(Const Msg : String);
|
|
Procedure DoLog(Const Fmt : String; Args : Array of const);
|
|
Procedure DoLog(Const Fmt : String; Args : Array of const);
|
|
|
|
+ Procedure OutputResults(); virtual;
|
|
procedure Warning(AContext: TPasElement; const AMsg: String);
|
|
procedure Warning(AContext: TPasElement; const AMsg: String);
|
|
procedure Warning(AContext: TPasElement; const AMsg: String;
|
|
procedure Warning(AContext: TPasElement; const AMsg: String;
|
|
const Args: array of const);
|
|
const Args: array of const);
|
|
@@ -169,6 +170,9 @@ type
|
|
procedure DescrEndTableRow; virtual; abstract;
|
|
procedure DescrEndTableRow; virtual; abstract;
|
|
procedure DescrBeginTableCell; virtual; abstract;
|
|
procedure DescrBeginTableCell; virtual; abstract;
|
|
procedure DescrEndTableCell; virtual; abstract;
|
|
procedure DescrEndTableCell; virtual; abstract;
|
|
|
|
+ procedure PrepareDocumentation; virtual;
|
|
|
|
+ // Descendents must override this.
|
|
|
|
+ procedure DoWriteDocumentation; virtual; Abstract;
|
|
|
|
|
|
Property CurrentContext : TPasElement Read FContext ;
|
|
Property CurrentContext : TPasElement Read FContext ;
|
|
public
|
|
public
|
|
@@ -184,7 +188,8 @@ type
|
|
Class Function FileNameExtension : String; virtual;
|
|
Class Function FileNameExtension : String; virtual;
|
|
Class Procedure Usage(List : TStrings); virtual;
|
|
Class Procedure Usage(List : TStrings); virtual;
|
|
Class procedure SplitImport(var AFilename, ALinkPrefix: String); virtual;
|
|
Class procedure SplitImport(var AFilename, ALinkPrefix: String); virtual;
|
|
- procedure WriteDoc; virtual; Abstract;
|
|
|
|
|
|
+ // Here we start the generation of documentation
|
|
|
|
+ procedure WriteDocumentation;
|
|
Function WriteDescr(Element: TPasElement) : TDocNode;
|
|
Function WriteDescr(Element: TPasElement) : TDocNode;
|
|
procedure WriteDescr(Element: TPasElement; DocNode: TDocNode);
|
|
procedure WriteDescr(Element: TPasElement; DocNode: TDocNode);
|
|
procedure WriteDescr(AContext: TPasElement; DescrNode: TDOMElement); virtual;
|
|
procedure WriteDescr(AContext: TPasElement; DescrNode: TDOMElement); virtual;
|
|
@@ -250,14 +255,21 @@ Type
|
|
FCurDirectory: String;
|
|
FCurDirectory: String;
|
|
FModule: TPasModule;
|
|
FModule: TPasModule;
|
|
FPageInfos: TFPObjectList; // list of TPageInfo objects
|
|
FPageInfos: TFPObjectList; // list of TPageInfo objects
|
|
|
|
+ FLinkUnresolvedCnt: Integer;
|
|
function GetPageCount: Integer;
|
|
function GetPageCount: Integer;
|
|
|
|
|
|
Protected
|
|
Protected
|
|
FAllocator: TFileAllocator;
|
|
FAllocator: TFileAllocator;
|
|
- function ResolveLinkID(const Name: String; Level: Integer=0): DOMString;
|
|
|
|
|
|
+ Procedure LinkUnresolvedInc();
|
|
|
|
+ // General resolving routine
|
|
|
|
+ function ResolveLinkID(const Name: String): DOMString;
|
|
|
|
+ // Simplified resolving routine. Excluded last path after dot
|
|
|
|
+ function ResolveLinkIDUnStrict(const Name: String): DOMString;
|
|
function ResolveLinkIDInUnit(const Name,AUnitName: String): DOMString;
|
|
function ResolveLinkIDInUnit(const Name,AUnitName: String): DOMString;
|
|
function ResolveLinkWithinPackage(AElement: TPasElement; ASubpageIndex: Integer): String;
|
|
function ResolveLinkWithinPackage(AElement: TPasElement; ASubpageIndex: Integer): String;
|
|
- Function CreateAllocator : TFileAllocator; virtual; abstract;
|
|
|
|
|
|
+ procedure PrepareDocumentation; override;
|
|
|
|
+ function CreateAllocator() : TFileAllocator; virtual; abstract;
|
|
|
|
+ Procedure OutputResults(); override;
|
|
// aFileName is the filename allocated by the Allocator, nothing prefixed.
|
|
// aFileName is the filename allocated by the Allocator, nothing prefixed.
|
|
procedure WriteDocPage(const aFileName: String; aElement: TPasElement; aSubPageIndex: Integer); virtual; abstract;
|
|
procedure WriteDocPage(const aFileName: String; aElement: TPasElement; aSubPageIndex: Integer); virtual; abstract;
|
|
procedure AllocatePages; virtual;
|
|
procedure AllocatePages; virtual;
|
|
@@ -272,12 +284,14 @@ Type
|
|
function GetFileBaseDir(aOutput: String): String; virtual;
|
|
function GetFileBaseDir(aOutput: String): String; virtual;
|
|
function InterPretOption(const Cmd, Arg: String): boolean; override;
|
|
function InterPretOption(const Cmd, Arg: String): boolean; override;
|
|
function ModuleHasClasses(AModule: TPasModule): Boolean;
|
|
function ModuleHasClasses(AModule: TPasModule): Boolean;
|
|
|
|
+ // Allocate pages etc.
|
|
|
|
+ Procedure DoWriteDocumentation; override;
|
|
|
|
+
|
|
Property PageInfos : TFPObjectList Read FPageInfos;
|
|
Property PageInfos : TFPObjectList Read FPageInfos;
|
|
Property SubPageNames: Boolean Read FSubPageNames;
|
|
Property SubPageNames: Boolean Read FSubPageNames;
|
|
Public
|
|
Public
|
|
constructor Create(APackage: TPasPackage; AEngine: TFPDocEngine); override;
|
|
constructor Create(APackage: TPasPackage; AEngine: TFPDocEngine); override;
|
|
Destructor Destroy; override;
|
|
Destructor Destroy; override;
|
|
- procedure WriteDoc; override;
|
|
|
|
class procedure Usage(List: TStrings); override;
|
|
class procedure Usage(List: TStrings); override;
|
|
property PageCount: Integer read GetPageCount;
|
|
property PageCount: Integer read GetPageCount;
|
|
Property Allocator : TFileAllocator Read FAllocator;
|
|
Property Allocator : TFileAllocator Read FAllocator;
|
|
@@ -389,6 +403,7 @@ begin
|
|
inherited Create(APackage, AEngine);
|
|
inherited Create(APackage, AEngine);
|
|
FPageInfos:=TFPObjectList.Create;
|
|
FPageInfos:=TFPObjectList.Create;
|
|
FSubPageNames:= False;
|
|
FSubPageNames:= False;
|
|
|
|
+ FLinkUnresolvedCnt:=0;
|
|
end;
|
|
end;
|
|
|
|
|
|
destructor TMultiFileDocWriter.Destroy;
|
|
destructor TMultiFileDocWriter.Destroy;
|
|
@@ -403,8 +418,18 @@ begin
|
|
Result := PageInfos.Count;
|
|
Result := PageInfos.Count;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TMultiFileDocWriter.ResolveLinkID(const Name: String; Level : Integer = 0): DOMString;
|
|
|
|
|
|
+procedure TMultiFileDocWriter.OutputResults();
|
|
|
|
+begin
|
|
|
|
+ DoLog('Unresolved links: %d', [FLinkUnresolvedCnt]);
|
|
|
|
+ inherited OutputResults();
|
|
|
|
+end;
|
|
|
|
|
|
|
|
+procedure TMultiFileDocWriter.LinkUnresolvedInc();
|
|
|
|
+begin
|
|
|
|
+ Inc(FLinkUnresolvedCnt);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TMultiFileDocWriter.ResolveLinkID(const Name: String): DOMString;
|
|
var
|
|
var
|
|
res,s: String;
|
|
res,s: String;
|
|
|
|
|
|
@@ -412,16 +437,46 @@ begin
|
|
res:=Engine.ResolveLink(Module,Name, True);
|
|
res:=Engine.ResolveLink(Module,Name, True);
|
|
// engine can return backslashes on Windows
|
|
// engine can return backslashes on Windows
|
|
if Length(res) > 0 then
|
|
if Length(res) > 0 then
|
|
- begin
|
|
|
|
- s:=Copy(Res, 1, Length(CurDirectory) + 1);
|
|
|
|
|
|
+ begin
|
|
|
|
+ s:=Copy(Res, 1, Length(CurDirectory) + 1);
|
|
if (S= CurDirectory + '/') or (s= CurDirectory + '\') then
|
|
if (S= CurDirectory + '/') or (s= CurDirectory + '\') then
|
|
- Res := Copy(Res, Length(CurDirectory) + 2, Length(Res))
|
|
|
|
|
|
+ begin
|
|
|
|
+ // TODO: I didn`t see a call to this code on a processing the lcl ana lazutil. What is that?
|
|
|
|
+ Res := Copy(Res, Length(CurDirectory) + 2, Length(Res));
|
|
|
|
+ //writeLn('INFO: ResolveLinkID "\" - ', Res);
|
|
|
|
+ end
|
|
else if not IsLinkAbsolute(Res) then
|
|
else if not IsLinkAbsolute(Res) then
|
|
Res := BaseDirectory + Res;
|
|
Res := BaseDirectory + Res;
|
|
- end;
|
|
|
|
|
|
+ end;
|
|
Result:=UTF8Decode(Res);
|
|
Result:=UTF8Decode(Res);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TMultiFileDocWriter.ResolveLinkIDUnStrict(const Name: String
|
|
|
|
+ ): DOMString;
|
|
|
|
+var
|
|
|
|
+ idDot, idLast: Integer;
|
|
|
|
+ res: String;
|
|
|
|
+begin
|
|
|
|
+ res:=Engine.ResolveLink(Module,Name, True);
|
|
|
|
+ if res = '' then
|
|
|
|
+ begin
|
|
|
|
+ // do simplify on one level from end.
|
|
|
|
+ // TOCO: I want to move that code to last check of Engine.ResolveLink() for not Strict
|
|
|
|
+ IdDot:= Pos('.', Name);
|
|
|
|
+ IdLast:= 0;
|
|
|
|
+ // search last dot
|
|
|
|
+ while idDot > 0 do
|
|
|
|
+ begin
|
|
|
|
+ IdLast:= idDot;
|
|
|
|
+ IdDot:= Pos('.', Name, IdLast+1);
|
|
|
|
+ end;
|
|
|
|
+ if idLast > 0 then
|
|
|
|
+ // have cut last element
|
|
|
|
+ res:= Engine.ResolveLink(Module, Copy(Name, 1, IdLast-1), True);
|
|
|
|
+ end;
|
|
|
|
+ Result:=UTF8Decode(res);
|
|
|
|
+end;
|
|
|
|
+
|
|
{ Used for:
|
|
{ Used for:
|
|
- <link> elements in descriptions
|
|
- <link> elements in descriptions
|
|
- "see also" entries
|
|
- "see also" entries
|
|
@@ -459,8 +514,15 @@ begin
|
|
SetLength(Result, 0);
|
|
SetLength(Result, 0);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TMultiFileDocWriter.PrepareDocumentation;
|
|
|
|
+begin
|
|
|
|
+ inherited PrepareDocumentation;
|
|
|
|
+ FAllocator:= CreateAllocator();
|
|
|
|
+ FAllocator.SubPageNames:= SubPageNames;
|
|
|
|
+end;
|
|
|
|
|
|
-Function TMultiFileDocWriter.AddPage(AElement: TPasElement; ASubpageIndex: Integer) : TPageInfo;
|
|
|
|
|
|
+function TMultiFileDocWriter.AddPage(AElement: TPasElement;
|
|
|
|
+ ASubpageIndex: Integer): TPageInfo;
|
|
|
|
|
|
begin
|
|
begin
|
|
Result:= TPageInfo.Create(aElement,aSubPageIndex);
|
|
Result:= TPageInfo.Create(aElement,aSubPageIndex);
|
|
@@ -508,7 +570,7 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-Function TMultiFileDocWriter.ModuleHasClasses(AModule: TPasModule) : Boolean;
|
|
|
|
|
|
+function TMultiFileDocWriter.ModuleHasClasses(AModule: TPasModule): Boolean;
|
|
|
|
|
|
begin
|
|
begin
|
|
result:=assigned(AModule)
|
|
result:=assigned(AModule)
|
|
@@ -551,7 +613,8 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-Procedure TMultiFileDocWriter.AllocateClassMemberPages(AModule: TPasModule; LinkList : TObjectList);
|
|
|
|
|
|
+procedure TMultiFileDocWriter.AllocateClassMemberPages(AModule: TPasModule;
|
|
|
|
+ LinkList: TObjectList);
|
|
var
|
|
var
|
|
i, j, k: Integer;
|
|
i, j, k: Integer;
|
|
ClassEl: TPasClassType;
|
|
ClassEl: TPasClassType;
|
|
@@ -715,7 +778,7 @@ begin
|
|
Result:=IncludeTrailingPathDelimiter(Result);
|
|
Result:=IncludeTrailingPathDelimiter(Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TMultiFileDocWriter.WriteDoc;
|
|
|
|
|
|
+procedure TMultiFileDocWriter.DoWriteDocumentation;
|
|
|
|
|
|
procedure CreatePath(const AFilename: String);
|
|
procedure CreatePath(const AFilename: String);
|
|
|
|
|
|
@@ -748,8 +811,6 @@ var
|
|
FinalFilename: String;
|
|
FinalFilename: String;
|
|
|
|
|
|
begin
|
|
begin
|
|
- FAllocator:=CreateAllocator;
|
|
|
|
- FAllocator.SubPageNames:= SubPageNames;
|
|
|
|
AllocatePages;
|
|
AllocatePages;
|
|
DoLog(SWritingPages, [PageCount]);
|
|
DoLog(SWritingPages, [PageCount]);
|
|
if Engine.Output <> '' then
|
|
if Engine.Output <> '' then
|
|
@@ -1106,6 +1167,13 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TFPDocWriter.WriteDocumentation;
|
|
|
|
+begin
|
|
|
|
+ PrepareDocumentation();
|
|
|
|
+ DoWriteDocumentation();
|
|
|
|
+ OutputResults();
|
|
|
|
+end;
|
|
|
|
+
|
|
function TFPDocWriter.FindTopicElement ( Node: TDocNode ) : TTopicElement;
|
|
function TFPDocWriter.FindTopicElement ( Node: TDocNode ) : TTopicElement;
|
|
|
|
|
|
Var
|
|
Var
|
|
@@ -1129,6 +1197,11 @@ begin
|
|
DoLog('%s : No support for images yet: %s (caption: "%s")',[ClassName,AFileName,ACaption]);
|
|
DoLog('%s : No support for images yet: %s (caption: "%s")',[ClassName,AFileName,ACaption]);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TFPDocWriter.PrepareDocumentation;
|
|
|
|
+begin
|
|
|
|
+ // Ancestors can call AllocatePages();CreateAllocator(); into base class
|
|
|
|
+end;
|
|
|
|
+
|
|
{ ---------------------------------------------------------------------
|
|
{ ---------------------------------------------------------------------
|
|
Generic documentation node conversion
|
|
Generic documentation node conversion
|
|
---------------------------------------------------------------------}
|
|
---------------------------------------------------------------------}
|
|
@@ -1486,6 +1559,11 @@ begin
|
|
DoLog(Format(Fmt,Args));
|
|
DoLog(Format(Fmt,Args));
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TFPDocWriter.OutputResults();
|
|
|
|
+begin
|
|
|
|
+ DoLog('Documentation process finished.');
|
|
|
|
+end;
|
|
|
|
+
|
|
function TFPDocWriter.ConvertExtShort(AContext: TPasElement;
|
|
function TFPDocWriter.ConvertExtShort(AContext: TPasElement;
|
|
Node: TDOMNode): Boolean;
|
|
Node: TDOMNode): Boolean;
|
|
begin
|
|
begin
|