+ Check for empty example file name

git-svn-id: trunk@4466 -
This commit is contained in:
michael 2006-08-20 09:44:43 +00:00
parent bc5e1be7b1
commit 7eb023d7cd
5 changed files with 43 additions and 32 deletions

View File

@ -1179,16 +1179,20 @@ end;
function TFPDocEngine.GetExampleFilename(const ExElement: TDOMElement): String;
var
i: Integer;
fn : String;
begin
Result:='';
for i := 0 to DescrDocs.Count - 1 do
if TDOMDocument(DescrDocs[i]) = ExElement.OwnerDocument then
begin
Result := ExtractFilePath(DescrDocNames[i]) + ExElement['file'];
Fn:=ExElement['file'];
if (FN<>'') and (TDOMDocument(DescrDocs[i]) = ExElement.OwnerDocument) then
begin
Result := ExtractFilePath(DescrDocNames[i]) + FN;
if (ExtractFileExt(Result)='') then
Result:=Result+'.pp';
exit;
end;
SetLength(Result, 0);
end;
end;
end;

View File

@ -1884,9 +1884,9 @@ Procedure THTMLWriter.AppendExampleSection(AElement : TPasElement;DocNode : TDoc
var
Node: TDOMNode;
// TableEl, El, TREl, TDEl, ParaEl, NewEl, DescrEl: TDOMElement;
s: String;
fn,s: String;
f: Text;
begin
if not (Assigned(DocNode) and Assigned(DocNode.FirstExample)) then
Exit;
@ -1895,30 +1895,34 @@ begin
begin
if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'example') then
begin
AppendText(CreateH2(BodyElement), SDocExample);
try
Assign(f, Engine.GetExampleFilename(TDOMElement(Node)));
Reset(f);
fn:=Engine.GetExampleFilename(TDOMElement(Node));
If (fn<>'') then
begin
AppendText(CreateH2(BodyElement), SDocExample);
try
PushOutputNode(BodyElement);
DescrBeginCode(False, TDOMElement(Node)['highlighter']);
while not EOF(f) do
begin
ReadLn(f, s);
DescrWriteCodeLine(s);
end;
DescrEndCode;
PopOutputNode;
finally
Close(f);
end;
except
on e: Exception do
begin
e.Message := '[example] ' + e.Message;
raise;
Assign(f, FN);
Reset(f);
try
PushOutputNode(BodyElement);
DescrBeginCode(False, TDOMElement(Node)['highlighter']);
while not EOF(f) do
begin
ReadLn(f, s);
DescrWriteCodeLine(s);
end;
DescrEndCode;
PopOutputNode;
finally
Close(f);
end;
end;
except
on e: Exception do
begin
e.Message := '[example] ' + e.Message;
raise;
end;
end;
end;
end;
Node := Node.NextSibling;
end;

View File

@ -918,7 +918,8 @@ begin
while Assigned(Example) do
begin
s:=Engine.GetExampleFileName(Example);
WriteExampleFile(S);
if (s<>'') then
WriteExampleFile(S);
DescrEndParaGraph;
Repeat
Example := TDomElement(Example.NextSibling);

View File

@ -592,7 +592,8 @@ begin
while Assigned(Example) do
begin
s:=Engine.GetExampleFileName(Example);
WriteExampleFile(S);
if (s<>'') then
WriteExampleFile(S);
DescrEndParaGraph;
Repeat
Example := TDomElement(Example.NextSibling);

View File

@ -842,7 +842,8 @@ begin
if (S<>'') then // not first example, start new paragraph
DescrBeginParagraph;
s:=Engine.GetExampleFileName(Example);
WriteExampleFile(S);
if (S<>'') then
WriteExampleFile(S);
if Assigned(Example.NextSibling) then
DescrEndParaGraph;
end;