mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 11:29:20 +02:00
* --dont-trim avoids trimming while loading XMLs. Mantis #16683
git-svn-id: trunk@18924 -
This commit is contained in:
parent
041f3d0222
commit
d6726a6ade
@ -23,7 +23,7 @@ unit dGlobals;
|
|||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses Classes, DOM, PasTree, PParser, StrUtils;
|
uses Classes, DOM, PasTree, PParser, StrUtils,uriparser;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
LEOL : Integer;
|
LEOL : Integer;
|
||||||
@ -149,6 +149,7 @@ resourcestring
|
|||||||
SUsageOption170 = '--warn-no-node Warn if no documentation node was found.';
|
SUsageOption170 = '--warn-no-node Warn if no documentation node was found.';
|
||||||
SUsageOption180 = '--mo-dir=dir Set directory where language files reside to dir';
|
SUsageOption180 = '--mo-dir=dir Set directory where language files reside to dir';
|
||||||
SUsageOption190 = '--parse-impl (Experimental) try to parse implementation too';
|
SUsageOption190 = '--parse-impl (Experimental) try to parse implementation too';
|
||||||
|
SUsageOption200 = '--dont-trim Don''t trim XML contents';
|
||||||
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.';
|
||||||
SUsageFormatSpecific = 'Output format "%s" supports the following options:';
|
SUsageFormatSpecific = 'Output format "%s" supports the following options:';
|
||||||
@ -300,7 +301,7 @@ type
|
|||||||
function FindLinkedNode(ANode: TDocNode): TDocNode;
|
function FindLinkedNode(ANode: TDocNode): TDocNode;
|
||||||
|
|
||||||
// Documentation file support
|
// Documentation file support
|
||||||
procedure AddDocFile(const AFilename: String);
|
procedure AddDocFile(const AFilename: String;DontTrim:boolean=false);
|
||||||
|
|
||||||
// Documentation retrieval
|
// Documentation retrieval
|
||||||
function FindDocNode(AElement: TPasElement): TDocNode;
|
function FindDocNode(AElement: TPasElement): TDocNode;
|
||||||
@ -1255,7 +1256,34 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPDocEngine.AddDocFile(const AFilename: String);
|
procedure ReadXMLFileALT(OUT ADoc:TXMLDocument;const AFileName:ansistring);
|
||||||
|
var
|
||||||
|
Parser: TDOMParser;
|
||||||
|
Src: TXMLInputSource;
|
||||||
|
FileStream: TStream;
|
||||||
|
begin
|
||||||
|
ADoc := nil;
|
||||||
|
FileStream := TFileStream.Create(AFilename, fmOpenRead+fmShareDenyWrite);
|
||||||
|
try
|
||||||
|
Parser := TDOMParser.Create; // create a parser object
|
||||||
|
try
|
||||||
|
Src := TXMLInputSource.Create(FileStream); // and the input source
|
||||||
|
src.SystemId:=FileNameToUri(AFileName);
|
||||||
|
try
|
||||||
|
Parser.Options.PreserveWhitespace := True;
|
||||||
|
Parser.Parse(Src, ADoc);
|
||||||
|
finally
|
||||||
|
Src.Free; // cleanup
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Parser.Free;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
FileStream.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFPDocEngine.AddDocFile(const AFilename: String;DontTrim:boolean=false);
|
||||||
|
|
||||||
function ReadNode(OwnerDocNode: TDocNode; Element: TDOMElement): TDocNode;
|
function ReadNode(OwnerDocNode: TDocNode; Element: TDOMElement): TDocNode;
|
||||||
var
|
var
|
||||||
@ -1318,7 +1346,10 @@ var
|
|||||||
PackageDocNode, TopicNode,ModuleDocNode: TDocNode;
|
PackageDocNode, TopicNode,ModuleDocNode: TDocNode;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
ReadXMLFile(Doc, AFilename);
|
if DontTrim then
|
||||||
|
ReadXMLFileALT(Doc, AFilename)
|
||||||
|
else
|
||||||
|
ReadXMLFile(Doc, AFilename);
|
||||||
DescrDocs.Add(Doc);
|
DescrDocs.Add(Doc);
|
||||||
DescrDocNames.Add(AFilename);
|
DescrDocNames.Add(AFilename);
|
||||||
|
|
||||||
|
@ -87,6 +87,7 @@ begin
|
|||||||
Writeln(SUsageOption170);
|
Writeln(SUsageOption170);
|
||||||
Writeln(SUsageOption180);
|
Writeln(SUsageOption180);
|
||||||
Writeln(SUsageOption190);
|
Writeln(SUsageOption190);
|
||||||
|
Writeln(SUsageOption200);
|
||||||
L:=TStringList.Create;
|
L:=TStringList.Create;
|
||||||
Try
|
Try
|
||||||
Backend:=FProject.OPtions.Backend;
|
Backend:=FProject.OPtions.Backend;
|
||||||
@ -230,6 +231,8 @@ begin
|
|||||||
FProject.Options.ShowPrivate := False
|
FProject.Options.ShowPrivate := False
|
||||||
else if s = '--stop-on-parser-error' then
|
else if s = '--stop-on-parser-error' then
|
||||||
FProject.Options.StopOnParseError := True
|
FProject.Options.StopOnParseError := True
|
||||||
|
else if s = '--dont-trim' then
|
||||||
|
FProject.Options.donttrim := True
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
i := Pos('=', s);
|
i := Pos('=', s);
|
||||||
@ -316,7 +319,7 @@ begin
|
|||||||
Engine.ReadContentFile(Copy(Arg,1,i-1),Copy(Arg,i+1,Length(Arg)));
|
Engine.ReadContentFile(Copy(Arg,1,i-1),Copy(Arg,i+1,Length(Arg)));
|
||||||
end;
|
end;
|
||||||
for i := 0 to APackage.Descriptions.Count - 1 do
|
for i := 0 to APackage.Descriptions.Count - 1 do
|
||||||
Engine.AddDocFile(APackage.Descriptions[i]);
|
Engine.AddDocFile(APackage.Descriptions[i],Options.donttrim);
|
||||||
Engine.SetPackageName(APackage.Name);
|
Engine.SetPackageName(APackage.Name);
|
||||||
Engine.Output:=APackage.Output;
|
Engine.Output:=APackage.Output;
|
||||||
Engine.HideProtected:=Options.HideProtected;
|
Engine.HideProtected:=Options.HideProtected;
|
||||||
|
@ -59,6 +59,7 @@ Type
|
|||||||
FOSTarget: String;
|
FOSTarget: String;
|
||||||
FSOPE: Boolean;
|
FSOPE: Boolean;
|
||||||
FWarnNoNode: Boolean;
|
FWarnNoNode: Boolean;
|
||||||
|
FDontTrim : Boolean;
|
||||||
procedure SetBackendOptions(const AValue: TStrings);
|
procedure SetBackendOptions(const AValue: TStrings);
|
||||||
Public
|
Public
|
||||||
Constructor Create;
|
Constructor Create;
|
||||||
@ -77,6 +78,7 @@ Type
|
|||||||
Property InterfaceOnly : Boolean Read FIO Write FIO;
|
Property InterfaceOnly : Boolean Read FIO Write FIO;
|
||||||
Property MoDir : String Read FMoDir Write FMODir;
|
Property MoDir : String Read FMoDir Write FMODir;
|
||||||
Property DefaultPackageName : String Read FDefaultPackageName Write FDefaultPackageName;
|
Property DefaultPackageName : String Read FDefaultPackageName Write FDefaultPackageName;
|
||||||
|
Property DontTrim : Boolean Read FDontTrim Write FDontTrim;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TFPDocProject }
|
{ TFPDocProject }
|
||||||
|
@ -156,12 +156,12 @@ procedure TXMLFPDocOptions.LoadEngineOptions(Options: TEngineOptions;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
Const
|
Const
|
||||||
NCount = 10;
|
NCount = 11;
|
||||||
ONames : Array[0..NCount] of string
|
ONames : Array[0..NCount] of string
|
||||||
= ('hide-protected','warn-no-node','show-private',
|
= ('hide-protected','warn-no-node','show-private',
|
||||||
'stop-on-parser-error', 'ostarget','cputarget',
|
'stop-on-parser-error', 'ostarget','cputarget',
|
||||||
'mo-dir','parse-impl','format', 'language',
|
'mo-dir','parse-impl','format', 'language',
|
||||||
'package');
|
'package','dont-trim');
|
||||||
|
|
||||||
Var
|
Var
|
||||||
O : TDOMnode;
|
O : TDOMnode;
|
||||||
@ -187,6 +187,7 @@ begin
|
|||||||
8 : Options.Backend:=V;
|
8 : Options.Backend:=V;
|
||||||
9 : Options.Language:=v;
|
9 : Options.Language:=v;
|
||||||
10 : Options.DefaultPackageName:=V;
|
10 : Options.DefaultPackageName:=V;
|
||||||
|
11 : Options.DontTrim:=TrueValue(V);
|
||||||
else
|
else
|
||||||
Options.BackendOptions.add('--'+n);
|
Options.BackendOptions.add('--'+n);
|
||||||
Options.BackendOptions.add(v);
|
Options.BackendOptions.add(v);
|
||||||
|
Loading…
Reference in New Issue
Block a user