llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tools-extra Author: Erick Velez (evelez7) <details> <summary>Changes</summary> The <head> sections of the existing partials are already identical, so creating a partial will help reduce lines in the templates. Now changes to <head> sections can easily propogate and can easily be added to future HTML pages. --- Full diff: https://github.com/llvm/llvm-project/pull/171668.diff 6 Files Affected: - (modified) clang-tools-extra/clang-doc/HTMLGenerator.cpp (+4-1) - (modified) clang-tools-extra/clang-doc/assets/class-template.mustache (+1-14) - (added) clang-tools-extra/clang-doc/assets/head-template.mustache (+14) - (modified) clang-tools-extra/clang-doc/assets/namespace-template.mustache (+1-14) - (modified) clang-tools-extra/clang-doc/support/Utils.cpp (+3) - (modified) clang-tools-extra/clang-doc/tool/CMakeLists.txt (+1) ``````````diff diff --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp b/clang-tools-extra/clang-doc/HTMLGenerator.cpp index 6f58c3d00fa28..19018f2cf845d 100644 --- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp +++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp @@ -66,10 +66,13 @@ Error HTMLGenerator::setupTemplateFiles(const ClangDocContext &CDCtx) { ConvertToNative(CDCtx.MustacheTemplates.lookup("function-template")); std::string EnumFilePath = ConvertToNative(CDCtx.MustacheTemplates.lookup("enum-template")); + std::string HeadFilePath = + ConvertToNative(CDCtx.MustacheTemplates.lookup("head-template")); std::vector<std::pair<StringRef, StringRef>> Partials = { {"Comments", CommentFilePath}, {"FunctionPartial", FunctionFilePath}, - {"EnumPartial", EnumFilePath}}; + {"EnumPartial", EnumFilePath}, + {"HeadPartial", HeadFilePath}}; if (Error Err = setupTemplate(NamespaceTemplate, NamespaceFilePath, Partials)) return Err; diff --git a/clang-tools-extra/clang-doc/assets/class-template.mustache b/clang-tools-extra/clang-doc/assets/class-template.mustache index 1197e76ab553c..9c5019510b43c 100644 --- a/clang-tools-extra/clang-doc/assets/class-template.mustache +++ b/clang-tools-extra/clang-doc/assets/class-template.mustache @@ -7,20 +7,7 @@ }} <!DOCTYPE html> <html lang="en-US"> -<head> - <meta charset="utf-8"/> - <title>{{Name}}</title> - {{#Stylesheets}} - <link rel="stylesheet" type="text/css" href="{{.}}"/> - {{/Stylesheets}} - {{#Scripts}} - <script src="{{.}}"></script> - {{/Scripts}} - {{! Highlight.js dependency for syntax highlighting }} - <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css"> - <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script> - <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/cpp.min.js"></script> -</head> +{{>HeadPartial}} <body> <nav class="navbar"> <div class="navbar__container"> diff --git a/clang-tools-extra/clang-doc/assets/head-template.mustache b/clang-tools-extra/clang-doc/assets/head-template.mustache new file mode 100644 index 0000000000000..f0a8057a9c3dc --- /dev/null +++ b/clang-tools-extra/clang-doc/assets/head-template.mustache @@ -0,0 +1,14 @@ +<head> + <meta charset="utf-8"/> + <title>{{Name}}</title> + {{#Stylesheets}} + <link rel="stylesheet" type="text/css" href="{{.}}"/> + {{/Stylesheets}} + {{#Scripts}} + <script src="{{.}}"></script> + {{/Scripts}} + {{! Highlight.js dependency for syntax highlighting }} + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css"> + <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/cpp.min.js"></script> +</head> diff --git a/clang-tools-extra/clang-doc/assets/namespace-template.mustache b/clang-tools-extra/clang-doc/assets/namespace-template.mustache index 7fb66cadbb8e8..f386eb2e6a581 100644 --- a/clang-tools-extra/clang-doc/assets/namespace-template.mustache +++ b/clang-tools-extra/clang-doc/assets/namespace-template.mustache @@ -7,20 +7,7 @@ }} <!DOCTYPE html> <html lang="en-US"> -<head> - <meta charset="utf-8"/> - <title>{{NamespaceTitle}}</title> - {{#Stylesheets}} - <link rel="stylesheet" type="text/css" href="{{.}}"/> - {{/Stylesheets}} - {{#Scripts}} - <script src="{{.}}"></script> - {{/Scripts}} - {{! Highlight.js dependency for syntax highlighting }} - <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css"> - <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script> - <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/cpp.min.js"></script> -</head> +{{>HeadPartial}} <body> <nav class="navbar"> <div class="navbar__container"> diff --git a/clang-tools-extra/clang-doc/support/Utils.cpp b/clang-tools-extra/clang-doc/support/Utils.cpp index f410bfcf956d4..50e849dc26c79 100644 --- a/clang-tools-extra/clang-doc/support/Utils.cpp +++ b/clang-tools-extra/clang-doc/support/Utils.cpp @@ -56,6 +56,8 @@ void getHtmlFiles(StringRef AssetsPath, clang::doc::ClangDocContext &CDCtx) { appendPathPosix(AssetsPath, "function-template.mustache"); SmallString<128> CommentTemplate = appendPathPosix(AssetsPath, "comment-template.mustache"); + SmallString<128> HeadTemplate = + appendPathPosix(AssetsPath, "head-template.mustache"); CDCtx.MustacheTemplates.insert( {"namespace-template", NamespaceTemplate.c_str()}); @@ -64,4 +66,5 @@ void getHtmlFiles(StringRef AssetsPath, clang::doc::ClangDocContext &CDCtx) { CDCtx.MustacheTemplates.insert( {"function-template", FunctionTemplate.c_str()}); CDCtx.MustacheTemplates.insert({"comment-template", CommentTemplate.c_str()}); + CDCtx.MustacheTemplates.insert({"head-template", HeadTemplate.c_str()}); } diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index 7c9a94adec8a4..eb8f937bae831 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -31,6 +31,7 @@ set(assets function-template.mustache namespace-template.mustache template.mustache + head-template.mustache ) set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets") `````````` </details> https://github.com/llvm/llvm-project/pull/171668 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
