Debian Codegraph @

ivette/src/dome/doc/template/tmpl/container.tmpl

raw
1 <?js
2 var self = this;
3 var isGlobalPage;
4
5 docs.forEach(function(doc, i) {
6 ?>
7
8 <?js
9 // we only need to check this once
10 if (typeof isGlobalPage === 'undefined') {
11 isGlobalPage = (doc.kind === 'globalobj');
12 }
13 ?>
14 <?js if (doc.kind === 'mainpage' || (doc.kind === 'package')) { ?>
15 <?js= self.partial('mainpage.tmpl', doc) ?>
16 <?js } else if (doc.kind === 'source') { ?>
17 <?js= self.partial('source.tmpl', doc) ?>
18 <?js } else { ?>
19
20 <section>
21
22 <header>
23 <?js if (!doc.longname || doc.kind !== 'module') { ?>
24 <h2><?js if (doc.ancestors && doc.ancestors.length) { ?>
25 <span class="ancestors"><?js= doc.ancestors.join('') ?></span><?js
26 }
27 ?><?js= (doc.name && doc.name.startsWith('module:')) ? doc.name.substring(7): doc.name ?><?js
28 if (doc.variation) { ?>
29 <sup class="variation"><?js= doc.variation ?></sup>
30 <?js } ?></h2>
31 <?js if (doc.classdesc) { ?>
32 <div class="class-description"><?js= doc.classdesc ?></div>
33 <?js } ?>
34 <?js } else if (doc.kind === 'module' && doc.modules) { ?>
35 <?js doc.modules.forEach(function(module) { ?>
36 <?js if (module.classdesc) { ?>
37 <div class="class-description"><?js= module.classdesc ?></div>
38 <?js } ?>
39 <?js }) ?>
40 <?js } ?>
41 </header>
42
43 <article>
44 <div class="container-overview">
45 <?js if (doc.kind === 'module' && doc.modules) { ?>
46 <?js if (doc.description) { ?>
47 <div class="description"><?js= doc.description ?></div>
48 <?js } ?>
49
50 <?js doc.modules.forEach(function(module) { ?>
51 <?js= self.partial('method.tmpl', module) ?>
52 <?js }) ?>
53 <?js } else if (doc.kind === 'class') { ?>
54 <?js= self.partial('method.tmpl', doc) ?>
55 <?js } else { ?>
56 <?js if (doc.description) { ?>
57 <div class="description"><?js= doc.description ?></div>
58 <?js } ?>
59
60 <?js= self.partial('details.tmpl', doc) ?>
61
62 <?js if (doc.examples && doc.examples.length) { ?>
63 <h3>Example<?js= doc.examples.length > 1? 's':'' ?></h3>
64 <?js= self.partial('examples.tmpl', doc.examples) ?>
65 <?js } ?>
66 <?js } ?>
67 </div>
68
69 <?js if (doc.augments && doc.augments.length) { ?>
70 <h3 class="subsection-title">Extends</h3>
71
72 <?js= self.partial('augments.tmpl', doc) ?>
73 <?js } ?>
74
75 <?js if (doc.requires && doc.requires.length) { ?>
76 <h3 class="subsection-title">Requires</h3>
77
78 <ul><?js doc.requires.forEach(function(r) { ?>
79 <li><?js= self.linkto(r, r) ?></li>
80 <?js }); ?></ul>
81 <?js } ?>
82
83 <?js
84 var classes = self.find({kind: 'class', memberof: doc.longname});
85 if (!isGlobalPage && classes && classes.length) {
86 ?>
87 <h3 class="subsection-title">Classes</h3>
88 <div class="summary">
89 <table class="summary">
90 <?js classes.forEach(function(c) { ?>
91 <tr>
92 <td><?js= self.linkto(c.longname, c.name) ?></td>
93 <td><?js if (c.summary) { ?><?js= c.summary ?><?js } ?></td>
94 </tr>
95 <?js }); ?>
96 </table>
97 </div>
98 <?js } ?>
99
100 <?js
101 var mixins = self.find({kind: 'mixin', memberof: doc.longname});
102 if (!isGlobalPage && mixins && mixins.length) {
103 ?>
104 <h3 class="subsection-title">Mixins</h3>
105
106 <dl><?js mixins.forEach(function(m) { ?>
107 <dt><?js= self.linkto(m.longname, m.name) ?></dt>
108 <dd><?js if (m.summary) { ?><?js= m.summary ?><?js } ?></dd>
109 <?js }); ?></dl>
110 <?js } ?>
111
112 <?js
113 var namespaces = self.find({kind: 'namespace', memberof: doc.longname});
114 if (!isGlobalPage && namespaces && namespaces.length) {
115 ?>
116 <h3 class="subsection-title">Namespaces</h3>
117
118 <dl><?js namespaces.forEach(function(n) { ?>
119 <dt><?js= self.linkto(n.longname, n.name) ?></dt>
120 <dd><?js if (n.summary) { ?><?js= n.summary ?><?js } ?></dd>
121 <?js }); ?></dl>
122 <?js } ?>
123
124 <?js
125 var members = self.find({kind: 'member', memberof: isGlobalPage ? {isUndefined: true} : doc.longname});
126 var methods = self.find({kind: 'function', memberof: isGlobalPage ? {isUndefined: true} : doc.longname});
127
128 var hasMembers = members && members.length && members.forEach ;
129 var hasMethods = methods && methods.length && methods.forEach ;
130
131 // symbols that are assigned to module.exports are not globals, even though they're not a memberof anything
132 if (isGlobalPage && hasMembers) {
133 members = members.filter(function(m) {
134 return m.longname && m.longname.indexOf('module:') !== 0;
135 });
136 hasMembers = members && members.length && members.forEach ;
137 }
138
139 var makeWarning = ( m , msg ) => {
140 let ident = m.longname + ':' ;
141 if (m.meta) {
142 let { path, filename, lineno } = m.meta ;
143 let root = process.env['DOME_PWD'];
144 let dir = root && path.startsWith(root) ? path.substring(root.length+1) : path ;
145 ident = dir + '/' + filename + ':' + lineno + ': (' + m.name + ')' ;
146 }
147 console.warn( ident, msg);
148 };
149
150 var makeSummary = (m) => {
151 if (m.summary) {
152 let s = m.summary.trim() ;
153 if ( s.startsWith('<p>') && s[3].toUpperCase() !== s[3] )
154 makeWarning( m , "Not capitalized @summary" );
155 if ( s.startsWith('<p>') && ! s.endsWith('.</p>') )
156 makeWarning( m , "Missing @summary final '.'" );
157 return s;
158 }
159 let descr = m.description ;
160 if (descr && typeof(descr)=='string' && descr.startsWith("<p>")) {
161 let pos = descr.indexOf("</p>");
162 if (0 <= pos && pos < 60) return descr.substring(0,pos)+"</p>";
163 }
164 makeWarning( m , "Missing @summary" );
165 return '<span class="dimmed">(details below)</span>' ;
166 };
167
168 if ( hasMembers || hasMethods ) {
169 ?>
170
171 <h3 class="subsection-title">Summary</h3>
172 <div class="summary">
173 <table class="summary">
174 <?js hasMembers && members.forEach(function(m) { ?>
175 <tr class="list-item">
176 <td class="list-title">
177 <a href="#<?js= m.id ?>"><code><?js= m.name ?></code></a>
178 </td>
179 <td class="list-descr">
180 <?js= makeSummary(m) ?>
181 </tr>
182 <?js }); ?>
183
184 <?js if (hasMethods && hasMembers) { ?>
185 <tr class="list-separator">
186 <td class="list-title"/>
187 <td class="list-descr"/>
188 </tr>
189 <?js } ?>
190
191 <?js hasMethods && methods.forEach(function(m) { ?>
192 <tr class="list-item">
193 <td class="list-title">
194 <a href="#<?js= m.id ?>"><code><?js= m.name ?>()</code></a>
195 </td>
196 <td class="list-descr">
197 <?js= makeSummary(m) ?>
198 </td>
199 </tr>
200 <?js }); ?>
201 </table>
202 </div>
203
204 <?js } ?>
205
206 <?js
207 if (hasMembers) {
208 ?>
209 <h3 class="subsection-title">Members</h3>
210
211 <?js members.forEach(function(p) { ?>
212 <?js= self.partial('members.tmpl', p) ?>
213 <?js }); ?>
214 <?js } ?>
215
216 <?js
217
218 if (hasMethods) {
219 ?>
220
221 <h3 class="subsection-title">Methods</h3>
222
223 <?js methods.forEach(function(m) { ?>
224 <?js= self.partial('method.tmpl', m) ?>
225 <?js }); ?>
226 <?js } ?>
227
228 <?js
229 var typedefs = self.find({kind: 'typedef', memberof: isGlobalPage ? {isUndefined: true} : doc.longname});
230 if (typedefs && typedefs.length && typedefs.forEach) {
231 ?>
232 <h3 class="subsection-title">Type Definitions</h3>
233
234 <?js typedefs.forEach(function(e) {
235 if (e.signature) {
236 ?>
237 <?js= self.partial('method.tmpl', e) ?>
238 <?js
239 }
240 else {
241 ?>
242 <?js= self.partial('members.tmpl', e) ?>
243 <?js
244 }
245 }); ?>
246 <?js } ?>
247
248 <?js
249 var events = self.find({kind: 'event', memberof: isGlobalPage ? {isUndefined: true} : doc.longname});
250 if (events && events.length && events.forEach) {
251 ?>
252 <h3 class="subsection-title">Events</h3>
253
254 <?js events.forEach(function(e) { ?>
255 <?js= self.partial('method.tmpl', e) ?>
256 <?js }); ?>
257 <?js } ?>
258 </article>
259
260 </section>
261 <?js } ?>
262
263 <?js }); ?>