Skip to content

[clang-doc] Add Mustache template assets #138059

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

Open
wants to merge 1 commit into
base: users/ilovepi/clang-doc-improved-descriptions
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
471 changes: 471 additions & 0 deletions clang-tools-extra/clang-doc/assets/clang-doc-mustache.css

Large diffs are not rendered by default.

227 changes: 227 additions & 0 deletions clang-tools-extra/clang-doc/assets/class-template.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
{{!
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
See https://llvm.org/LICENSE.txt for license information.
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

This file defines the template for classes/struct
}}
<!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>
<body>
<nav class="navbar">
<div class="navbar__container">
{{#ProjectName}}
<div class="navbar__logo">
{{ProjectName}}
</div>
{{/ProjectName}}
<div class="navbar__menu">
<ul class="navbar__links">
<li class="navbar__item">
<a href="/" class="navbar__link">Namespace</a>
</li>
<li class="navbar__item">
<a href="/" class="navbar__link">Class</a>
</li>
</ul>
</div>
</div>
</nav>
<main>
<div class="container">
<div class="sidebar">
<h2>{{RecordType}} {{Name}}</h2>
<ul>
{{#PublicMembers}}
<li class="sidebar-section">
<a class="sidebar-item" href="#PublicMethods">Public Members</a>
</li>
<ul>
{{#Obj}}
<li class="sidebar-item-container">
<a class="sidebar-item" href="#{{Name}}">{{Name}}</a>
</li>
{{/Obj}}
</ul>
{{/PublicMembers}}
{{#ProtectedMembers}}
<li class="sidebar-section">
<a class="sidebar-item" href="#PublicMethods">Protected Members</a>
</li>
<ul>
{{#Obj}}
<li class="sidebar-item-container">
<a class="sidebar-item" href="#{{Name}}">{{Name}}</a>
</li>
{{/Obj}}
</ul>
{{/ProtectedMembers}}
{{#PublicFunction}}
<li class="sidebar-section">
<a class="sidebar-item" href="#PublicMethods">Public Method</a>
</li>
<ul>
{{#Obj}}
<li class="sidebar-item-container">
<a class="sidebar-item" href="#{{ID}}">{{Name}}</a>
</li>
{{/Obj}}
</ul>
{{/PublicFunction}}
{{#ProtectedFunction}}
<li class="sidebar-section">
<a class="sidebar-item" href="#ProtectedFunction">Protected Method</a>
</li>
<ul>
{{#Obj}}
<li class="sidebar-item-container">
<a class="sidebar-item" href="#{{ID}}">{{Name}}</a>
</li>
{{/Obj}}
</ul>
{{/ProtectedFunction}}
{{#Enums}}
<li class="sidebar-section">
<a class="sidebar-item" href="#Enums">Enums</a>
</li>
<ul>
{{#Obj}}
<li class="sidebar-item-container">
<a class="sidebar-item" href="#{{ID}}">{{EnumName}}</a>
</li>
{{/Obj}}
</ul>
{{/Enums}}
{{#Typedef}}
<li class="sidebar-section">Typedef</li>
{{/Typedef}}
{{#Record}}
<li class="sidebar-section">
<a class="sidebar-item" href="#Classes">Inner Classes</a>
</li>
<ul>
{{#Links}}
<li class="sidebar-item-container">
<a class="sidebar-item" href="#{{ID}}">{{Name}}</a>
</li>
{{/Links}}
</ul>
{{/Record}}
</ul>
</div>
<div class="resizer" id="resizer"></div>
<div class="content">
<section class="hero section-container">
<div class="hero__title">
<h1 class="hero__title-large">{{RecordType}} {{Name}}</h1>
{{#RecordComments}}
<div class="hero__subtitle">
{{>Comments}}
</div>
{{/RecordComments}}
</div>
</section>
{{#PublicMembers}}
<section id="PublicMembers" class="section-container">
<h2>Public Members</h2>
<div>
{{#Obj}}
<div id="{{Name}}" class="delimiter-container">
<pre>
<code class="language-cpp code-clang-doc" >{{Type}} {{Name}}</code>
</pre>
{{#MemberComments}}
<div>
{{>Comments}}
</div>
{{/MemberComments}}
</div>
{{/Obj}}
</div>
</section>
{{/PublicMembers}}
{{#ProtectedMembers}}
<section id="ProtectedMembers" class="section-container">
<h2>Protected Members</h2>
<div>
{{#Obj}}
<div id="{{Name}}" class="delimiter-container">
<pre>
<code class="language-cpp code-clang-doc" >{{Type}} {{Name}}</code>
</pre>
{{#MemberComments}}
<div>
{{>Comments}}
</div>
{{/MemberComments}}
</div>
{{/Obj}}
</div>
</section>
{{/ProtectedMembers}}
{{#PublicFunction}}
<section id="PublicMethods" class="section-container">
<h2>Public Methods</h2>
<div>
{{#Obj}}
{{>FunctionPartial}}
{{/Obj}}
</div>
</section>
{{/PublicFunction}}
{{#ProtectedFunction}}
<section id="ProtectedFunction" class="section-container">
<h2>Protected Methods</h2>
<div>
{{#Obj}}
{{>FunctionPartial}}
{{/Obj}}
</div>
</section>
{{/ProtectedFunction}}
{{#Enums}}
<section id="Enums" class="section-container">
<h2>Enumerations</h2>
<div>
{{#Obj}}
{{>EnumPartial}}
{{/Obj}}
</div>
</section>
{{/Enums}}
{{#Record}}
<section id="Classes" class="section-container">
<h2>Inner Classes</h2>
<ul class="class-container">
{{#Links}}
<li id="{{ID}}" style="max-height: 40px;">
<a href="{{Link}}"><pre><code class="language-cpp code-clang-doc" >class {{Name}}</code></pre></a>
</li>
{{/Links}}
</ul>
</section>
{{/Record}}
{{#Typedef}}
<section class="section-container">
<h2 id="Enums">Enums</h2>
</section>
{{/Typedef}}
</div>
</div>
</main>
</body>
</html>
34 changes: 34 additions & 0 deletions clang-tools-extra/clang-doc/assets/comments-template.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{!
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
See https://llvm.org/LICENSE.txt for license information.
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

This file defines templates for generating comments
}}
{{#FullComment}}
{{#Children}}
{{>Comments}}
{{/Children}}
{{/FullComment}}
{{#ParagraphComment}}
{{#Children}}
{{>Comments}}
{{/Children}}
{{/ParagraphComment}}
{{#BlockCommandComment}}
<div class="block-command-comment__command">
<div class="block-command-command">
{{Command}}
</div>
<div>
{{#Children}}
{{>Comments}}
{{/Children}}
</div>
</div>
{{/BlockCommandComment}}
{{#TextComment}}
<div>
<p>{{TextComment}}</p>
</div>
{{/TextComment}}
47 changes: 47 additions & 0 deletions clang-tools-extra/clang-doc/assets/enum-template.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{!
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
See https://llvm.org/LICENSE.txt for license information.
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

This file defines the template for enums
}}
<div id="{{ID}}" class="delimiter-container">
<div>
<pre>
<code class="language-cpp code-clang-doc">
{{EnumName}}
</code>
</pre>
</div>
{{! Enum Values }}
<table class="table-wrapper">
<tbody>
<tr>
<th>Name</th>
<th>Value</th>
{{#HasComment}}
<th>Comment</th>
{{/HasComment}}
</tr>
{{#EnumValues}}
<tr>
<td>{{Name}}</td>
<td>{{Value}}</td>
{{#EnumValueComments}}
<td>{{>Comments}}</td>
{{/EnumValueComments}}
</tr>
{{/EnumValues}}
</tbody>
</table>
{{#EnumComments}}
<div>
{{>Comments}}
</div>
{{/EnumComments}}
{{#Location}}
<div>
Defined at line {{LineNumber}} of file {{Filename}}
</div>
{{/Location}}
</div>
23 changes: 23 additions & 0 deletions clang-tools-extra/clang-doc/assets/function-template.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{!
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
See https://llvm.org/LICENSE.txt for license information.
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

This file defines the template for functions/methods
}}
<div class="delimiter-container">
<div id="{{ID}}">
{{! Function Prototype }}
<pre>
<code class="language-cpp code-clang-doc">
{{ReturnType.Name}} {{Name}} ({{#Params}}{{^End}}{{Type}} {{Name}}, {{/End}}{{#End}}{{Type}} {{Name}}{{/End}}{{/Params}})
</code>
</pre>
{{! Function Comments }}
{{#FunctionComments}}
<div>
{{>Comments}}
</div>
{{/FunctionComments}}
</div>
</div>
30 changes: 30 additions & 0 deletions clang-tools-extra/clang-doc/assets/mustache-index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
document.addEventListener("DOMContentLoaded", function() {
const resizer = document.getElementById('resizer');
const sidebar = document.querySelector('.sidebar');

let isResizing = false;
resizer.addEventListener('mousedown', (e) => { isResizing = true; });

document.addEventListener('mousemove', (e) => {
if (!isResizing)
return;
const newWidth = e.clientX;
if (newWidth > 100 && newWidth < window.innerWidth - 100) {
sidebar.style.width = `${newWidth}px`;
}
});

document.addEventListener('mouseup', () => { isResizing = false; });

document.querySelectorAll('pre code').forEach((el) => {
hljs.highlightElement(el);
el.classList.remove("hljs");
});

document.querySelectorAll('.sidebar-item-container').forEach(item => {
item.addEventListener('click', function() {
const anchor = item.getElementsByTagName("a");
window.location.hash = anchor[0].getAttribute('href');
});
});
})
Loading
Loading