📄 uhtmldoc.pas
字号:
//including to lists of all record-likes
for rk := low(rk) to high(rk) do
WriteLn(F, '<td align=center><a href="', DescFilePreFix[rk],
'List.html">', Localize(Plurals[rk]), '</a></td>');
end;
WriteLn(F, '</tr></table>');
WriteLn(F, '<hr>'); //end the header
end;
except //in case of an error
CloseFile(F); //close the file, then
raise; //forward the error
end;
end;
{Writes the footer of a HTML file and closes it.
~param F the HTML file to end and close }
procedure THTMLDoc.EndFile(var F: TextFile);
begin
try
if TextFooterFile <> '' then //custom footer supplied?
WriteLn(F, FTextFooter) //just write it
else
begin
// WriteLn(F, '<div align=center><font size="-2">Generated by JADD - Just Another DelphiDoc</font></div>');
WriteLn(F, '</body>');
WriteLn(F, '</html>'); //end the HTML file
end;
finally
CloseFile(F); //finally close the file
end;
end;
{Writes a list of the functions documented in the current file.
~param F the file to write the documentation to
~param List the list of function to generate a list from }
procedure THTMLDoc.ShowFunctionList(var F: TextFile; List: TIdentifierList);
var i :Integer; //counter through all identifiers
point :Integer; //positon of a point in comment
Func :TIdentifier; //each identifier
Comment :TComment; //comment of the identifier
Data :String; //main comment of it
begin
if not List.IsEmpty then //if the list is not empty
begin
List.Sort; //sort the list
WriteLn(F, '<dl class=funclist>'); //start the list
for i := 0 to List.Count - 1 do //for each function in the list
begin
Func := List[i]; //get it
if not DoNotDocumentIdentifier(Func) then //documented?
begin
Write(F, ' <dt>'); //start entry of it
Write(F, GetScope(Func.Scope)); //write its scope
//write portability issues
Write(F, GetPortabilityIssues(Func.Portability));
if faAbstract in TFunction(Func).Attributes then //if abstract
Write(F, FCommentFormats.FAbstractIconText); //write indicating icon
Write(F, ' ');
if faClassMethod in TFunction(Func).Attributes then //if it is a class
Write(F, ReservedWord('class'), ' '); //method, write it
//write the kind of the function and its linked name
Write(F, ReservedWord(FuncNames[TFunction(Func).FuncKind]),
' <a href="#I_');
if Func.InternalNameIndex <> 0 then
Write(F, Func.InternalNameIndex);
Write(F, Func.Name, '">', Func.Name, '</a>');
WriteLn(F, '</dt>'); //end the definition
Write(F, ' <dd>'); //start the short description
SetCommentIdent(Func, Func.InFile);
Comment := GetComment; //get comment of the function
try
//check if it is deprecated
if Comment.GetAndDeleteSection(csDeprecated, Data) then
Write(F, '<b>', Localize(dtSpecialDeprecated), '</b> ');
//get the main comment
Comment.GetAndDeleteSection(csComment, Data);
FInheritedDocSection := idsText;
Data := ParseCommentText(Data); //and evaluate it
FInheritedDocSection := idsInvalid;
finally
Comment.Free;
end;
//write the first sentence
repeat
point := pos('.', Data); //get position of the next point
if point <> 0 then //found a point?
begin
Write(F, copy(Data, 1, point)); //write this part
Delete(Data, 1, point);
//a whitespace has to follow the point (could be an abbrevation)
if (Data = '') or (Data[1] in [#0..' ']) then //whitespace follows?
point := 0; //end of the sentence
end
else
Write(F, Data); //just write the whole comment
until point = 0; //until sentence written
WriteLn(F, '</dd>'); //end the short description
end; //if not DoNotDocumentIdentifier(Func)
end; //for i := 0 to List.Count - 1
WriteLn(F, '</dl>'); //end the list of the functions
end; //if not List.IsEmpty
end;
//header titles of the lists of different kinds of identifiers in
//files
const DeclName: array[TWriteKind] of TDocumentationTexts =
(dtDocumentationFileDeclarationsHeaderVar,
dtDocumentationFileDeclarationsHeaderThreadVar,
dtDocumentationFileDeclarationsHeaderConst,
dtDocumentationFileDeclarationsHeaderResourceString,
dtDocumentationFileDeclarationsHeaderSimpleTypes,
dtDocumentationFileDeclarationsHeaderFunctions);
//the classes of the lists of different kinds of identifiers in files
DeclTypeClass: array[TWriteKind] of TIdentifierClass =
(TVariable, TVariable, TConstant,
TResourceString, TType, TFunction);
//the name of anchors to the beginning of the lists of different
//kinds of identifiers in files
AnchorDeclName: array[TWriteKind] of String =
('Variables', 'ThreadVariables', 'Constants',
'ResourceStrings', 'SimpleTypes', 'Functions');
{Writes a short linked list of the given kind of identifiers in the file.
~param F the file to write the list to
~param AFile the file whose identifiers to write
~param WriteType the kind of identifiers to write }
procedure THTMLDoc.WriteVarConstFuncsList(var F: TextFile; AFile: TPascalFile;
WriteType: TWriteKind);
var AClass :TIdentifierClass; //the class of the identifier to get
{Gets the list of the identifiers to write.
~param Scope the scope the identifier has to be in
~param List the list to add the identifiers to }
procedure GetList(Scope: TScope; List: TIdentifierList);
var i :Integer; //counter through the identifiers of the file
Ident :TIdentifier; //each identifier
begin
for i := 0 to AFile.Idents.Count - 1 do //for each identifier
begin
Ident := AFile.Idents[i]; //get it
//is of the right kind and has the right scope?
if (((Ident is AClass) and
//but not a record-like type?
((WriteType <> wkSimpleType) or not (Ident is TRecordType)) and
//and also correctly a treat-variable or not?
(not (WriteType in [wkVar, wkThreadVar]) or
(TVariable(Ident).IsThreadVar = (WriteType = wkThreadVar)))) or
((WriteType = wkConst) and (Ident is TEnumTypeItem))) and
//documented?
(Ident.Scope = Scope) and not DoNotDocumentIdentifier(Ident) then
List.AddIdent(Ident); //add the identifier to the list
end;
end;
{Writes a list of non-function identifiers.
~param List the list to write }
procedure WriteList(List: TIdentifierList);
var i :Integer; //counter through all identifiers
Ident :TIdentifier; //each identifier
begin
if not List.IsEmpty then //if the list is not empty
begin
List.Sort; //sort it
for i := 0 to List.Count - 1 do //for each identifier
begin
Ident := List[i]; //get it
if i <> 0 then //if not the first
Write(F, ', '); //add spearator
Write(F, '<a href="#I_'); //write (local) link to it
if Ident.InternalNameIndex <> 0 then
Write(F, Ident.InternalNameIndex);
Write(F, Ident.Name, '">', Ident.Name, '</a>');
end;
WriteLn(F, '<br>'); //and end the line
end
else //write the empty list
WriteLn(F, '<i>', Localize(dtDocumentationEmptyList), '</i><br>');
end;
var List :TIdentifierList; //list of identifiers in interface
ImplList :TIdentifierList; //list of them in implementation part
begin
AClass := DeclTypeClass[WriteType]; //get class of identifiers
List := TIdentifierList.Create; //create interface list
try
GetList(sInterface, List); //get the list of the identifiers
ImplList := TIdentifierList.Create; //create implementation list
try
if not NoPrivateOnlyInterface then //implementation should be documented?
GetList(sImplementation, ImplList); //get the identifier
if not List.IsEmpty or not ImplList.IsEmpty then //identifiers found?
begin
//write the header of the kind of identifiers
WriteLn(F, '<h2 class=identslist>',
Localize(dtDocumentationFileDeclarationsHeaderPrefix),
Localize(DeclName[WriteType]), ':</h2>');
//write header for identifiers in the interface part
Write(F, ' <b class=identsscope>',
Localize(dtDocumentationFileDeclarationsHeaderGlobalPrefix),
Localize(DeclName[WriteType]), ':</b> ');
if WriteType <> wkFunc then //and write the list
WriteList(List)
else
if List.IsEmpty then //list is empty?
//write the empty list
WriteLn(F, '<i>',
Localize(dtDocumentationFileDeclarationsHeaderLocalPrefix),
Localize(dtDocumentationEmptyList), '</i><br>')
else
ShowFunctionList(F, List); //write the list
//identifiers in the implementation part should be documented?
if not NoPrivateOnlyInterface then
begin
//write header for identifiers in the implementation part
Write(F, ' <b class=identsscope>',
Localize(dtDocumentationFileDeclarationsHeaderLocalPrefix),
Localize(DeclName[WriteType]), ':</b> ');
if WriteType <> wkFunc then //and write the list
WriteList(ImplList)
else
if ImplList.IsEmpty then //list is empty?
//write the empty list
WriteLn(F, '<i>', Localize(dtDocumentationEmptyList), '</i><br>')
else
ShowFunctionList(F, ImplList); //write the list
end;
WriteLn(F, '<hr>'); //end the section of this kind of identifiers
end;
finally
ImplList.RemoveAll(False); //free the lists (without identifiers)
ImplList.Free;
end;
finally
List.RemoveAll(False);
List.Free;
end;
end;
{Writes a short linked list of the record-like types in the file.
~param F the file to write the list to
~param AFile the file whose record-like types should be written
~param Kind the kind of record-like types to write }
procedure THTMLDoc.WriteRecordTypeList(var F: TextFile; AFile: TPascalFile;
Kind: TRecordKind);
{Gets the list of the record-like types of that kind to write.
~param Scope the scope the identifier has to be in
~param List the list to add the identifiers to }
procedure GetList(Scope: TScope; List: TIdentifierList);
var i :Integer; //counter through all identifiers
Ident :TIdentifier; //each identifier
begin
for i := 0 to AFile.Idents.Count - 1 do //for all identifiers in the file
begin
Ident := AFile.Idents[i]; //get it
//is a record-like type of the correct kind and with correct scope?
if (Ident is TRecordType) and (Ident.Scope = Scope) and
(TRecordType(Ident).Kind = Kind) and
not DoNotDocumentIdentifier(Ident) then //documented?
List.AddIdent(Ident); //add it to the list
end;
end;
{Writes a list of linked record-like types.
~param List the list to write }
procedure WriteList(List: TIdentifierList);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -