mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 09:26:15 +02:00
+ Check for empty example file name
git-svn-id: trunk@4466 -
This commit is contained in:
parent
bc5e1be7b1
commit
7eb023d7cd
@ -1179,16 +1179,20 @@ end;
|
|||||||
function TFPDocEngine.GetExampleFilename(const ExElement: TDOMElement): String;
|
function TFPDocEngine.GetExampleFilename(const ExElement: TDOMElement): String;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
fn : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
Result:='';
|
||||||
for i := 0 to DescrDocs.Count - 1 do
|
for i := 0 to DescrDocs.Count - 1 do
|
||||||
if TDOMDocument(DescrDocs[i]) = ExElement.OwnerDocument then
|
|
||||||
begin
|
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
|
if (ExtractFileExt(Result)='') then
|
||||||
Result:=Result+'.pp';
|
Result:=Result+'.pp';
|
||||||
exit;
|
end;
|
||||||
end;
|
end;
|
||||||
SetLength(Result, 0);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1884,9 +1884,9 @@ Procedure THTMLWriter.AppendExampleSection(AElement : TPasElement;DocNode : TDoc
|
|||||||
var
|
var
|
||||||
Node: TDOMNode;
|
Node: TDOMNode;
|
||||||
// TableEl, El, TREl, TDEl, ParaEl, NewEl, DescrEl: TDOMElement;
|
// TableEl, El, TREl, TDEl, ParaEl, NewEl, DescrEl: TDOMElement;
|
||||||
s: String;
|
fn,s: String;
|
||||||
f: Text;
|
f: Text;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if not (Assigned(DocNode) and Assigned(DocNode.FirstExample)) then
|
if not (Assigned(DocNode) and Assigned(DocNode.FirstExample)) then
|
||||||
Exit;
|
Exit;
|
||||||
@ -1895,30 +1895,34 @@ begin
|
|||||||
begin
|
begin
|
||||||
if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'example') then
|
if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'example') then
|
||||||
begin
|
begin
|
||||||
AppendText(CreateH2(BodyElement), SDocExample);
|
fn:=Engine.GetExampleFilename(TDOMElement(Node));
|
||||||
try
|
If (fn<>'') then
|
||||||
Assign(f, Engine.GetExampleFilename(TDOMElement(Node)));
|
begin
|
||||||
Reset(f);
|
AppendText(CreateH2(BodyElement), SDocExample);
|
||||||
try
|
try
|
||||||
PushOutputNode(BodyElement);
|
Assign(f, FN);
|
||||||
DescrBeginCode(False, TDOMElement(Node)['highlighter']);
|
Reset(f);
|
||||||
while not EOF(f) do
|
try
|
||||||
begin
|
PushOutputNode(BodyElement);
|
||||||
ReadLn(f, s);
|
DescrBeginCode(False, TDOMElement(Node)['highlighter']);
|
||||||
DescrWriteCodeLine(s);
|
while not EOF(f) do
|
||||||
end;
|
begin
|
||||||
DescrEndCode;
|
ReadLn(f, s);
|
||||||
PopOutputNode;
|
DescrWriteCodeLine(s);
|
||||||
finally
|
end;
|
||||||
Close(f);
|
DescrEndCode;
|
||||||
end;
|
PopOutputNode;
|
||||||
except
|
finally
|
||||||
on e: Exception do
|
Close(f);
|
||||||
begin
|
|
||||||
e.Message := '[example] ' + e.Message;
|
|
||||||
raise;
|
|
||||||
end;
|
end;
|
||||||
end;
|
except
|
||||||
|
on e: Exception do
|
||||||
|
begin
|
||||||
|
e.Message := '[example] ' + e.Message;
|
||||||
|
raise;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
Node := Node.NextSibling;
|
Node := Node.NextSibling;
|
||||||
end;
|
end;
|
||||||
|
@ -918,7 +918,8 @@ begin
|
|||||||
while Assigned(Example) do
|
while Assigned(Example) do
|
||||||
begin
|
begin
|
||||||
s:=Engine.GetExampleFileName(Example);
|
s:=Engine.GetExampleFileName(Example);
|
||||||
WriteExampleFile(S);
|
if (s<>'') then
|
||||||
|
WriteExampleFile(S);
|
||||||
DescrEndParaGraph;
|
DescrEndParaGraph;
|
||||||
Repeat
|
Repeat
|
||||||
Example := TDomElement(Example.NextSibling);
|
Example := TDomElement(Example.NextSibling);
|
||||||
|
@ -592,7 +592,8 @@ begin
|
|||||||
while Assigned(Example) do
|
while Assigned(Example) do
|
||||||
begin
|
begin
|
||||||
s:=Engine.GetExampleFileName(Example);
|
s:=Engine.GetExampleFileName(Example);
|
||||||
WriteExampleFile(S);
|
if (s<>'') then
|
||||||
|
WriteExampleFile(S);
|
||||||
DescrEndParaGraph;
|
DescrEndParaGraph;
|
||||||
Repeat
|
Repeat
|
||||||
Example := TDomElement(Example.NextSibling);
|
Example := TDomElement(Example.NextSibling);
|
||||||
|
@ -842,7 +842,8 @@ begin
|
|||||||
if (S<>'') then // not first example, start new paragraph
|
if (S<>'') then // not first example, start new paragraph
|
||||||
DescrBeginParagraph;
|
DescrBeginParagraph;
|
||||||
s:=Engine.GetExampleFileName(Example);
|
s:=Engine.GetExampleFileName(Example);
|
||||||
WriteExampleFile(S);
|
if (S<>'') then
|
||||||
|
WriteExampleFile(S);
|
||||||
if Assigned(Example.NextSibling) then
|
if Assigned(Example.NextSibling) then
|
||||||
DescrEndParaGraph;
|
DescrEndParaGraph;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user