@@ -55,7 +55,7 @@ class HTMLTag {
55
55
operator TagType () const { return Value; }
56
56
operator bool () = delete;
57
57
58
- bool IsSelfClosing () const ;
58
+ bool isSelfClosing () const ;
59
59
llvm::SmallString<16 > ToString () const ;
60
60
61
61
private:
@@ -71,7 +71,7 @@ struct HTMLNode {
71
71
HTMLNode (NodeType Type) : Type(Type) {}
72
72
virtual ~HTMLNode () = default ;
73
73
74
- virtual void Render (llvm::raw_ostream &OS, int IndentationLevel) = 0;
74
+ virtual void render (llvm::raw_ostream &OS, int IndentationLevel) = 0;
75
75
NodeType Type; // Type of node
76
76
};
77
77
@@ -80,7 +80,7 @@ struct TextNode : public HTMLNode {
80
80
: HTMLNode(NodeType::NODE_TEXT), Text(Text.str()) {}
81
81
82
82
std::string Text; // Content of node
83
- void Render (llvm::raw_ostream &OS, int IndentationLevel) override ;
83
+ void render (llvm::raw_ostream &OS, int IndentationLevel) override ;
84
84
};
85
85
86
86
struct TagNode : public HTMLNode {
@@ -94,25 +94,25 @@ struct TagNode : public HTMLNode {
94
94
std::vector<std::pair<std::string, std::string>>
95
95
Attributes; // List of key-value attributes for tag
96
96
97
- void Render (llvm::raw_ostream &OS, int IndentationLevel) override ;
97
+ void render (llvm::raw_ostream &OS, int IndentationLevel) override ;
98
98
};
99
99
100
100
constexpr const char *kDoctypeDecl = " <!DOCTYPE html>" ;
101
101
102
102
struct HTMLFile {
103
103
std::vector<std::unique_ptr<HTMLNode>> Children; // List of child nodes
104
- void Render (llvm::raw_ostream &OS) {
104
+ void render (llvm::raw_ostream &OS) {
105
105
OS << kDoctypeDecl << " \n " ;
106
106
for (const auto &C : Children) {
107
- C->Render (OS, 0 );
107
+ C->render (OS, 0 );
108
108
OS << " \n " ;
109
109
}
110
110
}
111
111
};
112
112
113
113
} // namespace
114
114
115
- bool HTMLTag::IsSelfClosing () const {
115
+ bool HTMLTag::isSelfClosing () const {
116
116
switch (Value) {
117
117
case HTMLTag::TAG_META:
118
118
case HTMLTag::TAG_LINK:
@@ -177,12 +177,12 @@ llvm::SmallString<16> HTMLTag::ToString() const {
177
177
llvm_unreachable (" Unhandled HTMLTag::TagType" );
178
178
}
179
179
180
- void TextNode::Render (llvm::raw_ostream &OS, int IndentationLevel) {
180
+ void TextNode::render (llvm::raw_ostream &OS, int IndentationLevel) {
181
181
OS.indent (IndentationLevel * 2 );
182
182
printHTMLEscaped (Text, OS);
183
183
}
184
184
185
- void TagNode::Render (llvm::raw_ostream &OS, int IndentationLevel) {
185
+ void TagNode::render (llvm::raw_ostream &OS, int IndentationLevel) {
186
186
// Children nodes are rendered in the same line if all of them are text nodes
187
187
bool InlineChildren = true ;
188
188
for (const auto &C : Children)
@@ -194,7 +194,7 @@ void TagNode::Render(llvm::raw_ostream &OS, int IndentationLevel) {
194
194
OS << " <" << Tag.ToString ();
195
195
for (const auto &A : Attributes)
196
196
OS << " " << A.first << " =\" " << A.second << " \" " ;
197
- if (Tag.IsSelfClosing ()) {
197
+ if (Tag.isSelfClosing ()) {
198
198
OS << " />" ;
199
199
return ;
200
200
}
@@ -205,7 +205,7 @@ void TagNode::Render(llvm::raw_ostream &OS, int IndentationLevel) {
205
205
for (const auto &C : Children) {
206
206
int ChildrenIndentation =
207
207
InlineChildren || !NewLineRendered ? 0 : IndentationLevel + 1 ;
208
- C->Render (OS, ChildrenIndentation);
208
+ C->render (OS, ChildrenIndentation);
209
209
if (!InlineChildren && (C == Children.back () ||
210
210
(C->Type != NodeType::NODE_TEXT ||
211
211
(&C + 1 )->get ()->Type != NodeType::NODE_TEXT))) {
@@ -221,7 +221,7 @@ void TagNode::Render(llvm::raw_ostream &OS, int IndentationLevel) {
221
221
222
222
template <typename Derived, typename Base,
223
223
typename = std::enable_if<std::is_base_of<Derived, Base>::value>>
224
- static void AppendVector (std::vector<Derived> &&New,
224
+ static void appendVector (std::vector<Derived> &&New,
225
225
std::vector<Base> &Original) {
226
226
std::move (New.begin (), New.end (), std::back_inserter (Original));
227
227
}
@@ -322,8 +322,7 @@ genReference(const Reference &Type, StringRef CurrentDirectory,
322
322
if (Type.Path .empty ()) {
323
323
if (!JumpToSection)
324
324
return std::make_unique<TextNode>(Type.Name );
325
- else
326
- return genLink (Type.Name , " #" + *JumpToSection);
325
+ return genLink (Type.Name , " #" + *JumpToSection);
327
326
}
328
327
llvm::SmallString<64 > Path = Type.getRelativeFilePath (CurrentDirectory);
329
328
llvm::sys::path::append (Path, Type.getFileBaseName () + " .html" );
@@ -366,7 +365,7 @@ genEnumsBlock(const std::vector<EnumInfo> &Enums,
366
365
auto &DivBody = Out.back ();
367
366
for (const auto &E : Enums) {
368
367
std::vector<std::unique_ptr<TagNode>> Nodes = genHTML (E, CDCtx);
369
- AppendVector (std::move (Nodes), DivBody->Children );
368
+ appendVector (std::move (Nodes), DivBody->Children );
370
369
}
371
370
return Out;
372
371
}
@@ -397,7 +396,7 @@ genFunctionsBlock(const std::vector<FunctionInfo> &Functions,
397
396
for (const auto &F : Functions) {
398
397
std::vector<std::unique_ptr<TagNode>> Nodes =
399
398
genHTML (F, CDCtx, ParentInfoDir);
400
- AppendVector (std::move (Nodes), DivBody->Children );
399
+ appendVector (std::move (Nodes), DivBody->Children );
401
400
}
402
401
return Out;
403
402
}
@@ -487,10 +486,10 @@ genFileHeadNodes(StringRef Title, StringRef InfoPath,
487
486
Out.emplace_back (std::make_unique<TagNode>(HTMLTag::TAG_TITLE, Title));
488
487
std::vector<std::unique_ptr<TagNode>> StylesheetsNodes =
489
488
genStylesheetsHTML (InfoPath, CDCtx);
490
- AppendVector (std::move (StylesheetsNodes), Out);
489
+ appendVector (std::move (StylesheetsNodes), Out);
491
490
std::vector<std::unique_ptr<TagNode>> JsNodes =
492
491
genJsScriptsHTML (InfoPath, CDCtx);
493
- AppendVector (std::move (JsNodes), Out);
492
+ appendVector (std::move (JsNodes), Out);
494
493
return Out;
495
494
}
496
495
@@ -522,15 +521,15 @@ static std::unique_ptr<TagNode> genInfoFileMainNode(
522
521
MainContentNode->Attributes .emplace_back (" id" , " main-content" );
523
522
MainContentNode->Attributes .emplace_back (
524
523
" class" , " col-xs-12 col-sm-9 col-md-8 main-content" );
525
- AppendVector (std::move (MainContentInnerNodes), MainContentNode->Children );
524
+ appendVector (std::move (MainContentInnerNodes), MainContentNode->Children );
526
525
527
526
auto RightSidebarNode = std::make_unique<TagNode>(HTMLTag::TAG_DIV);
528
527
RightSidebarNode->Attributes .emplace_back (" id" , " sidebar-right" );
529
528
RightSidebarNode->Attributes .emplace_back (
530
529
" class" , " col-xs-6 col-sm-6 col-md-2 sidebar sidebar-offcanvas-right" );
531
530
std::vector<std::unique_ptr<TagNode>> InfoIndexHTML =
532
531
genHTML (InfoIndex, InfoPath, true );
533
- AppendVector (std::move (InfoIndexHTML), RightSidebarNode->Children );
532
+ appendVector (std::move (InfoIndexHTML), RightSidebarNode->Children );
534
533
535
534
MainNode->Children .emplace_back (std::move (LeftSidebarNode));
536
535
MainNode->Children .emplace_back (std::move (MainContentNode));
@@ -564,7 +563,7 @@ genInfoFile(StringRef Title, StringRef InfoPath,
564
563
genInfoFileMainNode (InfoPath, MainContentNodes, InfoIndex);
565
564
std::unique_ptr<TagNode> FooterNode = genFileFooterNode ();
566
565
567
- AppendVector (std::move (HeadNodes), F.Children );
566
+ appendVector (std::move (HeadNodes), F.Children );
568
567
F.Children .emplace_back (std::move (HeaderNode));
569
568
F.Children .emplace_back (std::move (MainNode));
570
569
F.Children .emplace_back (std::move (FooterNode));
@@ -603,7 +602,7 @@ genHTML(const Index &Index, StringRef InfoPath, bool IsOutermostList) {
603
602
for (const auto &C : Index.Children ) {
604
603
auto LiBody = std::make_unique<TagNode>(HTMLTag::TAG_LI);
605
604
std::vector<std::unique_ptr<TagNode>> Nodes = genHTML (C, InfoPath, false );
606
- AppendVector (std::move (Nodes), LiBody->Children );
605
+ appendVector (std::move (Nodes), LiBody->Children );
607
606
UlBody->Children .emplace_back (std::move (LiBody));
608
607
}
609
608
return Out;
@@ -618,7 +617,9 @@ static std::unique_ptr<HTMLNode> genHTML(const CommentInfo &I) {
618
617
FullComment->Children .emplace_back (std::move (Node));
619
618
}
620
619
return std::move (FullComment);
621
- } else if (I.Kind == " ParagraphComment" ) {
620
+ }
621
+
622
+ if (I.Kind == " ParagraphComment" ) {
622
623
auto ParagraphComment = std::make_unique<TagNode>(HTMLTag::TAG_P);
623
624
for (const auto &Child : I.Children ) {
624
625
std::unique_ptr<HTMLNode> Node = genHTML (*Child);
@@ -628,7 +629,9 @@ static std::unique_ptr<HTMLNode> genHTML(const CommentInfo &I) {
628
629
if (ParagraphComment->Children .empty ())
629
630
return nullptr ;
630
631
return std::move (ParagraphComment);
631
- } else if (I.Kind == " TextComment" ) {
632
+ }
633
+
634
+ if (I.Kind == " TextComment" ) {
632
635
if (I.Text == " " )
633
636
return nullptr ;
634
637
return std::make_unique<TextNode>(I.Text );
@@ -648,11 +651,7 @@ static std::unique_ptr<TagNode> genHTML(const std::vector<CommentInfo> &C) {
648
651
static std::vector<std::unique_ptr<TagNode>>
649
652
genHTML (const EnumInfo &I, const ClangDocContext &CDCtx) {
650
653
std::vector<std::unique_ptr<TagNode>> Out;
651
- std::string EnumType;
652
- if (I.Scoped )
653
- EnumType = " enum class " ;
654
- else
655
- EnumType = " enum " ;
654
+ std::string EnumType = I.Scoped ? " enum class " : " enum " ;
656
655
657
656
Out.emplace_back (
658
657
std::make_unique<TagNode>(HTMLTag::TAG_H3, EnumType + I.Name ));
@@ -746,17 +745,17 @@ genHTML(const NamespaceInfo &I, Index &InfoIndex, const ClangDocContext &CDCtx,
746
745
747
746
std::vector<std::unique_ptr<TagNode>> ChildNamespaces =
748
747
genReferencesBlock (I.Children .Namespaces , " Namespaces" , BasePath);
749
- AppendVector (std::move (ChildNamespaces), Out);
748
+ appendVector (std::move (ChildNamespaces), Out);
750
749
std::vector<std::unique_ptr<TagNode>> ChildRecords =
751
750
genReferencesBlock (I.Children .Records , " Records" , BasePath);
752
- AppendVector (std::move (ChildRecords), Out);
751
+ appendVector (std::move (ChildRecords), Out);
753
752
754
753
std::vector<std::unique_ptr<TagNode>> ChildFunctions =
755
754
genFunctionsBlock (I.Children .Functions , CDCtx, BasePath);
756
- AppendVector (std::move (ChildFunctions), Out);
755
+ appendVector (std::move (ChildFunctions), Out);
757
756
std::vector<std::unique_ptr<TagNode>> ChildEnums =
758
757
genEnumsBlock (I.Children .Enums , CDCtx);
759
- AppendVector (std::move (ChildEnums), Out);
758
+ appendVector (std::move (ChildEnums), Out);
760
759
761
760
if (!I.Children .Namespaces .empty ())
762
761
InfoIndex.Children .emplace_back (" Namespaces" , " Namespaces" );
@@ -800,29 +799,29 @@ genHTML(const RecordInfo &I, Index &InfoIndex, const ClangDocContext &CDCtx,
800
799
auto &PBody = Out.back ();
801
800
PBody->Children .emplace_back (std::make_unique<TextNode>(" Inherits from " ));
802
801
if (Parents.empty ())
803
- AppendVector (std::move (VParents), PBody->Children );
802
+ appendVector (std::move (VParents), PBody->Children );
804
803
else if (VParents.empty ())
805
- AppendVector (std::move (Parents), PBody->Children );
804
+ appendVector (std::move (Parents), PBody->Children );
806
805
else {
807
- AppendVector (std::move (Parents), PBody->Children );
806
+ appendVector (std::move (Parents), PBody->Children );
808
807
PBody->Children .emplace_back (std::make_unique<TextNode>(" , " ));
809
- AppendVector (std::move (VParents), PBody->Children );
808
+ appendVector (std::move (VParents), PBody->Children );
810
809
}
811
810
}
812
811
813
812
std::vector<std::unique_ptr<TagNode>> Members =
814
813
genRecordMembersBlock (I.Members , I.Path );
815
- AppendVector (std::move (Members), Out);
814
+ appendVector (std::move (Members), Out);
816
815
std::vector<std::unique_ptr<TagNode>> ChildRecords =
817
816
genReferencesBlock (I.Children .Records , " Records" , I.Path );
818
- AppendVector (std::move (ChildRecords), Out);
817
+ appendVector (std::move (ChildRecords), Out);
819
818
820
819
std::vector<std::unique_ptr<TagNode>> ChildFunctions =
821
820
genFunctionsBlock (I.Children .Functions , CDCtx, I.Path );
822
- AppendVector (std::move (ChildFunctions), Out);
821
+ appendVector (std::move (ChildFunctions), Out);
823
822
std::vector<std::unique_ptr<TagNode>> ChildEnums =
824
823
genEnumsBlock (I.Children .Enums , CDCtx);
825
- AppendVector (std::move (ChildEnums), Out);
824
+ appendVector (std::move (ChildEnums), Out);
826
825
827
826
if (!I.Members .empty ())
828
827
InfoIndex.Children .emplace_back (" Members" , " Members" );
@@ -945,7 +944,7 @@ llvm::Error HTMLGenerator::generateDocForInfo(Info *I, llvm::raw_ostream &OS,
945
944
946
945
HTMLFile F = genInfoFile (InfoTitle, I->getRelativeFilePath (" " ),
947
946
MainContentNodes, InfoIndex, CDCtx);
948
- F.Render (OS);
947
+ F.render (OS);
949
948
950
949
return llvm::Error::success ();
951
950
}
@@ -968,7 +967,7 @@ static std::string getRefType(InfoType IT) {
968
967
llvm_unreachable (" Unknown InfoType" );
969
968
}
970
969
971
- static llvm::Error SerializeIndex (ClangDocContext &CDCtx) {
970
+ static llvm::Error serializeIndex (ClangDocContext &CDCtx) {
972
971
std::error_code OK;
973
972
std::error_code FileErr;
974
973
llvm::SmallString<128 > FilePath;
@@ -1018,7 +1017,7 @@ static std::unique_ptr<TagNode> genIndexFileMainNode() {
1018
1017
return MainNode;
1019
1018
}
1020
1019
1021
- static llvm::Error GenIndex (const ClangDocContext &CDCtx) {
1020
+ static llvm::Error genIndex (const ClangDocContext &CDCtx) {
1022
1021
std::error_code FileErr, OK;
1023
1022
llvm::SmallString<128 > IndexPath;
1024
1023
llvm::sys::path::native (CDCtx.OutDirectory , IndexPath);
@@ -1038,17 +1037,17 @@ static llvm::Error GenIndex(const ClangDocContext &CDCtx) {
1038
1037
std::unique_ptr<TagNode> MainNode = genIndexFileMainNode ();
1039
1038
std::unique_ptr<TagNode> FooterNode = genFileFooterNode ();
1040
1039
1041
- AppendVector (std::move (HeadNodes), F.Children );
1040
+ appendVector (std::move (HeadNodes), F.Children );
1042
1041
F.Children .emplace_back (std::move (HeaderNode));
1043
1042
F.Children .emplace_back (std::move (MainNode));
1044
1043
F.Children .emplace_back (std::move (FooterNode));
1045
1044
1046
- F.Render (IndexOS);
1045
+ F.render (IndexOS);
1047
1046
1048
1047
return llvm::Error::success ();
1049
1048
}
1050
1049
1051
- static llvm::Error CopyFile (StringRef FilePath, StringRef OutDirectory) {
1050
+ static llvm::Error copyFile (StringRef FilePath, StringRef OutDirectory) {
1052
1051
llvm::SmallString<128 > PathWrite;
1053
1052
llvm::sys::path::native (OutDirectory, PathWrite);
1054
1053
llvm::sys::path::append (PathWrite, llvm::sys::path::filename (FilePath));
@@ -1066,20 +1065,20 @@ static llvm::Error CopyFile(StringRef FilePath, StringRef OutDirectory) {
1066
1065
}
1067
1066
1068
1067
llvm::Error HTMLGenerator::createResources (ClangDocContext &CDCtx) {
1069
- auto Err = SerializeIndex (CDCtx);
1068
+ auto Err = serializeIndex (CDCtx);
1070
1069
if (Err)
1071
1070
return Err;
1072
- Err = GenIndex (CDCtx);
1071
+ Err = genIndex (CDCtx);
1073
1072
if (Err)
1074
1073
return Err;
1075
1074
1076
1075
for (const auto &FilePath : CDCtx.UserStylesheets ) {
1077
- Err = CopyFile (FilePath, CDCtx.OutDirectory );
1076
+ Err = copyFile (FilePath, CDCtx.OutDirectory );
1078
1077
if (Err)
1079
1078
return Err;
1080
1079
}
1081
1080
for (const auto &FilePath : CDCtx.JsScripts ) {
1082
- Err = CopyFile (FilePath, CDCtx.OutDirectory );
1081
+ Err = copyFile (FilePath, CDCtx.OutDirectory );
1083
1082
if (Err)
1084
1083
return Err;
1085
1084
}
0 commit comments