-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[clang-doc] Create a partial for HTML <head> sections #171668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
@llvm/pr-subscribers-clang-tools-extra Author: Erick Velez (evelez7) ChangesThe <head> sections of the existing partials are already identical, so Full diff: https://github.com/llvm/llvm-project/pull/171668.diff 6 Files Affected:
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")
|
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.
b1022c3 to
8a92239
Compare
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/20203 Here is the relevant piece of the build log for the reference |

The sections of the existing partials are already identical, so
creating a partial will help reduce lines in the templates. Now
changes to sections can easily propogate and can easily be added
to future HTML pages.