* Allow single page mode for multi-page writers

git-svn-id: trunk@48348 -
This commit is contained in:
michael 2021-01-23 11:42:21 +00:00
parent 2519fb1266
commit b51fd7079a
3 changed files with 58 additions and 6 deletions

View File

@ -256,6 +256,8 @@ Type
FModule: TPasModule; FModule: TPasModule;
FPageInfos: TFPObjectList; // list of TPageInfo objects FPageInfos: TFPObjectList; // list of TPageInfo objects
FLinkUnresolvedCnt: Integer; FLinkUnresolvedCnt: Integer;
FOutputPageNames: TStringList;
function GetOutputPageNames: TStrings;
function GetPageCount: Integer; function GetPageCount: Integer;
function LinkFix(ALink:String):String; function LinkFix(ALink:String):String;
Protected Protected
@ -286,6 +288,7 @@ Type
function ModuleHasClasses(AModule: TPasModule): Boolean; function ModuleHasClasses(AModule: TPasModule): Boolean;
// Allocate pages etc. // Allocate pages etc.
Procedure DoWriteDocumentation; override; Procedure DoWriteDocumentation; override;
Function MustGeneratePage(aFileName : String) : Boolean; virtual;
Property PageInfos : TFPObjectList Read FPageInfos; Property PageInfos : TFPObjectList Read FPageInfos;
Property SubPageNames: Boolean Read FSubPageNames; Property SubPageNames: Boolean Read FSubPageNames;
@ -298,6 +301,7 @@ Type
Property Module: TPasModule Read FModule Write FModule; Property Module: TPasModule Read FModule Write FModule;
Property CurDirectory: String Read FCurDirectory Write FCurDirectory; // relative to curdir of process Property CurDirectory: String Read FCurDirectory Write FCurDirectory; // relative to curdir of process
property BaseDirectory: String read FBaseDirectory Write FBaseDirectory; // relative path to package base directory property BaseDirectory: String read FBaseDirectory Write FBaseDirectory; // relative path to package base directory
Property OutputPageNames : TStrings Read GetOutputPageNames;
end; end;
TFPDocWriterClass = Class of TFPDocWriter; TFPDocWriterClass = Class of TFPDocWriter;
@ -328,7 +332,7 @@ function SortPasElements(Item1, Item2: Pointer): Integer;
implementation implementation
uses fpdocstrs; uses strutils, fpdocstrs;
function SortPasElements(Item1, Item2: Pointer): Integer; function SortPasElements(Item1, Item2: Pointer): Integer;
begin begin
@ -418,6 +422,16 @@ begin
Result := PageInfos.Count; Result := PageInfos.Count;
end; end;
function TMultiFileDocWriter.GetOutputPageNames: TStrings;
begin
If (FoutputPageNames=Nil) then
begin
FOutputPageNames:=TStringList.Create;
FOutputPageNames.Sorted:=True;
end;
Result:=FOutputPageNames;
end;
procedure TMultiFileDocWriter.OutputResults(); procedure TMultiFileDocWriter.OutputResults();
begin begin
DoLog('Unresolved links: %d', [FLinkUnresolvedCnt]); DoLog('Unresolved links: %d', [FLinkUnresolvedCnt]);
@ -826,22 +840,59 @@ begin
with TPageInfo(PageInfos[i]) do with TPageInfo(PageInfos[i]) do
begin begin
FileName:= Allocator.GetFilename(Element, SubpageIndex); FileName:= Allocator.GetFilename(Element, SubpageIndex);
FinalFilename := GetFileBaseDir(Engine.Output) + FileName; if MustGeneratePage(FileName) then
CreatePath(FinalFilename); begin
WriteDocPage(FileName,ELement,SubPageIndex); FinalFilename := GetFileBaseDir(Engine.Output) + FileName;
CreatePath(FinalFilename);
WriteDocPage(FileName,ELement,SubPageIndex);
end;
end; end;
end; end;
function TMultiFileDocWriter.MustGeneratePage(aFileName: String): Boolean;
begin
Result:=Not Assigned(FOutputPageNames);
if Not Result then
Result:=FOutputPageNames.IndexOf(aFileName)<>-1;
Writeln(afilename ,': ',result);
end;
class procedure TMultiFileDocWriter.Usage(List: TStrings); class procedure TMultiFileDocWriter.Usage(List: TStrings);
begin begin
List.AddStrings(['--use-subpagenames', SUsageSubNames]); List.AddStrings(['--use-subpagenames', SUsageSubNames]);
List.AddStrings(['--only-pages=LIST', SUsageOnlyPages]);
end; end;
function TMultiFileDocWriter.InterPretOption(const Cmd, Arg: String): boolean; function TMultiFileDocWriter.InterPretOption(const Cmd, Arg: String): boolean;
Var
I : Integer;
FN : String;
begin begin
Writeln('Cmd : ',Cmd);
Result := True; Result := True;
if Cmd = '--use-subpagenames' then if Cmd = '--use-subpagenames' then
FSubPageNames:= True FSubPageNames:= True
else
if Cmd = '--only-pages' then
begin
Result:=Arg<>'';
if Result then
begin
if Arg[1]='@' then
begin
FN:=Copy(Arg,2,Length(Arg)-1);
OutputPageNames.LoadFromFile(FN);
end
else
begin
For I:=1 to WordCount(Arg,[',']) do
OutputPageNames.Add(ExtractWord(I,Arg,[',']));
end;
Writeln('OutputPagenames ',OutputPagenames.CommaText);
end
end
else else
Result:=inherited InterPretOption(Cmd, Arg); Result:=inherited InterPretOption(Cmd, Arg);
end; end;

View File

@ -158,8 +158,8 @@
</Debugging> </Debugging>
</Linking> </Linking>
<Other> <Other>
<CustomOptions Value="-dCheckPasTreeRefCount <CustomOptions Value="-dCheckPasTreeRefCountx
-dDebugRefCount"/> -dDebugRefCountx"/>
<OtherDefines Count="1"> <OtherDefines Count="1">
<Define0 Value="CheckPasTreeRefCount"/> <Define0 Value="CheckPasTreeRefCount"/>
</OtherDefines> </OtherDefines>

View File

@ -189,6 +189,7 @@ resourcestring
SUsageOption310 = '--write-project=file'; SUsageOption310 = '--write-project=file';
SUsageOption320 = ' Write all command-line options to a project file'; SUsageOption320 = ' Write all command-line options to a project file';
SUsageSubNames = 'Use the file subnames instead the indexes as postfixes'; SUsageSubNames = 'Use the file subnames instead the indexes as postfixes';
SUsageOnlyPages = 'Only write pages in LIST, LIST is comma-separated list of filenames or @filename where the named file contains 1 file per line.';
SUsageFormats = 'The following output formats are supported by this fpdoc:'; SUsageFormats = 'The following output formats are supported by this fpdoc:';
SUsageBackendHelp = 'Specify an output format, combined with --help to get more help for this backend.'; SUsageBackendHelp = 'Specify an output format, combined with --help to get more help for this backend.';