diff --git a/utils/fpdoc/dwriter.pp b/utils/fpdoc/dwriter.pp index cedf335df7..80e5997c63 100644 --- a/utils/fpdoc/dwriter.pp +++ b/utils/fpdoc/dwriter.pp @@ -256,6 +256,8 @@ Type FModule: TPasModule; FPageInfos: TFPObjectList; // list of TPageInfo objects FLinkUnresolvedCnt: Integer; + FOutputPageNames: TStringList; + function GetOutputPageNames: TStrings; function GetPageCount: Integer; function LinkFix(ALink:String):String; Protected @@ -286,6 +288,7 @@ Type function ModuleHasClasses(AModule: TPasModule): Boolean; // Allocate pages etc. Procedure DoWriteDocumentation; override; + Function MustGeneratePage(aFileName : String) : Boolean; virtual; Property PageInfos : TFPObjectList Read FPageInfos; Property SubPageNames: Boolean Read FSubPageNames; @@ -298,6 +301,7 @@ Type Property Module: TPasModule Read FModule Write FModule; 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 OutputPageNames : TStrings Read GetOutputPageNames; end; TFPDocWriterClass = Class of TFPDocWriter; @@ -328,7 +332,7 @@ function SortPasElements(Item1, Item2: Pointer): Integer; implementation -uses fpdocstrs; +uses strutils, fpdocstrs; function SortPasElements(Item1, Item2: Pointer): Integer; begin @@ -418,6 +422,16 @@ begin Result := PageInfos.Count; end; +function TMultiFileDocWriter.GetOutputPageNames: TStrings; +begin + If (FoutputPageNames=Nil) then + begin + FOutputPageNames:=TStringList.Create; + FOutputPageNames.Sorted:=True; + end; + Result:=FOutputPageNames; +end; + procedure TMultiFileDocWriter.OutputResults(); begin DoLog('Unresolved links: %d', [FLinkUnresolvedCnt]); @@ -826,22 +840,59 @@ begin with TPageInfo(PageInfos[i]) do begin FileName:= Allocator.GetFilename(Element, SubpageIndex); - FinalFilename := GetFileBaseDir(Engine.Output) + FileName; - CreatePath(FinalFilename); - WriteDocPage(FileName,ELement,SubPageIndex); + if MustGeneratePage(FileName) then + begin + FinalFilename := GetFileBaseDir(Engine.Output) + FileName; + CreatePath(FinalFilename); + WriteDocPage(FileName,ELement,SubPageIndex); + 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); begin List.AddStrings(['--use-subpagenames', SUsageSubNames]); + List.AddStrings(['--only-pages=LIST', SUsageOnlyPages]); end; function TMultiFileDocWriter.InterPretOption(const Cmd, Arg: String): boolean; + +Var + I : Integer; + FN : String; + begin + Writeln('Cmd : ',Cmd); Result := True; if Cmd = '--use-subpagenames' then 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 Result:=inherited InterPretOption(Cmd, Arg); end; diff --git a/utils/fpdoc/fpdoc.lpi b/utils/fpdoc/fpdoc.lpi index d4126e5fdf..201f6383a8 100644 --- a/utils/fpdoc/fpdoc.lpi +++ b/utils/fpdoc/fpdoc.lpi @@ -158,8 +158,8 @@ - + diff --git a/utils/fpdoc/fpdocstrs.pp b/utils/fpdoc/fpdocstrs.pp index 2b82bc823c..2e58cf64f4 100644 --- a/utils/fpdoc/fpdocstrs.pp +++ b/utils/fpdoc/fpdocstrs.pp @@ -189,6 +189,7 @@ resourcestring SUsageOption310 = '--write-project=file'; SUsageOption320 = ' Write all command-line options to a project file'; 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:'; SUsageBackendHelp = 'Specify an output format, combined with --help to get more help for this backend.';