container.tmpl 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?js
  2. var self = this;
  3. var isGlobalPage;
  4. var isTSLPage;
  5. docs.forEach(function(doc, i) {
  6. ?>
  7. <?js
  8. // we only need to check this once
  9. if (typeof isGlobalPage === 'undefined') {
  10. isGlobalPage = (doc.kind === 'globalobj');
  11. isTSLPage = (doc.isTSL === true);
  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. <section>
  20. <header>
  21. <?js if (!doc.longname || doc.kind !== 'module') { ?>
  22. <?js if (doc.classdesc) { ?>
  23. <div class="class-description"><?js= doc.classdesc ?></div>
  24. <?js } ?>
  25. <?js } else if (doc.kind === 'module' && doc.modules) { ?>
  26. <?js doc.modules.forEach(function(module) { ?>
  27. <?js if (module.classdesc) { ?>
  28. <div class="class-description"><?js= module.classdesc ?></div>
  29. <?js } ?>
  30. <?js }) ?>
  31. <?js } ?>
  32. <?js if (doc.demo) { ?>
  33. <iframe id="viewer" src="../<?js= doc.demo ?>"></iframe>
  34. <?js } ?>
  35. <?js if (doc.codeExample) { ?>
  36. <h2>Code Example</h2>
  37. <div translate="no"><?js= doc.codeExample ?></div>
  38. <?js } ?>
  39. </header>
  40. <article>
  41. <?js if (doc.import) { ?>
  42. <h2 class="subsection-title">Import</h2>
  43. <p><span translate="no"><?js= doc.name ?></span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation">Installation#Addons</a>.</p>
  44. <pre class="prettyprint source lang-js" translate="no"><code><?js= doc.import ?></code></pre>
  45. <?js } ?>
  46. <div class="container-overview">
  47. <?js if (doc.kind === 'module' && doc.modules) { ?>
  48. <?js if (doc.description) { ?>
  49. <div class="description"><?js= doc.description ?></div>
  50. <?js } ?>
  51. <?js doc.modules.forEach(function(module) { ?>
  52. <?js= self.partial('method.tmpl', module) ?>
  53. <?js }) ?>
  54. <?js } else if (doc.kind === 'class' || (doc.kind === 'namespace' && doc.signature)) { ?>
  55. <?js= self.partial('method.tmpl', doc) ?>
  56. <?js } else { ?>
  57. <?js if (doc.description) { ?>
  58. <div class="description"><?js= doc.description ?></div>
  59. <?js } ?>
  60. <?js= self.partial('details.tmpl', doc) ?>
  61. <?js if (doc.examples && doc.examples.length) { ?>
  62. <h3>Example<?js= doc.examples.length > 1? 's':'' ?></h3>
  63. <?js= self.partial('examples.tmpl', doc.examples) ?>
  64. <?js } ?>
  65. <?js } ?>
  66. </div>
  67. <?js
  68. var ignoreInheritedSymbols = { ...(self.ignoreInheritedSymbols ? { inherited: {isUndefined: true} } : {}) };
  69. var classes = self.find({kind: 'class', memberof: doc.longname});
  70. if (!isGlobalPage && classes && classes.length) {
  71. ?>
  72. <h2 class="subsection-title">Classes</h2>
  73. <dl>
  74. <?js classes.forEach(function(c) { ?>
  75. <dt><?js= self.linkto(c.longname, c.name) ?></dt>
  76. <dd><?js if (c.summary) { ?><?js= c.summary ?><?js } ?></dd>
  77. <?js }); ?>
  78. </dl>
  79. <?js } ?>
  80. <?js
  81. var members = self.find({kind: 'member', memberof: isGlobalPage ? {isUndefined: true} : doc.longname, ...ignoreInheritedSymbols});
  82. // symbols that are assigned to module.exports are not globals, even though they're not a memberof anything
  83. if (isGlobalPage && members && members.length && members.forEach) {
  84. members = members.filter(function(m) {
  85. if (m.longname && m.longname.indexOf('module:') === 0) return false;
  86. // Filter based on whether this is TSL or Global page
  87. var hasTslTag = m.tags && m.tags.some(function(tag) { return tag.title === 'tsl'; });
  88. return isTSLPage ? hasTslTag : !hasTslTag;
  89. });
  90. }
  91. if (members && members.length && members.forEach) {
  92. ?>
  93. <h2 class="subsection-title">Properties</h2>
  94. <?js members.forEach(function(p) { ?>
  95. <?js= self.partial('members.tmpl', p) ?>
  96. <?js }); ?>
  97. <?js } ?>
  98. <?js
  99. var methods = self.find({kind: 'function', memberof: isGlobalPage ? {isUndefined: true} : doc.longname, ...ignoreInheritedSymbols});
  100. // Filter methods for TSL vs Global
  101. if (isGlobalPage && methods && methods.length) {
  102. methods = methods.filter(function(m) {
  103. var hasTslTag = m.tags && m.tags.some(function(tag) { return tag.title === 'tsl'; });
  104. return isTSLPage ? hasTslTag : !hasTslTag;
  105. });
  106. }
  107. var staticMethods = methods.filter(function(m) { return m.scope === 'static'; });
  108. var instanceMethods = methods.filter(function(m) { return m.scope !== 'static'; });
  109. if (instanceMethods.length) {
  110. ?>
  111. <h2 class="subsection-title">Methods</h2>
  112. <?js instanceMethods.forEach(function(m) { ?>
  113. <?js= self.partial('method.tmpl', m) ?>
  114. <?js }); ?>
  115. <?js } ?>
  116. <?js if (staticMethods.length) { ?>
  117. <h2 class="subsection-title">Static Methods</h2>
  118. <?js staticMethods.forEach(function(m) { ?>
  119. <?js= self.partial('method.tmpl', m) ?>
  120. <?js }); ?>
  121. <?js } ?>
  122. <?js
  123. var typedefs = self.find({kind: 'typedef', memberof: isGlobalPage ? {isUndefined: true} : doc.longname, ...ignoreInheritedSymbols});
  124. if (typedefs && typedefs.length && typedefs.forEach) {
  125. ?>
  126. <h2 class="subsection-title">Type Definitions</h2>
  127. <?js typedefs.forEach(function(e) {
  128. if (e.signature) {
  129. ?>
  130. <?js= self.partial('method.tmpl', e) ?>
  131. <?js
  132. }
  133. else {
  134. ?>
  135. <?js= self.partial('members.tmpl', e) ?>
  136. <?js
  137. }
  138. }); ?>
  139. <?js } ?>
  140. <?js
  141. var events = self.find({kind: 'event', memberof: isGlobalPage ? {isUndefined: true} : doc.longname, ...ignoreInheritedSymbols});
  142. if (events && events.length && events.forEach) {
  143. ?>
  144. <h2 class="subsection-title">Events</h2>
  145. <?js events.forEach(function(e) { ?>
  146. <?js= self.partial('method.tmpl', e) ?>
  147. <?js }); ?>
  148. <?js } ?>
  149. <?js if (doc.meta && doc.meta.shortpath) { ?>
  150. <h2 class="subsection-title">Source</h2>
  151. <p>
  152. <a href="https://github.com/mrdoob/three.js/blob/master/<?js= doc.meta.shortpath ?>" translate="no"><?js= doc.meta.shortpath ?></a>
  153. </p>
  154. <?js } ?>
  155. </article>
  156. </section>
  157. <?js } ?>
  158. <?js }); ?>
粤ICP备19079148号