Skip to content

Commit 162890b

Browse files
ilovepiPeterChou1
andcommitted
[clang-doc] Add Mustache template assets
This patch adds the various assets used with the HTML Mustache backend. This includes templates for a variety of different language constructs, as well as the CSS. Split from #133161. Co-authored-by: Peter Chou <[email protected]>
1 parent de5258a commit 162890b

9 files changed

+939
-0
lines changed

clang-tools-extra/clang-doc/assets/clang-doc-mustache.css

Lines changed: 471 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
{{!
2+
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3+
See https://llvm.org/LICENSE.txt for license information.
4+
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
This file defines the template for classes/struct
7+
}}
8+
<!DOCTYPE html>
9+
<html lang="en-US">
10+
<head>
11+
<meta charset="utf-8"/>
12+
<title>{{Name}}</title>
13+
{{#Stylesheets}}
14+
<link rel="stylesheet" type="text/css" href="{{.}}"/>
15+
{{/Stylesheets}}
16+
{{#Scripts}}
17+
<script src="{{.}}"></script>
18+
{{/Scripts}}
19+
{{! Highlight.js dependency for syntax highlighting }}
20+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
21+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
22+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/cpp.min.js"></script>
23+
</head>
24+
<body>
25+
<nav class="navbar">
26+
<div class="navbar__container">
27+
{{#ProjectName}}
28+
<div class="navbar__logo">
29+
{{ProjectName}}
30+
</div>
31+
{{/ProjectName}}
32+
<div class="navbar__menu">
33+
<ul class="navbar__links">
34+
<li class="navbar__item">
35+
<a href="/" class="navbar__link">Namespace</a>
36+
</li>
37+
<li class="navbar__item">
38+
<a href="/" class="navbar__link">Class</a>
39+
</li>
40+
</ul>
41+
</div>
42+
</div>
43+
</nav>
44+
<main>
45+
<div class="container">
46+
<div class="sidebar">
47+
<h2>{{RecordType}} {{Name}}</h2>
48+
<ul>
49+
{{#PublicMembers}}
50+
<li class="sidebar-section">
51+
<a class="sidebar-item" href="#PublicMethods">Public Members</a>
52+
</li>
53+
<ul>
54+
{{#Obj}}
55+
<li class="sidebar-item-container">
56+
<a class="sidebar-item" href="#{{Name}}">{{Name}}</a>
57+
</li>
58+
{{/Obj}}
59+
</ul>
60+
{{/PublicMembers}}
61+
{{#ProtectedMembers}}
62+
<li class="sidebar-section">
63+
<a class="sidebar-item" href="#PublicMethods">Protected Members</a>
64+
</li>
65+
<ul>
66+
{{#Obj}}
67+
<li class="sidebar-item-container">
68+
<a class="sidebar-item" href="#{{Name}}">{{Name}}</a>
69+
</li>
70+
{{/Obj}}
71+
</ul>
72+
{{/ProtectedMembers}}
73+
{{#PublicFunction}}
74+
<li class="sidebar-section">
75+
<a class="sidebar-item" href="#PublicMethods">Public Method</a>
76+
</li>
77+
<ul>
78+
{{#Obj}}
79+
<li class="sidebar-item-container">
80+
<a class="sidebar-item" href="#{{ID}}">{{Name}}</a>
81+
</li>
82+
{{/Obj}}
83+
</ul>
84+
{{/PublicFunction}}
85+
{{#ProtectedFunction}}
86+
<li class="sidebar-section">
87+
<a class="sidebar-item" href="#ProtectedFunction">Protected Method</a>
88+
</li>
89+
<ul>
90+
{{#Obj}}
91+
<li class="sidebar-item-container">
92+
<a class="sidebar-item" href="#{{ID}}">{{Name}}</a>
93+
</li>
94+
{{/Obj}}
95+
</ul>
96+
{{/ProtectedFunction}}
97+
{{#Enums}}
98+
<li class="sidebar-section">
99+
<a class="sidebar-item" href="#Enums">Enums</a>
100+
</li>
101+
<ul>
102+
{{#Obj}}
103+
<li class="sidebar-item-container">
104+
<a class="sidebar-item" href="#{{ID}}">{{EnumName}}</a>
105+
</li>
106+
{{/Obj}}
107+
</ul>
108+
{{/Enums}}
109+
{{#Typedef}}
110+
<li class="sidebar-section">Typedef</li>
111+
{{/Typedef}}
112+
{{#Record}}
113+
<li class="sidebar-section">
114+
<a class="sidebar-item" href="#Classes">Inner Classes</a>
115+
</li>
116+
<ul>
117+
{{#Links}}
118+
<li class="sidebar-item-container">
119+
<a class="sidebar-item" href="#{{ID}}">{{Name}}</a>
120+
</li>
121+
{{/Links}}
122+
</ul>
123+
{{/Record}}
124+
</ul>
125+
</div>
126+
<div class="resizer" id="resizer"></div>
127+
<div class="content">
128+
<section class="hero section-container">
129+
<div class="hero__title">
130+
<h1 class="hero__title-large">{{RecordType}} {{Name}}</h1>
131+
{{#RecordComments}}
132+
<div class="hero__subtitle">
133+
{{>Comments}}
134+
</div>
135+
{{/RecordComments}}
136+
</div>
137+
</section>
138+
{{#PublicMembers}}
139+
<section id="PublicMembers" class="section-container">
140+
<h2>Public Members</h2>
141+
<div>
142+
{{#Obj}}
143+
<div id="{{Name}}" class="delimiter-container">
144+
<pre>
145+
<code class="language-cpp code-clang-doc" >{{Type}} {{Name}}</code>
146+
</pre>
147+
{{#MemberComments}}
148+
<div>
149+
{{>Comments}}
150+
</div>
151+
{{/MemberComments}}
152+
</div>
153+
{{/Obj}}
154+
</div>
155+
</section>
156+
{{/PublicMembers}}
157+
{{#ProtectedMembers}}
158+
<section id="ProtectedMembers" class="section-container">
159+
<h2>Protected Members</h2>
160+
<div>
161+
{{#Obj}}
162+
<div id="{{Name}}" class="delimiter-container">
163+
<pre>
164+
<code class="language-cpp code-clang-doc" >{{Type}} {{Name}}</code>
165+
</pre>
166+
{{#MemberComments}}
167+
<div>
168+
{{>Comments}}
169+
</div>
170+
{{/MemberComments}}
171+
</div>
172+
{{/Obj}}
173+
</div>
174+
</section>
175+
{{/ProtectedMembers}}
176+
{{#PublicFunction}}
177+
<section id="PublicMethods" class="section-container">
178+
<h2>Public Methods</h2>
179+
<div>
180+
{{#Obj}}
181+
{{>FunctionPartial}}
182+
{{/Obj}}
183+
</div>
184+
</section>
185+
{{/PublicFunction}}
186+
{{#ProtectedFunction}}
187+
<section id="ProtectedFunction" class="section-container">
188+
<h2>Protected Methods</h2>
189+
<div>
190+
{{#Obj}}
191+
{{>FunctionPartial}}
192+
{{/Obj}}
193+
</div>
194+
</section>
195+
{{/ProtectedFunction}}
196+
{{#Enums}}
197+
<section id="Enums" class="section-container">
198+
<h2>Enumerations</h2>
199+
<div>
200+
{{#Obj}}
201+
{{>EnumPartial}}
202+
{{/Obj}}
203+
</div>
204+
</section>
205+
{{/Enums}}
206+
{{#Record}}
207+
<section id="Classes" class="section-container">
208+
<h2>Inner Classes</h2>
209+
<ul class="class-container">
210+
{{#Links}}
211+
<li id="{{ID}}" style="max-height: 40px;">
212+
<a href="{{Link}}"><pre><code class="language-cpp code-clang-doc" >class {{Name}}</code></pre></a>
213+
</li>
214+
{{/Links}}
215+
</ul>
216+
</section>
217+
{{/Record}}
218+
{{#Typedef}}
219+
<section class="section-container">
220+
<h2 id="Enums">Enums</h2>
221+
</section>
222+
{{/Typedef}}
223+
</div>
224+
</div>
225+
</main>
226+
</body>
227+
</html>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{{!
2+
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3+
See https://llvm.org/LICENSE.txt for license information.
4+
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
This file defines templates for generating comments
7+
}}
8+
{{#FullComment}}
9+
{{#Children}}
10+
{{>Comments}}
11+
{{/Children}}
12+
{{/FullComment}}
13+
{{#ParagraphComment}}
14+
{{#Children}}
15+
{{>Comments}}
16+
{{/Children}}
17+
{{/ParagraphComment}}
18+
{{#BlockCommandComment}}
19+
<div class="block-command-comment__command">
20+
<div class="block-command-command">
21+
{{Command}}
22+
</div>
23+
<div>
24+
{{#Children}}
25+
{{>Comments}}
26+
{{/Children}}
27+
</div>
28+
</div>
29+
{{/BlockCommandComment}}
30+
{{#TextComment}}
31+
<div>
32+
<p>{{TextComment}}</p>
33+
</div>
34+
{{/TextComment}}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{{!
2+
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3+
See https://llvm.org/LICENSE.txt for license information.
4+
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
This file defines the template for enums
7+
}}
8+
<div id="{{ID}}" class="delimiter-container">
9+
<div>
10+
<pre>
11+
<code class="language-cpp code-clang-doc">
12+
{{EnumName}}
13+
</code>
14+
</pre>
15+
</div>
16+
{{! Enum Values }}
17+
<table class="table-wrapper">
18+
<tbody>
19+
<tr>
20+
<th>Name</th>
21+
<th>Value</th>
22+
{{#HasComment}}
23+
<th>Comment</th>
24+
{{/HasComment}}
25+
</tr>
26+
{{#EnumValues}}
27+
<tr>
28+
<td>{{Name}}</td>
29+
<td>{{Value}}</td>
30+
{{#EnumValueComments}}
31+
<td>{{>Comments}}</td>
32+
{{/EnumValueComments}}
33+
</tr>
34+
{{/EnumValues}}
35+
</tbody>
36+
</table>
37+
{{#EnumComments}}
38+
<div>
39+
{{>Comments}}
40+
</div>
41+
{{/EnumComments}}
42+
{{#Location}}
43+
<div>
44+
Defined at line {{LineNumber}} of file {{Filename}}
45+
</div>
46+
{{/Location}}
47+
</div>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{!
2+
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3+
See https://llvm.org/LICENSE.txt for license information.
4+
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
This file defines the template for functions/methods
7+
}}
8+
<div class="delimiter-container">
9+
<div id="{{ID}}">
10+
{{! Function Prototype }}
11+
<pre>
12+
<code class="language-cpp code-clang-doc">
13+
{{ReturnType.Name}} {{Name}} ({{#Params}}{{^End}}{{Type}} {{Name}}, {{/End}}{{#End}}{{Type}} {{Name}}{{/End}}{{/Params}})
14+
</code>
15+
</pre>
16+
{{! Function Comments }}
17+
{{#FunctionComments}}
18+
<div>
19+
{{>Comments}}
20+
</div>
21+
{{/FunctionComments}}
22+
</div>
23+
</div>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
document.addEventListener("DOMContentLoaded", function() {
2+
const resizer = document.getElementById('resizer');
3+
const sidebar = document.querySelector('.sidebar');
4+
5+
let isResizing = false;
6+
resizer.addEventListener('mousedown', (e) => { isResizing = true; });
7+
8+
document.addEventListener('mousemove', (e) => {
9+
if (!isResizing)
10+
return;
11+
const newWidth = e.clientX;
12+
if (newWidth > 100 && newWidth < window.innerWidth - 100) {
13+
sidebar.style.width = `${newWidth}px`;
14+
}
15+
});
16+
17+
document.addEventListener('mouseup', () => { isResizing = false; });
18+
19+
document.querySelectorAll('pre code').forEach((el) => {
20+
hljs.highlightElement(el);
21+
el.classList.remove("hljs");
22+
});
23+
24+
document.querySelectorAll('.sidebar-item-container').forEach(item => {
25+
item.addEventListener('click', function() {
26+
const anchor = item.getElementsByTagName("a");
27+
window.location.hash = anchor[0].getAttribute('href');
28+
});
29+
});
30+
})

0 commit comments

Comments
 (0)