IDE: fpdoc editor: auto repair xml

git-svn-id: trunk@28526 -
This commit is contained in:
mattias 2010-11-28 12:44:28 +00:00
parent afcd16b76c
commit 7d14b1c344
5 changed files with 35 additions and 17 deletions

View File

@ -33,7 +33,7 @@ interface
uses
Classes, SysUtils, FileProcs, contnrs, BasicCodeTools;
procedure FixFPDocFragment(var Fragment: string; Fix: boolean;
procedure FixFPDocFragment(var Fragment: string; AllowTags, Fix: boolean;
out ErrorList: TObjectList; Verbose: boolean = false);
implementation
@ -46,7 +46,7 @@ type
Msg: string;
end;
procedure FixFPDocFragment(var Fragment: string; Fix: boolean;
procedure FixFPDocFragment(var Fragment: string; AllowTags, Fix: boolean;
out ErrorList: TObjectList; Verbose: boolean);
{ - Fix all tags to lowercase to reduce svn commits
- auto close comments
@ -463,7 +463,10 @@ var
procedure ParseLowerThan;
begin
// comment, tag or 'lower than'
if (p[1]='!') and (p[2]='-') and (p[3]='-') then begin
if not AllowTags then begin
// invalid character => convert or skip
HandleSpecialChar;
end else if (p[1]='!') and (p[2]='-') and (p[3]='-') then begin
// comment
ParseComment;
end else if p[1] in ['a'..'z','A'..'Z'] then begin

View File

@ -7,6 +7,7 @@
<MainUnit Value="0"/>
<ResourceType Value="res"/>
</General>
<LazDoc Paths="doc"/>
<i18n>
<EnableI18N LFM="False"/>
</i18n>

View File

@ -102,7 +102,7 @@ begin
Result:=true;
try
s:=Fragment;
FixFPDocFragment(s,true,ErrorList,Verbose);
FixFPDocFragment(s,true,true,ErrorList,Verbose);
if s<>FixedFragment then begin
Result:=false;
debugln(['failed: ',Title]);

View File

@ -31,7 +31,7 @@ interface
uses
// FCL
Classes, SysUtils, StrUtils,
Classes, SysUtils, StrUtils, contnrs,
// LCL
LCLProc, LResources, StdCtrls, Buttons, ComCtrls, Controls, Dialogs,
ExtCtrls, Forms, Graphics, LCLType,
@ -39,6 +39,7 @@ uses
SynEdit,
// codetools
BasicCodeTools, FileProcs, CodeAtom, CodeCache, CodeToolManager,
CTXMLFixFragment,
{$IFDEF NewXMLCfg}
Laz2_DOM, Laz2_XMLRead, Laz2_XMLWrite,
{$ELSE}
@ -1259,29 +1260,38 @@ var
CurName:=Element.FPDocFile.Filename
else
CurName:=Element.ElementName;
MessageDlg('Write error',
'Error writing "'+CurName+'"'#13
+Msg,mtError,[mbCancel],0);
MessageDlg(lisCodeToolsDefsWriteError,
Format(lisFPDocErrorWriting, [CurName, #13, Msg]), mtError, [mbCancel],
0);
end;
end;
function SetValue(Item: TFPDocItem): boolean;
var
NewValue: String;
ErrorList: TObjectList;
begin
Result:=false;
NewValue:=Values[Item];
ErrorList:=nil;
try
CurDocFile.SetChildValue(TopNode,FPDocItemNames[Item],NewValue);
Result:=true;
except
on E: EXMLReadError do begin
DebugLn(['SetValue ',dbgs(E.LineCol),' Name=',FPDocItemNames[Item]]);
JumpToError(Item,E.LineCol);
MessageDlg('FPDoc syntax error',
'There is a syntax error in the fpdoc element "'+FPDocItemNames[Item]+'":'#13#13
+E.Message,mtError,[mbOk],'');
try
FixFPDocFragment(NewValue,
Item in [fpdiShort,fpdiDescription,fpdiErrors,fpdiSeeAlso],
true,ErrorList);
CurDocFile.SetChildValue(TopNode,FPDocItemNames[Item],NewValue);
Result:=true;
except
on E: EXMLReadError do begin
DebugLn(['SetValue ',dbgs(E.LineCol),' Name=',FPDocItemNames[Item]]);
JumpToError(Item,E.LineCol);
MessageDlg(lisFPDocFPDocSyntaxError,
Format(lisFPDocThereIsASyntaxErrorInTheFpdocElement, [FPDocItemNames
[Item], #13#13, E.Message]), mtError, [mbOk], '');
end;
end;
finally
FreeAndNil(ErrorList);
end;
end;

View File

@ -2890,6 +2890,10 @@ resourcestring
// codetools defines
lisCodeToolsDefsCodeToolsDefinesPreview = 'CodeTools Defines Preview';
lisCodeToolsDefsWriteError = 'Write error';
lisFPDocErrorWriting = 'Error writing "%s"%s%s';
lisFPDocFPDocSyntaxError = 'FPDoc syntax error';
lisFPDocThereIsASyntaxErrorInTheFpdocElement = 'There is a syntax error in '
+'the fpdoc element "%s":%s%s';
lisUnableToWriteToFile2 = 'Unable to write to file "%s".';
lisUnableToWriteTheProjectSessionFileError = 'Unable to write the project '
+'session file%s"%s".%sError: %s';