jsduck 0.6.1 → 2.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (453) hide show
  1. data/.gitignore +4 -0
  2. data/README.md +35 -13
  3. data/Rakefile +129 -0
  4. data/bin/jsduck +112 -20
  5. data/jsduck.gemspec +10 -7
  6. data/lib/jsduck/aggregator.rb +46 -20
  7. data/lib/jsduck/aliases.rb +39 -0
  8. data/lib/jsduck/app.rb +123 -51
  9. data/lib/jsduck/categories.rb +132 -0
  10. data/lib/jsduck/class.rb +71 -18
  11. data/lib/jsduck/doc_formatter.rb +61 -26
  12. data/lib/jsduck/doc_parser.rb +53 -2
  13. data/lib/jsduck/exporter.rb +14 -15
  14. data/lib/jsduck/guides.rb +110 -0
  15. data/lib/jsduck/js_parser.rb +18 -4
  16. data/lib/jsduck/jsonp.rb +17 -0
  17. data/lib/jsduck/logger.rb +36 -0
  18. data/lib/jsduck/merger.rb +69 -51
  19. data/lib/jsduck/page.rb +1 -1
  20. data/lib/jsduck/relations.rb +14 -3
  21. data/lib/jsduck/{members.rb → search_data.rb} +3 -28
  22. data/lib/jsduck/source_file.rb +4 -4
  23. data/lib/jsduck/source_writer.rb +2 -2
  24. data/lib/jsduck/timer.rb +6 -2
  25. data/lib/jsduck/tree.rb +29 -16
  26. data/lib/jsduck/tree_icons.rb +1 -1
  27. data/template/README.md +14 -0
  28. data/template/app.js +25 -0
  29. data/template/app/Application.js +53 -0
  30. data/template/app/Favorites.js +88 -0
  31. data/template/app/History.js +45 -0
  32. data/template/app/LocalStore.js +45 -0
  33. data/template/app/Settings.js +39 -0
  34. data/template/app/Syntax.js +20 -0
  35. data/template/app/controller/Classes.js +301 -0
  36. data/template/app/controller/Search.js +156 -0
  37. data/template/app/model/Favorite.js +11 -0
  38. data/template/app/model/Setting.js +11 -0
  39. data/template/app/store/Favorites.js +7 -0
  40. data/template/app/store/Search.js +14 -0
  41. data/template/app/store/Settings.js +7 -0
  42. data/template/app/view/ClassGrid.js +109 -0
  43. data/template/app/view/HoverMenu.js +59 -0
  44. data/template/app/view/HoverMenuButton.js +147 -0
  45. data/template/app/view/Viewport.js +240 -0
  46. data/template/app/view/cls/Header.js +47 -0
  47. data/template/app/view/cls/Overview.js +415 -0
  48. data/template/app/view/cls/Toolbar.js +199 -0
  49. data/template/app/view/index/Container.js +63 -0
  50. data/template/app/view/search/Dropdown.js +53 -0
  51. data/template/app/view/tree/Tree.js +133 -0
  52. data/template/favicon.ico +0 -0
  53. data/template/index.html +32 -37
  54. data/template/{resources/prettify → prettify}/prettify.css +0 -0
  55. data/template/{resources/prettify → prettify}/prettify.js +0 -0
  56. data/template/resources/images/class-m.png +0 -0
  57. data/template/resources/images/class-sm.png +0 -0
  58. data/template/resources/images/component-m.png +0 -0
  59. data/template/resources/images/configs.png +0 -0
  60. data/template/resources/images/data-package.png +0 -0
  61. data/template/resources/images/doc-m.png +0 -0
  62. data/template/resources/images/drag-bar-center.png +0 -0
  63. data/template/resources/{elbow-end.gif → images/elbow-end.gif} +0 -0
  64. data/template/resources/images/events.png +0 -0
  65. data/template/resources/images/expandcollapse.png +0 -0
  66. data/template/resources/images/guide-icon.png +0 -0
  67. data/template/resources/images/guides.png +0 -0
  68. data/template/resources/images/headBG.png +0 -0
  69. data/template/resources/images/header.gif +0 -0
  70. data/template/resources/images/icon.png +0 -0
  71. data/template/resources/images/icons.png +0 -0
  72. data/template/resources/images/loading-title.png +0 -0
  73. data/template/resources/images/loading.gif +0 -0
  74. data/template/resources/{member-collapsed.gif → images/member-collapsed.gif} +0 -0
  75. data/template/resources/{member-expanded.gif → images/member-expanded.gif} +0 -0
  76. data/template/resources/{member-hover.gif → images/member-hover.gif} +0 -0
  77. data/template/resources/images/methods.png +0 -0
  78. data/template/resources/images/model.png +0 -0
  79. data/template/resources/images/properties.png +0 -0
  80. data/template/resources/images/root-lines.png +0 -0
  81. data/template/resources/images/search-box.png +0 -0
  82. data/template/resources/images/singleton-m.png +0 -0
  83. data/template/resources/images/version-tabs.png +0 -0
  84. data/template/resources/images/x.png +0 -0
  85. data/template/resources/images/x12.png +0 -0
  86. metadata +84 -387
  87. data/lib/jsduck/cfg_table.rb +0 -21
  88. data/lib/jsduck/event_table.rb +0 -33
  89. data/lib/jsduck/inheritance_tree.rb +0 -42
  90. data/lib/jsduck/long_params.rb +0 -30
  91. data/lib/jsduck/method_table.rb +0 -45
  92. data/lib/jsduck/property_table.rb +0 -21
  93. data/lib/jsduck/short_params.rb +0 -24
  94. data/lib/jsduck/table.rb +0 -121
  95. data/template/resources/TabCloseMenu.js +0 -150
  96. data/template/resources/block-bottom.gif +0 -0
  97. data/template/resources/block-top.gif +0 -0
  98. data/template/resources/class.gif +0 -0
  99. data/template/resources/cmp.gif +0 -0
  100. data/template/resources/collapse-all.gif +0 -0
  101. data/template/resources/config.gif +0 -0
  102. data/template/resources/css/ext-all.css +0 -6993
  103. data/template/resources/css/xtheme-gray.css +0 -1654
  104. data/template/resources/docs.css +0 -361
  105. data/template/resources/docs.gif +0 -0
  106. data/template/resources/docs.js +0 -769
  107. data/template/resources/event.gif +0 -0
  108. data/template/resources/expand-all.gif +0 -0
  109. data/template/resources/expand-bg-over.gif +0 -0
  110. data/template/resources/expand-bg.gif +0 -0
  111. data/template/resources/expand-members.gif +0 -0
  112. data/template/resources/ext-all.js +0 -11
  113. data/template/resources/ext-base.js +0 -7
  114. data/template/resources/extanim32.gif +0 -0
  115. data/template/resources/fav.gif +0 -0
  116. data/template/resources/favicon.ico +0 -0
  117. data/template/resources/hd-bg.png +0 -0
  118. data/template/resources/hide-inherited.gif +0 -0
  119. data/template/resources/images/default/box/corners-blue.gif +0 -0
  120. data/template/resources/images/default/box/corners.gif +0 -0
  121. data/template/resources/images/default/box/l-blue.gif +0 -0
  122. data/template/resources/images/default/box/l.gif +0 -0
  123. data/template/resources/images/default/box/r-blue.gif +0 -0
  124. data/template/resources/images/default/box/r.gif +0 -0
  125. data/template/resources/images/default/box/tb-blue.gif +0 -0
  126. data/template/resources/images/default/box/tb.gif +0 -0
  127. data/template/resources/images/default/button/arrow.gif +0 -0
  128. data/template/resources/images/default/button/btn.gif +0 -0
  129. data/template/resources/images/default/button/group-cs.gif +0 -0
  130. data/template/resources/images/default/button/group-lr.gif +0 -0
  131. data/template/resources/images/default/button/group-tb.gif +0 -0
  132. data/template/resources/images/default/button/s-arrow-b-noline.gif +0 -0
  133. data/template/resources/images/default/button/s-arrow-b.gif +0 -0
  134. data/template/resources/images/default/button/s-arrow-bo.gif +0 -0
  135. data/template/resources/images/default/button/s-arrow-noline.gif +0 -0
  136. data/template/resources/images/default/button/s-arrow-o.gif +0 -0
  137. data/template/resources/images/default/button/s-arrow.gif +0 -0
  138. data/template/resources/images/default/dd/drop-add.gif +0 -0
  139. data/template/resources/images/default/dd/drop-no.gif +0 -0
  140. data/template/resources/images/default/dd/drop-yes.gif +0 -0
  141. data/template/resources/images/default/editor/tb-sprite.gif +0 -0
  142. data/template/resources/images/default/form/checkbox.gif +0 -0
  143. data/template/resources/images/default/form/clear-trigger.gif +0 -0
  144. data/template/resources/images/default/form/clear-trigger.psd +0 -0
  145. data/template/resources/images/default/form/date-trigger.gif +0 -0
  146. data/template/resources/images/default/form/date-trigger.psd +0 -0
  147. data/template/resources/images/default/form/error-tip-corners.gif +0 -0
  148. data/template/resources/images/default/form/exclamation.gif +0 -0
  149. data/template/resources/images/default/form/radio.gif +0 -0
  150. data/template/resources/images/default/form/search-trigger.gif +0 -0
  151. data/template/resources/images/default/form/search-trigger.psd +0 -0
  152. data/template/resources/images/default/form/text-bg.gif +0 -0
  153. data/template/resources/images/default/form/trigger-square.gif +0 -0
  154. data/template/resources/images/default/form/trigger-square.psd +0 -0
  155. data/template/resources/images/default/form/trigger-tpl.gif +0 -0
  156. data/template/resources/images/default/form/trigger.gif +0 -0
  157. data/template/resources/images/default/form/trigger.psd +0 -0
  158. data/template/resources/images/default/gradient-bg.gif +0 -0
  159. data/template/resources/images/default/grid/arrow-left-white.gif +0 -0
  160. data/template/resources/images/default/grid/arrow-right-white.gif +0 -0
  161. data/template/resources/images/default/grid/col-move-bottom.gif +0 -0
  162. data/template/resources/images/default/grid/col-move-top.gif +0 -0
  163. data/template/resources/images/default/grid/columns.gif +0 -0
  164. data/template/resources/images/default/grid/dirty.gif +0 -0
  165. data/template/resources/images/default/grid/done.gif +0 -0
  166. data/template/resources/images/default/grid/drop-no.gif +0 -0
  167. data/template/resources/images/default/grid/drop-yes.gif +0 -0
  168. data/template/resources/images/default/grid/footer-bg.gif +0 -0
  169. data/template/resources/images/default/grid/grid-blue-hd.gif +0 -0
  170. data/template/resources/images/default/grid/grid-blue-split.gif +0 -0
  171. data/template/resources/images/default/grid/grid-hrow.gif +0 -0
  172. data/template/resources/images/default/grid/grid-loading.gif +0 -0
  173. data/template/resources/images/default/grid/grid-split.gif +0 -0
  174. data/template/resources/images/default/grid/grid-vista-hd.gif +0 -0
  175. data/template/resources/images/default/grid/grid3-hd-btn.gif +0 -0
  176. data/template/resources/images/default/grid/grid3-hrow-over.gif +0 -0
  177. data/template/resources/images/default/grid/grid3-hrow.gif +0 -0
  178. data/template/resources/images/default/grid/grid3-special-col-bg.gif +0 -0
  179. data/template/resources/images/default/grid/grid3-special-col-sel-bg.gif +0 -0
  180. data/template/resources/images/default/grid/group-by.gif +0 -0
  181. data/template/resources/images/default/grid/group-collapse.gif +0 -0
  182. data/template/resources/images/default/grid/group-expand-sprite.gif +0 -0
  183. data/template/resources/images/default/grid/group-expand.gif +0 -0
  184. data/template/resources/images/default/grid/hd-pop.gif +0 -0
  185. data/template/resources/images/default/grid/hmenu-asc.gif +0 -0
  186. data/template/resources/images/default/grid/hmenu-desc.gif +0 -0
  187. data/template/resources/images/default/grid/hmenu-lock.gif +0 -0
  188. data/template/resources/images/default/grid/hmenu-lock.png +0 -0
  189. data/template/resources/images/default/grid/hmenu-unlock.gif +0 -0
  190. data/template/resources/images/default/grid/hmenu-unlock.png +0 -0
  191. data/template/resources/images/default/grid/invalid_line.gif +0 -0
  192. data/template/resources/images/default/grid/loading.gif +0 -0
  193. data/template/resources/images/default/grid/mso-hd.gif +0 -0
  194. data/template/resources/images/default/grid/nowait.gif +0 -0
  195. data/template/resources/images/default/grid/page-first-disabled.gif +0 -0
  196. data/template/resources/images/default/grid/page-first.gif +0 -0
  197. data/template/resources/images/default/grid/page-last-disabled.gif +0 -0
  198. data/template/resources/images/default/grid/page-last.gif +0 -0
  199. data/template/resources/images/default/grid/page-next-disabled.gif +0 -0
  200. data/template/resources/images/default/grid/page-next.gif +0 -0
  201. data/template/resources/images/default/grid/page-prev-disabled.gif +0 -0
  202. data/template/resources/images/default/grid/page-prev.gif +0 -0
  203. data/template/resources/images/default/grid/pick-button.gif +0 -0
  204. data/template/resources/images/default/grid/refresh.gif +0 -0
  205. data/template/resources/images/default/grid/row-check-sprite.gif +0 -0
  206. data/template/resources/images/default/grid/row-expand-sprite.gif +0 -0
  207. data/template/resources/images/default/grid/row-over.gif +0 -0
  208. data/template/resources/images/default/grid/row-sel.gif +0 -0
  209. data/template/resources/images/default/grid/sort-hd.gif +0 -0
  210. data/template/resources/images/default/grid/sort_asc.gif +0 -0
  211. data/template/resources/images/default/grid/sort_desc.gif +0 -0
  212. data/template/resources/images/default/grid/wait.gif +0 -0
  213. data/template/resources/images/default/layout/collapse.gif +0 -0
  214. data/template/resources/images/default/layout/expand.gif +0 -0
  215. data/template/resources/images/default/layout/gradient-bg.gif +0 -0
  216. data/template/resources/images/default/layout/mini-bottom.gif +0 -0
  217. data/template/resources/images/default/layout/mini-left.gif +0 -0
  218. data/template/resources/images/default/layout/mini-right.gif +0 -0
  219. data/template/resources/images/default/layout/mini-top.gif +0 -0
  220. data/template/resources/images/default/layout/ns-collapse.gif +0 -0
  221. data/template/resources/images/default/layout/ns-expand.gif +0 -0
  222. data/template/resources/images/default/layout/panel-close.gif +0 -0
  223. data/template/resources/images/default/layout/panel-title-bg.gif +0 -0
  224. data/template/resources/images/default/layout/panel-title-light-bg.gif +0 -0
  225. data/template/resources/images/default/layout/stick.gif +0 -0
  226. data/template/resources/images/default/layout/stuck.gif +0 -0
  227. data/template/resources/images/default/layout/tab-close-on.gif +0 -0
  228. data/template/resources/images/default/layout/tab-close.gif +0 -0
  229. data/template/resources/images/default/menu/checked.gif +0 -0
  230. data/template/resources/images/default/menu/group-checked.gif +0 -0
  231. data/template/resources/images/default/menu/item-over.gif +0 -0
  232. data/template/resources/images/default/menu/menu-parent.gif +0 -0
  233. data/template/resources/images/default/menu/menu.gif +0 -0
  234. data/template/resources/images/default/menu/unchecked.gif +0 -0
  235. data/template/resources/images/default/panel/corners-sprite.gif +0 -0
  236. data/template/resources/images/default/panel/left-right.gif +0 -0
  237. data/template/resources/images/default/panel/light-hd.gif +0 -0
  238. data/template/resources/images/default/panel/tool-sprite-tpl.gif +0 -0
  239. data/template/resources/images/default/panel/tool-sprites.gif +0 -0
  240. data/template/resources/images/default/panel/tools-sprites-trans.gif +0 -0
  241. data/template/resources/images/default/panel/top-bottom.gif +0 -0
  242. data/template/resources/images/default/panel/top-bottom.png +0 -0
  243. data/template/resources/images/default/panel/white-corners-sprite.gif +0 -0
  244. data/template/resources/images/default/panel/white-left-right.gif +0 -0
  245. data/template/resources/images/default/panel/white-top-bottom.gif +0 -0
  246. data/template/resources/images/default/progress/progress-bg.gif +0 -0
  247. data/template/resources/images/default/qtip/bg.gif +0 -0
  248. data/template/resources/images/default/qtip/close.gif +0 -0
  249. data/template/resources/images/default/qtip/tip-anchor-sprite.gif +0 -0
  250. data/template/resources/images/default/qtip/tip-sprite.gif +0 -0
  251. data/template/resources/images/default/s.gif +0 -0
  252. data/template/resources/images/default/shadow-c.png +0 -0
  253. data/template/resources/images/default/shadow-lr.png +0 -0
  254. data/template/resources/images/default/shadow.png +0 -0
  255. data/template/resources/images/default/shared/blue-loading.gif +0 -0
  256. data/template/resources/images/default/shared/calendar.gif +0 -0
  257. data/template/resources/images/default/shared/glass-bg.gif +0 -0
  258. data/template/resources/images/default/shared/hd-sprite.gif +0 -0
  259. data/template/resources/images/default/shared/large-loading.gif +0 -0
  260. data/template/resources/images/default/shared/left-btn.gif +0 -0
  261. data/template/resources/images/default/shared/loading-balls.gif +0 -0
  262. data/template/resources/images/default/shared/right-btn.gif +0 -0
  263. data/template/resources/images/default/shared/warning.gif +0 -0
  264. data/template/resources/images/default/sizer/e-handle-dark.gif +0 -0
  265. data/template/resources/images/default/sizer/e-handle.gif +0 -0
  266. data/template/resources/images/default/sizer/ne-handle-dark.gif +0 -0
  267. data/template/resources/images/default/sizer/ne-handle.gif +0 -0
  268. data/template/resources/images/default/sizer/nw-handle-dark.gif +0 -0
  269. data/template/resources/images/default/sizer/nw-handle.gif +0 -0
  270. data/template/resources/images/default/sizer/s-handle-dark.gif +0 -0
  271. data/template/resources/images/default/sizer/s-handle.gif +0 -0
  272. data/template/resources/images/default/sizer/se-handle-dark.gif +0 -0
  273. data/template/resources/images/default/sizer/se-handle.gif +0 -0
  274. data/template/resources/images/default/sizer/square.gif +0 -0
  275. data/template/resources/images/default/sizer/sw-handle-dark.gif +0 -0
  276. data/template/resources/images/default/sizer/sw-handle.gif +0 -0
  277. data/template/resources/images/default/slider/slider-bg.png +0 -0
  278. data/template/resources/images/default/slider/slider-thumb.png +0 -0
  279. data/template/resources/images/default/slider/slider-v-bg.png +0 -0
  280. data/template/resources/images/default/slider/slider-v-thumb.png +0 -0
  281. data/template/resources/images/default/tabs/scroll-left.gif +0 -0
  282. data/template/resources/images/default/tabs/scroll-right.gif +0 -0
  283. data/template/resources/images/default/tabs/scroller-bg.gif +0 -0
  284. data/template/resources/images/default/tabs/tab-btm-inactive-left-bg.gif +0 -0
  285. data/template/resources/images/default/tabs/tab-btm-inactive-right-bg.gif +0 -0
  286. data/template/resources/images/default/tabs/tab-btm-left-bg.gif +0 -0
  287. data/template/resources/images/default/tabs/tab-btm-over-left-bg.gif +0 -0
  288. data/template/resources/images/default/tabs/tab-btm-over-right-bg.gif +0 -0
  289. data/template/resources/images/default/tabs/tab-btm-right-bg.gif +0 -0
  290. data/template/resources/images/default/tabs/tab-close.gif +0 -0
  291. data/template/resources/images/default/tabs/tab-strip-bg.gif +0 -0
  292. data/template/resources/images/default/tabs/tab-strip-bg.png +0 -0
  293. data/template/resources/images/default/tabs/tab-strip-btm-bg.gif +0 -0
  294. data/template/resources/images/default/tabs/tabs-sprite.gif +0 -0
  295. data/template/resources/images/default/toolbar/bg.gif +0 -0
  296. data/template/resources/images/default/toolbar/btn-arrow-light.gif +0 -0
  297. data/template/resources/images/default/toolbar/btn-arrow.gif +0 -0
  298. data/template/resources/images/default/toolbar/btn-over-bg.gif +0 -0
  299. data/template/resources/images/default/toolbar/gray-bg.gif +0 -0
  300. data/template/resources/images/default/toolbar/more.gif +0 -0
  301. data/template/resources/images/default/toolbar/tb-bg.gif +0 -0
  302. data/template/resources/images/default/toolbar/tb-btn-sprite.gif +0 -0
  303. data/template/resources/images/default/toolbar/tb-xl-btn-sprite.gif +0 -0
  304. data/template/resources/images/default/toolbar/tb-xl-sep.gif +0 -0
  305. data/template/resources/images/default/tree/arrows.gif +0 -0
  306. data/template/resources/images/default/tree/drop-add.gif +0 -0
  307. data/template/resources/images/default/tree/drop-between.gif +0 -0
  308. data/template/resources/images/default/tree/drop-no.gif +0 -0
  309. data/template/resources/images/default/tree/drop-over.gif +0 -0
  310. data/template/resources/images/default/tree/drop-under.gif +0 -0
  311. data/template/resources/images/default/tree/drop-yes.gif +0 -0
  312. data/template/resources/images/default/tree/elbow-end-minus-nl.gif +0 -0
  313. data/template/resources/images/default/tree/elbow-end-minus.gif +0 -0
  314. data/template/resources/images/default/tree/elbow-end-plus-nl.gif +0 -0
  315. data/template/resources/images/default/tree/elbow-end-plus.gif +0 -0
  316. data/template/resources/images/default/tree/elbow-end.gif +0 -0
  317. data/template/resources/images/default/tree/elbow-line.gif +0 -0
  318. data/template/resources/images/default/tree/elbow-minus-nl.gif +0 -0
  319. data/template/resources/images/default/tree/elbow-minus.gif +0 -0
  320. data/template/resources/images/default/tree/elbow-plus-nl.gif +0 -0
  321. data/template/resources/images/default/tree/elbow-plus.gif +0 -0
  322. data/template/resources/images/default/tree/elbow.gif +0 -0
  323. data/template/resources/images/default/tree/folder-open.gif +0 -0
  324. data/template/resources/images/default/tree/folder.gif +0 -0
  325. data/template/resources/images/default/tree/leaf.gif +0 -0
  326. data/template/resources/images/default/tree/loading.gif +0 -0
  327. data/template/resources/images/default/tree/s.gif +0 -0
  328. data/template/resources/images/default/window/icon-error.gif +0 -0
  329. data/template/resources/images/default/window/icon-info.gif +0 -0
  330. data/template/resources/images/default/window/icon-question.gif +0 -0
  331. data/template/resources/images/default/window/icon-warning.gif +0 -0
  332. data/template/resources/images/default/window/left-corners.png +0 -0
  333. data/template/resources/images/default/window/left-corners.psd +0 -0
  334. data/template/resources/images/default/window/left-right.png +0 -0
  335. data/template/resources/images/default/window/left-right.psd +0 -0
  336. data/template/resources/images/default/window/right-corners.png +0 -0
  337. data/template/resources/images/default/window/right-corners.psd +0 -0
  338. data/template/resources/images/default/window/top-bottom.png +0 -0
  339. data/template/resources/images/default/window/top-bottom.psd +0 -0
  340. data/template/resources/images/gray/button/btn-arrow.gif +0 -0
  341. data/template/resources/images/gray/button/btn-sprite.gif +0 -0
  342. data/template/resources/images/gray/button/btn.gif +0 -0
  343. data/template/resources/images/gray/button/group-cs.gif +0 -0
  344. data/template/resources/images/gray/button/group-lr.gif +0 -0
  345. data/template/resources/images/gray/button/group-tb.gif +0 -0
  346. data/template/resources/images/gray/button/s-arrow-bo.gif +0 -0
  347. data/template/resources/images/gray/button/s-arrow-o.gif +0 -0
  348. data/template/resources/images/gray/form/clear-trigger.gif +0 -0
  349. data/template/resources/images/gray/form/date-trigger.gif +0 -0
  350. data/template/resources/images/gray/form/search-trigger.gif +0 -0
  351. data/template/resources/images/gray/form/trigger-square.gif +0 -0
  352. data/template/resources/images/gray/form/trigger.gif +0 -0
  353. data/template/resources/images/gray/gradient-bg.gif +0 -0
  354. data/template/resources/images/gray/grid/col-move-bottom.gif +0 -0
  355. data/template/resources/images/gray/grid/col-move-top.gif +0 -0
  356. data/template/resources/images/gray/grid/grid3-hd-btn.gif +0 -0
  357. data/template/resources/images/gray/grid/grid3-hrow-over.gif +0 -0
  358. data/template/resources/images/gray/grid/grid3-hrow-over2.gif +0 -0
  359. data/template/resources/images/gray/grid/grid3-hrow.gif +0 -0
  360. data/template/resources/images/gray/grid/grid3-hrow2.gif +0 -0
  361. data/template/resources/images/gray/grid/grid3-special-col-bg.gif +0 -0
  362. data/template/resources/images/gray/grid/grid3-special-col-bg2.gif +0 -0
  363. data/template/resources/images/gray/grid/grid3-special-col-sel-bg.gif +0 -0
  364. data/template/resources/images/gray/grid/group-collapse.gif +0 -0
  365. data/template/resources/images/gray/grid/group-expand-sprite.gif +0 -0
  366. data/template/resources/images/gray/grid/group-expand.gif +0 -0
  367. data/template/resources/images/gray/grid/page-first.gif +0 -0
  368. data/template/resources/images/gray/grid/page-last.gif +0 -0
  369. data/template/resources/images/gray/grid/page-next.gif +0 -0
  370. data/template/resources/images/gray/grid/page-prev.gif +0 -0
  371. data/template/resources/images/gray/grid/refresh.gif +0 -0
  372. data/template/resources/images/gray/grid/row-expand-sprite.gif +0 -0
  373. data/template/resources/images/gray/grid/sort_asc.gif +0 -0
  374. data/template/resources/images/gray/grid/sort_desc.gif +0 -0
  375. data/template/resources/images/gray/menu/group-checked.gif +0 -0
  376. data/template/resources/images/gray/menu/item-over-disabled.gif +0 -0
  377. data/template/resources/images/gray/menu/item-over.gif +0 -0
  378. data/template/resources/images/gray/menu/menu-parent.gif +0 -0
  379. data/template/resources/images/gray/panel/corners-sprite.gif +0 -0
  380. data/template/resources/images/gray/panel/left-right.gif +0 -0
  381. data/template/resources/images/gray/panel/light-hd.gif +0 -0
  382. data/template/resources/images/gray/panel/tool-sprite-tpl.gif +0 -0
  383. data/template/resources/images/gray/panel/tool-sprites.gif +0 -0
  384. data/template/resources/images/gray/panel/tools-sprites-trans.gif +0 -0
  385. data/template/resources/images/gray/panel/top-bottom.gif +0 -0
  386. data/template/resources/images/gray/panel/top-bottom.png +0 -0
  387. data/template/resources/images/gray/panel/white-corners-sprite.gif +0 -0
  388. data/template/resources/images/gray/panel/white-left-right.gif +0 -0
  389. data/template/resources/images/gray/panel/white-top-bottom.gif +0 -0
  390. data/template/resources/images/gray/progress/progress-bg.gif +0 -0
  391. data/template/resources/images/gray/qtip/bg.gif +0 -0
  392. data/template/resources/images/gray/qtip/close.gif +0 -0
  393. data/template/resources/images/gray/qtip/tip-anchor-sprite.gif +0 -0
  394. data/template/resources/images/gray/qtip/tip-sprite.gif +0 -0
  395. data/template/resources/images/gray/s.gif +0 -0
  396. data/template/resources/images/gray/shared/hd-sprite.gif +0 -0
  397. data/template/resources/images/gray/shared/left-btn.gif +0 -0
  398. data/template/resources/images/gray/shared/right-btn.gif +0 -0
  399. data/template/resources/images/gray/sizer/e-handle.gif +0 -0
  400. data/template/resources/images/gray/sizer/ne-handle.gif +0 -0
  401. data/template/resources/images/gray/sizer/nw-handle.gif +0 -0
  402. data/template/resources/images/gray/sizer/s-handle.gif +0 -0
  403. data/template/resources/images/gray/sizer/se-handle.gif +0 -0
  404. data/template/resources/images/gray/sizer/square.gif +0 -0
  405. data/template/resources/images/gray/sizer/sw-handle.gif +0 -0
  406. data/template/resources/images/gray/slider/slider-thumb.png +0 -0
  407. data/template/resources/images/gray/slider/slider-v-thumb.png +0 -0
  408. data/template/resources/images/gray/tabs/scroll-left.gif +0 -0
  409. data/template/resources/images/gray/tabs/scroll-right.gif +0 -0
  410. data/template/resources/images/gray/tabs/scroller-bg.gif +0 -0
  411. data/template/resources/images/gray/tabs/tab-btm-inactive-left-bg.gif +0 -0
  412. data/template/resources/images/gray/tabs/tab-btm-inactive-right-bg.gif +0 -0
  413. data/template/resources/images/gray/tabs/tab-btm-left-bg.gif +0 -0
  414. data/template/resources/images/gray/tabs/tab-btm-over-left-bg.gif +0 -0
  415. data/template/resources/images/gray/tabs/tab-btm-over-right-bg.gif +0 -0
  416. data/template/resources/images/gray/tabs/tab-btm-right-bg.gif +0 -0
  417. data/template/resources/images/gray/tabs/tab-close.gif +0 -0
  418. data/template/resources/images/gray/tabs/tab-strip-bg.gif +0 -0
  419. data/template/resources/images/gray/tabs/tab-strip-bg.png +0 -0
  420. data/template/resources/images/gray/tabs/tab-strip-btm-bg.gif +0 -0
  421. data/template/resources/images/gray/tabs/tabs-sprite.gif +0 -0
  422. data/template/resources/images/gray/toolbar/bg.gif +0 -0
  423. data/template/resources/images/gray/toolbar/btn-arrow-light.gif +0 -0
  424. data/template/resources/images/gray/toolbar/btn-arrow.gif +0 -0
  425. data/template/resources/images/gray/toolbar/btn-over-bg.gif +0 -0
  426. data/template/resources/images/gray/toolbar/gray-bg.gif +0 -0
  427. data/template/resources/images/gray/toolbar/more.gif +0 -0
  428. data/template/resources/images/gray/toolbar/tb-bg.gif +0 -0
  429. data/template/resources/images/gray/toolbar/tb-btn-sprite.gif +0 -0
  430. data/template/resources/images/gray/tree/arrows.gif +0 -0
  431. data/template/resources/images/gray/tree/elbow-end-minus-nl.gif +0 -0
  432. data/template/resources/images/gray/tree/elbow-end-minus.gif +0 -0
  433. data/template/resources/images/gray/tree/elbow-end-plus-nl.gif +0 -0
  434. data/template/resources/images/gray/tree/elbow-end-plus.gif +0 -0
  435. data/template/resources/images/gray/window/icon-error.gif +0 -0
  436. data/template/resources/images/gray/window/icon-info.gif +0 -0
  437. data/template/resources/images/gray/window/icon-question.gif +0 -0
  438. data/template/resources/images/gray/window/icon-warning.gif +0 -0
  439. data/template/resources/images/gray/window/left-corners.png +0 -0
  440. data/template/resources/images/gray/window/left-corners.pspimage +0 -0
  441. data/template/resources/images/gray/window/left-right.png +0 -0
  442. data/template/resources/images/gray/window/right-corners.png +0 -0
  443. data/template/resources/images/gray/window/top-bottom.png +0 -0
  444. data/template/resources/inherited.gif +0 -0
  445. data/template/resources/method.gif +0 -0
  446. data/template/resources/pkg-closed.gif +0 -0
  447. data/template/resources/pkg-open.gif +0 -0
  448. data/template/resources/pkg.gif +0 -0
  449. data/template/resources/prop.gif +0 -0
  450. data/template/resources/s.gif +0 -0
  451. data/template/resources/static.gif +0 -0
  452. data/template/resources/style.css +0 -291
  453. data/template/welcome.html +0 -45
@@ -0,0 +1,39 @@
1
+ module JsDuck
2
+
3
+ class Aliases
4
+ def initialize(relations)
5
+ @relations = relations
6
+ end
7
+
8
+ def resolve_all
9
+ @relations.each do |cls|
10
+ cls.each_member do |member|
11
+ if member[:alias]
12
+ resolve(member)
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ # Copy over doc/params/return from original member to alias.
19
+ def resolve(al)
20
+ orig = find_original(al)
21
+ al[:doc] = al[:doc] + "\n\n" + orig[:doc]
22
+ al[:params] = orig[:params] if orig[:params]
23
+ al[:return] = orig[:return] if orig[:return]
24
+ end
25
+
26
+ # Given aliased member, finds the original member.
27
+ # If the original also happens to be an alias, continue recursively.
28
+ def find_original(al)
29
+ al_def = al[:alias]
30
+ orig = @relations[al_def[:cls]].get_member(al_def[:member], al_def[:type] || al[:tagname])
31
+ if orig[:alias]
32
+ find_original(orig)
33
+ else
34
+ orig
35
+ end
36
+ end
37
+ end
38
+
39
+ end
@@ -2,15 +2,20 @@ require 'rubygems'
2
2
  require 'jsduck/aggregator'
3
3
  require 'jsduck/source_file'
4
4
  require 'jsduck/source_writer'
5
+ require 'jsduck/doc_formatter'
5
6
  require 'jsduck/class'
6
7
  require 'jsduck/tree'
7
8
  require 'jsduck/tree_icons'
8
- require 'jsduck/members'
9
+ require 'jsduck/search_data'
9
10
  require 'jsduck/relations'
10
- require 'jsduck/page'
11
+ require 'jsduck/aliases'
11
12
  require 'jsduck/exporter'
12
13
  require 'jsduck/timer'
13
14
  require 'jsduck/parallel_wrap'
15
+ require 'jsduck/logger'
16
+ require 'jsduck/guides'
17
+ require 'jsduck/categories'
18
+ require 'jsduck/jsonp'
14
19
  require 'json'
15
20
  require 'fileutils'
16
21
 
@@ -21,22 +26,41 @@ module JsDuck
21
26
  # These are basically input parameters for app
22
27
  attr_accessor :output_dir
23
28
  attr_accessor :template_dir
29
+ attr_accessor :guides_dir
30
+ attr_accessor :guides_order
31
+ attr_accessor :categories_path
32
+ attr_accessor :template_links
24
33
  attr_accessor :input_files
25
- attr_accessor :verbose
26
34
  attr_accessor :export
27
35
  attr_accessor :link_tpl
28
36
  attr_accessor :img_tpl
29
37
  attr_accessor :ignore_global
38
+ attr_accessor :external_classes
39
+ attr_accessor :show_private_classes
40
+ attr_accessor :title
41
+ attr_accessor :footer
42
+ attr_accessor :extjs_path
43
+ attr_accessor :append_html
30
44
 
31
45
  def initialize
32
46
  @output_dir = nil
33
47
  @template_dir = nil
48
+ @guides_dir = nil
49
+ @guides_order = nil
50
+ @categories_path = nil
51
+ @template_links = false
34
52
  @input_files = []
35
- @verbose = false
53
+ @warnings = true
36
54
  @export = nil
37
55
  @link_tpl = nil
38
56
  @img_tpl = nil
39
57
  @ignore_global = false
58
+ @external_classes = []
59
+ @show_private_classes = false
60
+ @title = "Ext JS API Documentation"
61
+ @footer = 'Generated with <a href="https://github.com/senchalabs/jsduck">JSDuck</a>.'
62
+ @extjs_path = "extjs/ext-all.js"
63
+ @append_html = ""
40
64
  @timer = Timer.new
41
65
  @parallel = ParallelWrap.new
42
66
  end
@@ -47,35 +71,71 @@ module JsDuck
47
71
  @parallel = ParallelWrap.new(:in_processes => count)
48
72
  end
49
73
 
74
+ # Sets warnings on or off
75
+ def warnings=(enabled)
76
+ Logger.instance.warnings = enabled
77
+ end
78
+
79
+ # Sets verbose mode on or off
80
+ def verbose=(enabled)
81
+ Logger.instance.verbose = enabled
82
+ end
83
+
50
84
  # Call this after input parameters set
51
85
  def run
86
+ # Set default templates
87
+ @link_tpl ||= '<a href="#/api/%c%-%m" rel="%c%-%m" class="docClass">%a</a>'
88
+ # Note that we wrap image template inside <p> because {@img} often
89
+ # appears inline within text, but that just looks ugly in HTML
90
+ @img_tpl ||= '<p><img src="doc-resources/%u" alt="%a"></p>'
91
+
52
92
  parsed_files = @timer.time(:parsing) { parallel_parse(@input_files) }
53
93
  result = @timer.time(:aggregating) { aggregate(parsed_files) }
54
94
  relations = @timer.time(:aggregating) { filter_classes(result) }
95
+ Aliases.new(relations).resolve_all
55
96
  warn_globals(relations)
56
97
  warn_unnamed(relations)
57
98
 
99
+ @guides = Guides.new(get_doc_formatter(relations), @guides_order)
100
+ if @guides_dir
101
+ @timer.time(:parsing) { @guides.parse_dir(@guides_dir) }
102
+ end
103
+
104
+ @categories = Categories.new(get_doc_formatter(relations), relations)
105
+ if @categories_path
106
+ @timer.time(:parsing) do
107
+ @categories.parse(@categories_path)
108
+ @categories.validate
109
+ end
110
+ end
111
+
58
112
  clear_dir(@output_dir)
59
113
  if @export == :json
60
114
  FileUtils.mkdir(@output_dir)
61
115
  init_output_dirs(@output_dir)
62
116
  @timer.time(:generating) { write_src(@output_dir+"/source", parsed_files) }
63
- @timer.time(:generating) { write_json(@output_dir+"/output", relations) }
117
+ @timer.time(:generating) { write_classes(@output_dir+"/output", relations) }
64
118
  else
65
- copy_template(@template_dir, @output_dir)
119
+ if @template_links
120
+ link_template(@template_dir, @output_dir)
121
+ else
122
+ copy_template(@template_dir, @output_dir)
123
+ end
124
+ create_index_html(@template_dir, @output_dir)
66
125
  @timer.time(:generating) { write_src(@output_dir+"/source", parsed_files) }
67
126
  @timer.time(:generating) { write_tree(@output_dir+"/output/tree.js", relations) }
68
- @timer.time(:generating) { write_members(@output_dir+"/output/members.js", relations) }
69
- @timer.time(:generating) { write_pages(@output_dir+"/output", relations) }
127
+ @timer.time(:generating) { write_search_data(@output_dir+"/output/searchData.js", relations) }
128
+ @timer.time(:generating) { write_classes(@output_dir+"/output", relations) }
129
+ @timer.time(:generating) { @guides.write(@output_dir+"/guides") }
70
130
  end
71
131
 
72
- @timer.report if @verbose
132
+ @timer.report
73
133
  end
74
134
 
75
135
  # Parses the files in parallel using as many processes as available CPU-s
76
136
  def parallel_parse(filenames)
77
137
  @parallel.map(filenames) do |fname|
78
- puts "Parsing #{fname} ..." if @verbose
138
+ Logger.instance.log("Parsing #{fname} ...")
79
139
  SourceFile.new(IO.read(fname), fname)
80
140
  end
81
141
  end
@@ -84,11 +144,12 @@ module JsDuck
84
144
  def aggregate(parsed_files)
85
145
  agr = Aggregator.new
86
146
  parsed_files.each do |file|
87
- puts "Aggregating #{file.filename} ..." if @verbose
147
+ Logger.instance.log("Aggregating #{file.filename} ...")
88
148
  agr.aggregate(file)
89
149
  end
90
150
  agr.classify_orphans
91
151
  agr.create_global_class unless @ignore_global
152
+ agr.append_ext4_event_options
92
153
  agr.result
93
154
  end
94
155
 
@@ -98,28 +159,28 @@ module JsDuck
98
159
  classes = []
99
160
  docs.each do |d|
100
161
  if d[:tagname] == :class
101
- classes << Class.new(d)
162
+ classes << Class.new(d) if !d[:private] || @show_private_classes
102
163
  else
103
164
  type = d[:tagname].to_s
104
165
  name = d[:name]
105
166
  file = d[:filename]
106
167
  line = d[:linenr]
107
- puts "Warning: Ignoring #{type}: #{name} in #{file} line #{line}"
168
+ Logger.instance.warn("Ignoring #{type}: #{name} in #{file} line #{line}")
108
169
  end
109
170
  end
110
- Relations.new(classes)
171
+ Relations.new(classes, @external_classes)
111
172
  end
112
173
 
113
174
  # print warning for each global member
114
175
  def warn_globals(relations)
115
176
  global = relations["global"]
116
177
  return unless global
117
- [:cfg, :property, :method, :event].each do |type|
178
+ global[:members].each_key do |type|
118
179
  global.members(type).each do |member|
119
180
  name = member[:name]
120
181
  file = member[:filename]
121
182
  line = member[:linenr]
122
- puts "Warning: Global #{type}: #{name} in #{file} line #{line}"
183
+ Logger.instance.warn("Global #{type}: #{name} in #{file} line #{line}")
123
184
  end
124
185
  end
125
186
  end
@@ -127,12 +188,12 @@ module JsDuck
127
188
  # print warning for each member with no name
128
189
  def warn_unnamed(relations)
129
190
  relations.each do |cls|
130
- [:cfg, :property, :method, :event].each do |type|
131
- cls[type].each do |member|
191
+ cls[:members].each_pair do |type, members|
192
+ members.each do |member|
132
193
  if !member[:name] || member[:name] == ""
133
194
  file = member[:filename]
134
195
  line = member[:linenr]
135
- puts "Warning: Unnamed #{type} in #{file} line #{line}"
196
+ Logger.instance.warn("Unnamed #{type} in #{file} line #{line}")
136
197
  end
137
198
  end
138
199
  end
@@ -142,7 +203,7 @@ module JsDuck
142
203
  # Given all classes, generates namespace tree and writes it
143
204
  # in JSON form into a file.
144
205
  def write_tree(filename, relations)
145
- tree = Tree.new.create(relations.classes)
206
+ tree = Tree.new.create(relations.classes, @guides)
146
207
  icons = TreeIcons.new.extract_icons(tree)
147
208
  js = "Docs.classData = " + JSON.generate( tree ) + ";"
148
209
  js += "Docs.icons = " + JSON.generate( icons ) + ";"
@@ -151,39 +212,19 @@ module JsDuck
151
212
 
152
213
  # Given all classes, generates members data for search and writes in
153
214
  # in JSON form into a file.
154
- def write_members(filename, relations)
155
- members = Members.new.create(relations.classes)
156
- js = "Docs.membersData = " + JSON.generate( {:data => members} ) + ";"
215
+ def write_search_data(filename, relations)
216
+ search_data = SearchData.new.create(relations.classes)
217
+ js = "Docs.searchData = " + JSON.generate( {:data => search_data} ) + ";"
157
218
  File.open(filename, 'w') {|f| f.write(js) }
158
219
  end
159
220
 
160
- # Writes documentation page for each class
161
- # We do it in parallel using as many processes as available CPU-s
162
- def write_pages(path, relations)
163
- cache = {}
164
- @parallel.each(relations.classes) do |cls|
165
- filename = path + "/" + cls[:name] + ".html"
166
- puts "Writing to #{filename} ..." if @verbose
167
- page = Page.new(cls, relations, cache)
168
- page.link_tpl = @link_tpl if @link_tpl
169
- page.img_tpl = @img_tpl if @img_tpl
170
- File.open(filename, 'w') {|f| f.write(page.to_html) }
171
- end
172
- end
173
-
174
- # Writes JSON export file for each class
175
- def write_json(path, relations)
176
- formatter = DocFormatter.new
177
- formatter.link_tpl = @link_tpl if @link_tpl
178
- formatter.img_tpl = @img_tpl if @img_tpl
179
- formatter.relations = relations
180
- exporter = Exporter.new(relations, formatter)
221
+ # Writes JsonP export file for each class
222
+ def write_classes(path, relations)
223
+ exporter = Exporter.new(relations, get_doc_formatter(relations))
181
224
  @parallel.each(relations.classes) do |cls|
182
- filename = path + "/" + cls[:name] + ".json"
183
- puts "Writing to #{filename} ..." if @verbose
184
- hash = exporter.export(cls)
185
- json = JSON.pretty_generate(hash)
186
- File.open(filename, 'w') {|f| f.write(json) }
225
+ filename = path + "/" + cls[:name] + ".js"
226
+ Logger.instance.log("Writing to #{filename} ...")
227
+ JsonP.write(filename, cls[:name].gsub(/\./, "_"), exporter.export(cls))
187
228
  end
188
229
  end
189
230
 
@@ -194,17 +235,35 @@ module JsDuck
194
235
  # updates all the doc-objects related to the file
195
236
  parsed_files.each do |file|
196
237
  html_filename = src.write(file.to_html, file.filename)
197
- puts "Writing to #{html_filename} ..." if @verbose
238
+ Logger.instance.log("Writing to #{html_filename} ...")
198
239
  file.html_filename = File.basename(html_filename)
199
240
  end
200
241
  end
201
242
 
243
+ # Creates and initializes DocFormatter
244
+ def get_doc_formatter(relations)
245
+ formatter = DocFormatter.new
246
+ formatter.link_tpl = @link_tpl if @link_tpl
247
+ formatter.img_tpl = @img_tpl if @img_tpl
248
+ formatter.relations = relations
249
+ formatter
250
+ end
251
+
202
252
  def copy_template(template_dir, dir)
203
- puts "Copying template files to #{dir}..." if @verbose
253
+ Logger.instance.log("Copying template files to #{dir}...")
204
254
  FileUtils.cp_r(template_dir, dir)
205
255
  init_output_dirs(dir)
206
256
  end
207
257
 
258
+ def link_template(template_dir, dir)
259
+ Logger.instance.log("Linking template files to #{dir}...")
260
+ FileUtils.mkdir(dir)
261
+ Dir.glob(template_dir + "/*").each do |file|
262
+ File.symlink(File.expand_path(file), dir+"/"+File.basename(file))
263
+ end
264
+ init_output_dirs(dir)
265
+ end
266
+
208
267
  def clear_dir(dir)
209
268
  if File.exists?(dir)
210
269
  FileUtils.rm_r(dir)
@@ -215,6 +274,19 @@ module JsDuck
215
274
  FileUtils.mkdir(dir + "/output")
216
275
  FileUtils.mkdir(dir + "/source")
217
276
  end
277
+
278
+ def create_index_html(template_dir, dir)
279
+ Logger.instance.log("Creating #{dir}/index.html...")
280
+ html = IO.read(template_dir+"/index.html")
281
+ html.gsub!("{title}", @title)
282
+ html.gsub!("{footer}", @footer)
283
+ html.gsub!("{extjs_path}", @extjs_path)
284
+ html.gsub!("{append_html}", @append_html)
285
+ html.gsub!("{guides}", @guides.to_html)
286
+ html.gsub!("{categories}", @categories.to_html)
287
+ FileUtils.rm(dir+"/index.html")
288
+ File.open(dir+"/index.html", 'w') {|f| f.write(html) }
289
+ end
218
290
  end
219
291
 
220
292
  end
@@ -0,0 +1,132 @@
1
+ require 'jsduck/logger'
2
+ require 'json'
3
+
4
+ module JsDuck
5
+
6
+ # Reads in categories and outputs them as HTML div
7
+ class Categories
8
+ def initialize(doc_formatter, relations={})
9
+ @doc_formatter = doc_formatter
10
+ @relations = relations
11
+ @categories = []
12
+ end
13
+
14
+ # Parses categories in JSON file
15
+ def parse(path)
16
+ @categories = JSON.parse(IO.read(path))["categories"]
17
+ end
18
+
19
+ # Prints warnings for missing classes in categories file
20
+ def validate
21
+ listed_classes = {}
22
+
23
+ # Check that each class listed in overview file exists
24
+ @categories.each do |cat|
25
+ cat["groups"].each do |group|
26
+ group["classes"].each do |cls_name|
27
+ unless @relations[cls_name]
28
+ Logger.instance.warn("Class '#{cls_name}' in category '#{cat['name']}/#{group['name']}' not found")
29
+ end
30
+ listed_classes[cls_name] = true
31
+ end
32
+ end
33
+ end
34
+
35
+ # Check that each existing non-private class is listed in overview file
36
+ @relations.each do |cls|
37
+ unless listed_classes[cls[:name]] || cls[:private]
38
+ Logger.instance.warn("Class '#{cls[:name]}' not found in categories file")
39
+ end
40
+ end
41
+ end
42
+
43
+ # Returns HTML listing of classes divided into categories
44
+ def to_html
45
+ return "" if @categories.length == 0
46
+
47
+ html = @categories.map do |category|
48
+ [
49
+ "<div class='section classes'>",
50
+ "<h1>#{category['name']}</h1>",
51
+ render_columns(category['groups']),
52
+ "<div style='clear:both'></div>",
53
+ "</div>",
54
+ ]
55
+ end.flatten.join("\n")
56
+
57
+ return <<-EOHTML
58
+ <div id='categories-content' style='display:none'>
59
+ #{html}
60
+ </div>
61
+ EOHTML
62
+ end
63
+
64
+ def render_columns(groups)
65
+ align = ["lft", "mid", "rgt"]
66
+ i = -1
67
+ return split(groups, 3).map do |col|
68
+ i += 1
69
+ [
70
+ "<div class='#{align[i]}'>",
71
+ render_groups(col),
72
+ "</div>",
73
+ ]
74
+ end
75
+ end
76
+
77
+ def render_groups(groups)
78
+ return groups.map do |g|
79
+ [
80
+ "<h3>#{g['name']}</h3>",
81
+ "<div class='links'>",
82
+ g["classes"].map {|cls| @relations[cls] ? @doc_formatter.link(cls, nil, cls) : cls },
83
+ "</div>",
84
+ ]
85
+ end
86
+ end
87
+
88
+ # Splits the array of items into n chunks so that the sum of
89
+ # largest chunk is as small as possible.
90
+ #
91
+ # This is a brute-force implementation - we just try all the
92
+ # combinations and choose the best one.
93
+ def split(items, n)
94
+ if n == 1
95
+ [items]
96
+ elsif items.length <= n
97
+ Array.new(n) {|i| items[i] ? [items[i]] : [] }
98
+ else
99
+ min_max = nil
100
+ min_arr = nil
101
+ i = 0
102
+ while i <= items.length-n
103
+ i += 1
104
+ # Try placing 1, 2, 3, ... items to first chunk.
105
+ # Calculate the remaining chunks recursively.
106
+ cols = [items[0,i]] + split(items[i, items.length], n-1)
107
+ max = max_sum(cols)
108
+ # Is this the optimal solution so far? Remember it.
109
+ if !min_max || max < min_max
110
+ min_max = max
111
+ min_arr = cols
112
+ end
113
+ end
114
+ min_arr
115
+ end
116
+ end
117
+
118
+ def max_sum(cols)
119
+ cols.map {|col| sum(col) }.max
120
+ end
121
+
122
+ # Finds the total size of items in array
123
+ #
124
+ # The size of one item is it's number of classes + the space for header
125
+ def sum(arr)
126
+ header_size = 3
127
+ arr.reduce(0) {|sum, item| sum + item["classes"].length + header_size }
128
+ end
129
+
130
+ end
131
+
132
+ end