* Added support for version tag (same level as errors or seealso tags

git-svn-id: trunk@15008 -
This commit is contained in:
michael 2010-03-13 16:03:52 +00:00
parent 1d0db2cc85
commit 235c3be24a
5 changed files with 98 additions and 29 deletions

View File

@ -55,6 +55,7 @@ resourcestring
SDocDeclaration = 'Declaration';
SDocDescription = 'Description';
SDocErrors = 'Errors';
SDocVersion = 'Version info';
SDocSeeAlso = 'See also';
SDocExample = 'Example';
SDocArguments = 'Arguments';
@ -208,6 +209,8 @@ type
members, and so on...
}
{ TDocNode }
TDocNode = class
private
FFirstChild, FNextSibling: TDocNode;
@ -222,6 +225,7 @@ type
FLink: String;
FTopicNode : Boolean;
FRefCount : Integer;
FVersion: TDomElement;
public
constructor Create(const AName: String; ANode: TDOMElement);
destructor Destroy; override;
@ -239,6 +243,7 @@ type
property ShortDescr: TDOMElement read FShortDescr;
property Descr: TDOMElement read FDescr;
property ErrorsDoc: TDOMElement read FErrorsDoc;
Property Version : TDomElement Read FVersion;
property SeeAlso: TDOMElement read FSeeAlso;
property FirstExample: TDOMElement read FFirstExample;
property Link: String read FLink;
@ -1044,6 +1049,11 @@ procedure TFPDocEngine.AddDocFile(const AFilename: String);
Result.FShortDescr := TDOMElement(Subnode)
else if Subnode.NodeName = 'descr' then
Result.FDescr := TDOMElement(Subnode)
else if Subnode.NodeName = 'version' then
begin
Writeln('Detected version',ELement['name']);
Result.FVersion := TDOMElement(Subnode)
end
else if Subnode.NodeName = 'errors' then
Result.FErrorsDoc := TDOMElement(Subnode)
else if Subnode.NodeName = 'seealso' then

View File

@ -2148,6 +2148,10 @@ begin
if Assigned(DocNode.ErrorsDoc) then
AppendDescrSection(AElement, BodyElement, DocNode.ErrorsDoc, SDocErrors);
// Append Version info
if Assigned(DocNode.Version) then
AppendDescrSection(AElement, BodyElement, DocNode.Version, SDocVersion);
// Append "See also" section
AppendSeeAlsoSection(AElement,DocNode);

View File

@ -58,6 +58,7 @@ Type
Procedure StartDescription; override;
Procedure StartAccess; override;
Procedure StartErrors; override;
Procedure StartVersion; override;
Procedure StartSeealso; override;
Procedure EndSeealso; override;
procedure StartUnitOverview(AModuleName,AModuleLabel : String);override;
@ -597,6 +598,11 @@ begin
Writeln('\Errors');
end;
procedure TLaTeXWriter.StartVersion;
begin
Writeln('\VersionInfo');
end;
Procedure TLatexWriter.StartAccess;
begin

View File

@ -16,6 +16,7 @@ Type
Module: TPasModule;
ModuleName: String;
FLastURL : DomString;
private
Protected
// Writing support.
procedure Write(const s: String); virtual;
@ -54,6 +55,7 @@ Type
Procedure StartDescription; Virtual;
Procedure StartAccess; Virtual;
Procedure StartErrors; Virtual;
Procedure StartVersion; Virtual;
Procedure StartSeealso; Virtual;
Procedure EndSeealso; Virtual;
// Procedures which MUST be overridden in descendents;
@ -305,6 +307,13 @@ begin
Writeln(SDocErrors+':');
end;
Procedure TLinearWriter.StartVersion;
begin
Writeln('');
Writeln(SDocVersion+':');
end;
Procedure TLinearWriter.StartSeealso;
begin
@ -353,7 +362,12 @@ begin
(not IsDescrNodeEmpty(DocNode.ShortDescr))) then
begin
StartSubSection(SDocDescription);
WriteDescr(ClassDecl);
WriteDescr(ClassDecl,DocNode);
If Assigned(DocNode.Version) then
begin
StartSubSection(SDocVersion);
WriteDescr(ClassDecl,DocNode.Version);
end;
end;
// Write method overview
@ -539,6 +553,7 @@ procedure TLinearWriter.WriteResourceStrings(ASection: TPasSection);
var
ResStrDecl: TPasResString;
i: Integer;
DocNode : TDocNode;
begin
if ASection.ResStrings.Count > 0 then
begin
@ -551,7 +566,12 @@ begin
EndListing;
WriteLabel(ResStrDecl);
WriteIndex(ResStrDecl);
WriteDescr(ResStrDecl);
DocNode:=WriteDescr(ResStrDecl);
If Assigned(DocNode) and Assigned(DocNode.Version) then
begin
Writeln(Format('%s : ',[SDocVersion]));
WriteDescr(ResStrDecl, DocNode.Version);
end;
end;
end;
end;
@ -743,8 +763,13 @@ begin
WriteENumElements(TypeDecl as TPasEnumType);
end;
WriteDescr(TypeDecl);
If Assigned(DocNode) and Assigned(DocNode.Version) then
begin
Writeln(Format('%s : ',[SDocVersion]));
WriteDescr(TypeDecl, DocNode.Version);
end;
DescrEndParaGraph;
end;
end;
end;
end;
@ -752,6 +777,8 @@ procedure TLinearWriter.WriteVars(ASection: TPasSection);
var
VarDecl: TPasVariable;
i: Integer;
DocNode : TDocNode;
begin
if ASection.Variables.Count > 0 then
begin
@ -765,7 +792,12 @@ begin
EndListing;
WriteLabel(VarDecl);
WriteIndex(VarDecl);
WriteDescr(VarDecl);
DocNode:=WriteDescr(VarDecl);
If Assigned(DocNode) and Assigned(DocNode.Version) then
begin
Writeln(Format('%s : ',[SDocVersion]));
WriteDescr(VarDecl, DocNode.Version);
end;
DescrEndParaGraph;
end;
end;
@ -817,19 +849,27 @@ begin
StartVisibility;
Writeln(VisibilityNames[Visibility])
end;
if Assigned(DocNode) and Assigned(DocNode.Descr) then
if Assigned(DocNode) then
begin
StartDescription;
WriteDescr(ProcDecl);
If Assigned(DocNode.Descr) then
begin
StartDescription;
WriteDescr(ProcDecl);
end;
if Assigned(DocNode.ErrorsDoc) then
begin
StartErrors;
WriteDescr(ProcDecl, DocNode.ErrorsDoc);
end;
if Assigned(DocNode.Version) then
begin
StartVersion;
WriteDescr(ProcDecl, DocNode.Version);
end;
WriteSeeAlso(DocNode);
EndProcedure;
WriteExample(DocNode);
end;
if Assigned(DocNode) and Assigned(DocNode.ErrorsDoc) then
begin
StartErrors;
WriteDescr(ProcDecl, DocNode.ErrorsDoc);
end;
WriteSeeAlso(DocNode);
EndProcedure;
WriteExample(DocNode);
end;
end;
@ -910,19 +950,27 @@ begin
S:=S+'Write';
end;
Writeln(S);
if Assigned(DocNode) and Assigned(DocNode.Descr) then
if Assigned(DocNode) then
begin
StartDescription;
WriteDescr(PropDecl);
if Assigned(DocNode.Descr) then
begin
StartDescription;
WriteDescr(PropDecl);
end;
if Assigned(DocNode.ErrorsDoc) then
begin
StartErrors;
WriteDescr(PropDecl, DocNode.ErrorsDoc);
end;
if Assigned(DocNode.Version) then
begin
StartVersion;
WriteDescr(PropDecl, DocNode.Version);
end;
WriteSeeAlso(DocNode);
EndProperty;
WriteExample(DocNode);
end;
if Assigned(DocNode) and Assigned(DocNode.ErrorsDoc) then
begin
StartErrors;
WriteDescr(PropDecl, DocNode.ErrorsDoc);
end;
WriteSeeAlso(DocNode);
EndProperty;
WriteExample(DocNode);
end;
end;

View File

@ -158,7 +158,7 @@ type
Function InterpretOption(Const Cmd,Arg : String) : Boolean; Virtual;
Class Procedure Usage(List : TStrings); virtual;
procedure WriteDoc; virtual; Abstract;
procedure WriteDescr(Element: TPasElement);
Function WriteDescr(Element: TPasElement) : TDocNode;
procedure WriteDescr(Element: TPasElement; DocNode: TDocNode);
procedure WriteDescr(AContext: TPasElement; DescrNode: TDOMElement); virtual;
Procedure FPDocError(Msg : String);
@ -1038,10 +1038,11 @@ begin
Inherited;
end;
procedure TFPDocWriter.WriteDescr(Element: TPasElement);
Function TFPDocWriter.WriteDescr(Element: TPasElement) : TDocNode;
begin
WriteDescr(ELement,Engine.FindDocNode(Element));
Result:=Engine.FindDocNode(Element);
WriteDescr(ELement,Result);
end;
procedure TFPDocWriter.WriteDescr(Element: TPasElement; DocNode: TDocNode);