mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 00:59:30 +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
|
||||
|
||||
uses Classes, DOM, PasTree, PParser, StrUtils;
|
||||
uses Classes, DOM, PasTree, PParser, StrUtils,uriparser;
|
||||
|
||||
Var
|
||||
LEOL : Integer;
|
||||
@ -149,6 +149,7 @@ resourcestring
|
||||
SUsageOption170 = '--warn-no-node Warn if no documentation node was found.';
|
||||
SUsageOption180 = '--mo-dir=dir Set directory where language files reside to dir';
|
||||
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:';
|
||||
SUsageBackendHelp = 'Specify an output format, combined with --help to get more help for this backend.';
|
||||
SUsageFormatSpecific = 'Output format "%s" supports the following options:';
|
||||
@ -300,7 +301,7 @@ type
|
||||
function FindLinkedNode(ANode: TDocNode): TDocNode;
|
||||
|
||||
// Documentation file support
|
||||
procedure AddDocFile(const AFilename: String);
|
||||
procedure AddDocFile(const AFilename: String;DontTrim:boolean=false);
|
||||
|
||||
// Documentation retrieval
|
||||
function FindDocNode(AElement: TPasElement): TDocNode;
|
||||
@ -1255,7 +1256,34 @@ begin
|
||||
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;
|
||||
var
|
||||
@ -1318,7 +1346,10 @@ var
|
||||
PackageDocNode, TopicNode,ModuleDocNode: TDocNode;
|
||||
|
||||
begin
|
||||
ReadXMLFile(Doc, AFilename);
|
||||
if DontTrim then
|
||||
ReadXMLFileALT(Doc, AFilename)
|
||||
else
|
||||
ReadXMLFile(Doc, AFilename);
|
||||
DescrDocs.Add(Doc);
|
||||
DescrDocNames.Add(AFilename);
|
||||
|
||||
|
@ -87,6 +87,7 @@ begin
|
||||
Writeln(SUsageOption170);
|
||||
Writeln(SUsageOption180);
|
||||
Writeln(SUsageOption190);
|
||||
Writeln(SUsageOption200);
|
||||
L:=TStringList.Create;
|
||||
Try
|
||||
Backend:=FProject.OPtions.Backend;
|
||||
@ -230,6 +231,8 @@ begin
|
||||
FProject.Options.ShowPrivate := False
|
||||
else if s = '--stop-on-parser-error' then
|
||||
FProject.Options.StopOnParseError := True
|
||||
else if s = '--dont-trim' then
|
||||
FProject.Options.donttrim := True
|
||||
else
|
||||
begin
|
||||
i := Pos('=', s);
|
||||
@ -316,7 +319,7 @@ begin
|
||||
Engine.ReadContentFile(Copy(Arg,1,i-1),Copy(Arg,i+1,Length(Arg)));
|
||||
end;
|
||||
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.Output:=APackage.Output;
|
||||
Engine.HideProtected:=Options.HideProtected;
|
||||
|
@ -59,6 +59,7 @@ Type
|
||||
FOSTarget: String;
|
||||
FSOPE: Boolean;
|
||||
FWarnNoNode: Boolean;
|
||||
FDontTrim : Boolean;
|
||||
procedure SetBackendOptions(const AValue: TStrings);
|
||||
Public
|
||||
Constructor Create;
|
||||
@ -77,6 +78,7 @@ Type
|
||||
Property InterfaceOnly : Boolean Read FIO Write FIO;
|
||||
Property MoDir : String Read FMoDir Write FMODir;
|
||||
Property DefaultPackageName : String Read FDefaultPackageName Write FDefaultPackageName;
|
||||
Property DontTrim : Boolean Read FDontTrim Write FDontTrim;
|
||||
end;
|
||||
|
||||
{ TFPDocProject }
|
||||
|
@ -156,12 +156,12 @@ procedure TXMLFPDocOptions.LoadEngineOptions(Options: TEngineOptions;
|
||||
end;
|
||||
|
||||
Const
|
||||
NCount = 10;
|
||||
NCount = 11;
|
||||
ONames : Array[0..NCount] of string
|
||||
= ('hide-protected','warn-no-node','show-private',
|
||||
'stop-on-parser-error', 'ostarget','cputarget',
|
||||
'mo-dir','parse-impl','format', 'language',
|
||||
'package');
|
||||
'package','dont-trim');
|
||||
|
||||
Var
|
||||
O : TDOMnode;
|
||||
@ -187,6 +187,7 @@ begin
|
||||
8 : Options.Backend:=V;
|
||||
9 : Options.Language:=v;
|
||||
10 : Options.DefaultPackageName:=V;
|
||||
11 : Options.DontTrim:=TrueValue(V);
|
||||
else
|
||||
Options.BackendOptions.add('--'+n);
|
||||
Options.BackendOptions.add(v);
|
||||
|
Loading…
Reference in New Issue
Block a user