From 8a9223981de584858f669da448f5ff7ea9b33089 Mon Sep 17 00:00:00 2001 From: Erick Velez Date: Fri, 14 Nov 2025 21:15:11 -0800 Subject: [PATCH] [clang-doc] Create a partial for HTML sections 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. --- clang-tools-extra/clang-doc/HTMLGenerator.cpp | 5 ++++- .../clang-doc/assets/class-template.mustache | 15 +-------------- .../clang-doc/assets/head-template.mustache | 14 ++++++++++++++ .../clang-doc/assets/namespace-template.mustache | 15 +-------------- clang-tools-extra/clang-doc/support/Utils.cpp | 3 +++ clang-tools-extra/clang-doc/tool/CMakeLists.txt | 1 + 6 files changed, 24 insertions(+), 29 deletions(-) create mode 100644 clang-tools-extra/clang-doc/assets/head-template.mustache 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> 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 @@ }} - - - {{Name}} - {{#Stylesheets}} - - {{/Stylesheets}} - {{#Scripts}} - - {{/Scripts}} - {{! Highlight.js dependency for syntax highlighting }} - - - - +{{>HeadPartial}}