📄 uicbasehtmldoc.pas
字号:
begin
//prepare image to be shown in the documentation
Format := FGenerator.WriteImage(Data.CharFormat, Data.JPEGFormat,
Data.Resolution, nil, Data.FileName,
Data.ImageLinks, Data.AlternativeText);
if Format <> '' then //if image is supported
FHTMLFile.WriteString(Format); //let the image be shown
end;
{Called for each node representing a short token of pascal code.
~param Code the text of the code token
~param Kind what kind of code the token is }
procedure TICHTMLVisitor.PascalCode(const Code: String; Kind: TICPascalCode);
begin
case Kind of //start the format
icpcReservedWord: FHTMLFile.WriteString('<b class="resword">');
icpcString: FHTMLFile.WriteString('<span class="string">');
icpcIdentifier: ;
else
Assert(False);
end;
WriteEncodedText(Code); //write the code
case Kind of //end the format
icpcReservedWord: FHTMLFile.WriteString('</b>');
icpcString: FHTMLFile.WriteString('</span>');
icpcIdentifier: ;
else
Assert(False);
end;
end;
{Called for each node representing a list. Each child node is an item in the
list.
~param Node the node representing a list
~param VisitChildren out: whether the children of the node (the items)
should also be visited; default is True
~todo implement more options (via CSS?!) }
procedure TICHTMLVisitor.List(Node: TICNList; var VisitChildren: Boolean);
//the attribute of the OL-tag depending on whether CSS should be used
//and the selected line marker
const OLAttributes: array[Boolean, TICListItemEnumeration] of String =
(('', ' type="A"', ' type="a"', ' type="I"', ' type="i"'),
(' class="olnumeric"',
' class="olupperlatin"', ' class="ollowerlatin"',
' class="olupperroman"', ' class="ollowerroman"'));
var i :Integer; //counter through all items of the list
begin
if Node.HasChildren then //list not empty?
begin
case Node.ItemMarker of //begin the list
iclimNone: FHTMLFile.WriteString('<ul class="ulnobullet">');
iclimEnumeration: begin
FHTMLFile.WriteString('<ol');
FHTMLFile.WriteString(OLAttributes[FGenerator.UseCSS,
Node.ItemEnumeration]);
FHTMLFile.WriteCharacter('>');
end;
iclimBullet: FHTMLFile.WriteString('<ul>');
else
Assert(False);
end;
FHTMLFile.WriteString(FGenerator.NewLine);
VisitChildren := False; //visit the items manually
for i := 0 to Node.ChildCount - 1 do //for each item of the list
begin
FHTMLFile.WriteString('<li>'); //begin item
Node.Children[i].Visit(Self); //write the item
FHTMLFile.WriteString('</li>'); //end item
FHTMLFile.WriteString(FGenerator.NewLine);
end;
case Node.ItemMarker of //end the list
iclimNone: FHTMLFile.WriteString('</ul>');
iclimEnumeration: FHTMLFile.WriteString('</ol>');
iclimBullet: FHTMLFile.WriteString('</ul>');
else
Assert(False);
end;
FHTMLFile.WriteString(FGenerator.NewLine);
end; //if Node.HasChildren
end;
{Called for each node representing a dictionary. The child nodes are used in
pairs, the first always specifies the term to be described while the second
contains the description.
~param Node the node representing a dictionary
~param VisitChildren out: whether the children of the node (the terms and
descriptions) should also be visited; default is True
~todo implement more options (via CSS?!) }
procedure TICHTMLVisitor.Dictionary(Node: TICNDictionary;
var VisitChildren: Boolean);
begin
VisitChildren := False; //don't visit the items again
HandleDictionary(Node); //show the items
end;
{Called for each node representing a topic in the documentation of identifiers
or files as derived from its comment.
~param Node the node representing a topic
~param VisitChildren out: whether the children of the node (the content)
should also be visited; default is True }
procedure TICHTMLVisitor.TopicComment(Node: TICNTopicForComment;
var VisitChildren: Boolean);
{Visits the child nodes of the main node of all documentation based on
comments and starts writes definition list for the attributs if necessary. }
procedure VisitMainCommentChildren;
var DLStarted :Boolean; //whether definition list has been started
i :Integer; //counter through child nodes
Child :TICNode; //each child node
begin
DLStarted := False; //definition list not started yet
for i := 0 to Node.ChildCount - 1 do //for all child nodes
begin
Child := Node.Children[i]; //get the child
Child.Visit(Self); //and visit it
//is the main comment and some attributes follow?
if not DLStarted and (i < Node.ChildCount - 1) and
(((Child is TICNTopicForFile) and
(TICNTopicForFile(Child).Topic = ictfCommentMain)) or
((Child is TICNTopicForIdentifier) and
(TICNTopicForIdentifier(Child).Topic = ictiCommentMain)) or
((Child is TICNTopicForClass) and
(TICNTopicForClass(Child).Topic = ictcCommentMain))) then
begin
FHTMLFile.WriteString('<dl>'); //start list of attributes
DLStarted := True; //it has been started
end;
end;
if DLStarted then //if the definition list has been started
begin
FHTMLFile.WriteString('</dl>'); //end it now
FHTMLFile.WriteString(FGenerator.NewLine);
end;
end;
var i :Integer; //counter through child nodes
begin
case Node.Topic of //handle the node
ictcComment: begin
VisitChildren := False; //will be handled now
VisitMainCommentChildren; //visit the children
end;
ictcCommentExtendedInfo: ;
ictcCommentSpecials: begin
FHTMLFile.WriteString(FGenerator.NewLine);
FHTMLFile.WriteString('<dl class="special">');
FHTMLFile.WriteString(FGenerator.NewLine);
end;
ictcCommentDeprecateds: ;
ictcCommentDeprecated: begin //make a heading and indent items
FHTMLFile.WriteString('<dt class="special">');
if not FGenerator.UseCSS then
FHTMLFile.WriteString('<strong>');
//write title for deprecated identifiers/files
if Assigned(FGenerator.CommentIdent) then
Localize(dtSpecialDeprecatedIdentifier)
else
Localize(dtSpecialDeprecatedFile);
if not FGenerator.UseCSS then
FHTMLFile.WriteString('</strong>');
FHTMLFile.WriteString('</dt>');
FHTMLFile.WriteString(FGenerator.NewLine);
FHTMLFile.WriteString('<dd class="special">');
end;
ictcCommentToDos: ;
ictcCommentToDo: begin //make a heading and indent items
FHTMLFile.WriteString('<dt class="special">');
if not FGenerator.UseCSS then
FHTMLFile.WriteString('<strong>');
Localize(dtSpecialToDo);
if not FGenerator.UseCSS then
FHTMLFile.WriteString('</strong>');
FHTMLFile.WriteString('</dt>');
FHTMLFile.WriteString(FGenerator.NewLine);
FHTMLFile.WriteString('<dd class="special">');
end;
ictcCommentFeatures: ;
ictcCommentFeature: begin //make a heading and indent items
FHTMLFile.WriteString('<dt class="special">');
if not FGenerator.UseCSS then
FHTMLFile.WriteString('<strong>');
Localize(dtSpecialFeature);
if not FGenerator.UseCSS then
FHTMLFile.WriteString('</strong>');
FHTMLFile.WriteString('</dt>');
FHTMLFile.WriteString(FGenerator.NewLine);
FHTMLFile.WriteString('<dd class="special">');
end;
ictcCommentSeeAll: begin //make a heading and indent items
FHTMLFile.WriteString(FGenerator.NewLine);
FHTMLFile.WriteString('<dt class="see">');
if not FGenerator.UseCSS then
FHTMLFile.WriteString('<strong>');
Localize(dtCommentsSeeAlso);
FHTMLFile.WriteCharacter(':');
if not FGenerator.UseCSS then
FHTMLFile.WriteString('</strong>');
FHTMLFile.WriteString('</dt><dd class="see">');
end;
ictcCommentSeeSuper: begin //write all items separated by a comma
FHTMLFile.WriteString(FGenerator.NewLine);
VisitChildren := False;
for i := 0 to Node.ChildCount - 1 do
begin
if i <> 0 then
FHTMLFile.WriteString(', ');
Node.Children[i].Visit(Self);
end;
end;
ictcCommentSee: ;
ictcCommentSeeTextSuper: begin
FHTMLFile.WriteString(FGenerator.NewLine);
FHTMLFile.WriteString('<ul>');
FHTMLFile.WriteString(FGenerator.NewLine);
end;
ictcCommentSeeText: FHTMLFile.WriteString('<li>');
ictcCommentAuthors: begin //make a heading and indent items
FHTMLFile.WriteString('<dt class="author">');
if not FGenerator.UseCSS then
FHTMLFile.WriteString('<strong>');
Localize(dtCommentAuthor);
FHTMLFile.WriteCharacter(':');
if not FGenerator.UseCSS then
FHTMLFile.WriteString('</strong>');
FHTMLFile.WriteString('</dt>');
FHTMLFile.WriteString(FGenerator.NewLine);
FHTMLFile.WriteString('<dd class="author"><ul>');
end;
ictcCommentVersions: begin //make a heading and indent items
FHTMLFile.WriteString('<dt class="version">');
if not FGenerator.UseCSS then
FHTMLFile.WriteString('<strong>');
Localize(dtCommentVersion);
FHTMLFile.WriteCharacter(':');
if not FGenerator.UseCSS then
FHTMLFile.WriteString('</strong>');
FHTMLFile.WriteString('</dt>');
FHTMLFile.WriteString(FGenerator.NewLine);
FHTMLFile.WriteString('<dd class="version"><ul>');
end;
ictcCommentAdditionals: Assert(False); //not possible
ictcCommentExamples: begin //write all examples
if not Assigned(FGenerator.CommentIdent) then
begin
FHTMLFile.WriteString('<dl class="example">');
FHTMLFile.WriteString(FGenerator.NewLine);
end;
VisitChildren := False; //handle examples here
for i := 0 to Node.ChildCount - 1 do
begin
FHTMLFile.WriteString('<dt class="example">');
if not FGenerator.UseCSS then
FHTMLFile.WriteString('<strong>');
Localize(dtCommentsExample);
if Node.ChildCount > 1 then
FHTMLFile.WriteFormatted(' %d', [i + 1]);
FHTMLFile.WriteCharacter(':');
if not FGenerator.UseCSS then
FHTMLFile.WriteString('</strong>');
FHTMLFile.WriteString('</dt>');
FHTMLFile.WriteString(FGenerator.NewLine);
FHTMLFile.WriteString('<dd class="example">');
Node.Children[i].Visit(Self); //write example
FHTMLFile.WriteString('</dd>');
FHTMLFile.WriteString(FGenerator.NewLine);
end;
if not Assigned(FGenerator.CommentIdent) then
begin
FHTMLFile.WriteString('</dl>');
FHTMLFile.WriteString(FGenerator.NewLine);
end;
end;
else
Assert(False);
end;
if VisitChildren then //children not already handled?
begin
VisitChildren := False; //will be handled now
Node.VisitChildren(Self); //write all childrens
end;
case Node.Topic of //end the topic
// ictcComment: ;
ictcCommentSpecials: begin
FHTMLFile.WriteString('</dl>');
FHTMLFile.WriteStrin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -