jsduck 0.6.1 → 2.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/README.md +35 -13
- data/Rakefile +129 -0
- data/bin/jsduck +112 -20
- data/jsduck.gemspec +10 -7
- data/lib/jsduck/aggregator.rb +46 -20
- data/lib/jsduck/aliases.rb +39 -0
- data/lib/jsduck/app.rb +123 -51
- data/lib/jsduck/categories.rb +132 -0
- data/lib/jsduck/class.rb +71 -18
- data/lib/jsduck/doc_formatter.rb +61 -26
- data/lib/jsduck/doc_parser.rb +53 -2
- data/lib/jsduck/exporter.rb +14 -15
- data/lib/jsduck/guides.rb +110 -0
- data/lib/jsduck/js_parser.rb +18 -4
- data/lib/jsduck/jsonp.rb +17 -0
- data/lib/jsduck/logger.rb +36 -0
- data/lib/jsduck/merger.rb +69 -51
- data/lib/jsduck/page.rb +1 -1
- data/lib/jsduck/relations.rb +14 -3
- data/lib/jsduck/{members.rb → search_data.rb} +3 -28
- data/lib/jsduck/source_file.rb +4 -4
- data/lib/jsduck/source_writer.rb +2 -2
- data/lib/jsduck/timer.rb +6 -2
- data/lib/jsduck/tree.rb +29 -16
- data/lib/jsduck/tree_icons.rb +1 -1
- data/template/README.md +14 -0
- data/template/app.js +25 -0
- data/template/app/Application.js +53 -0
- data/template/app/Favorites.js +88 -0
- data/template/app/History.js +45 -0
- data/template/app/LocalStore.js +45 -0
- data/template/app/Settings.js +39 -0
- data/template/app/Syntax.js +20 -0
- data/template/app/controller/Classes.js +301 -0
- data/template/app/controller/Search.js +156 -0
- data/template/app/model/Favorite.js +11 -0
- data/template/app/model/Setting.js +11 -0
- data/template/app/store/Favorites.js +7 -0
- data/template/app/store/Search.js +14 -0
- data/template/app/store/Settings.js +7 -0
- data/template/app/view/ClassGrid.js +109 -0
- data/template/app/view/HoverMenu.js +59 -0
- data/template/app/view/HoverMenuButton.js +147 -0
- data/template/app/view/Viewport.js +240 -0
- data/template/app/view/cls/Header.js +47 -0
- data/template/app/view/cls/Overview.js +415 -0
- data/template/app/view/cls/Toolbar.js +199 -0
- data/template/app/view/index/Container.js +63 -0
- data/template/app/view/search/Dropdown.js +53 -0
- data/template/app/view/tree/Tree.js +133 -0
- data/template/favicon.ico +0 -0
- data/template/index.html +32 -37
- data/template/{resources/prettify → prettify}/prettify.css +0 -0
- data/template/{resources/prettify → prettify}/prettify.js +0 -0
- data/template/resources/images/class-m.png +0 -0
- data/template/resources/images/class-sm.png +0 -0
- data/template/resources/images/component-m.png +0 -0
- data/template/resources/images/configs.png +0 -0
- data/template/resources/images/data-package.png +0 -0
- data/template/resources/images/doc-m.png +0 -0
- data/template/resources/images/drag-bar-center.png +0 -0
- data/template/resources/{elbow-end.gif → images/elbow-end.gif} +0 -0
- data/template/resources/images/events.png +0 -0
- data/template/resources/images/expandcollapse.png +0 -0
- data/template/resources/images/guide-icon.png +0 -0
- data/template/resources/images/guides.png +0 -0
- data/template/resources/images/headBG.png +0 -0
- data/template/resources/images/header.gif +0 -0
- data/template/resources/images/icon.png +0 -0
- data/template/resources/images/icons.png +0 -0
- data/template/resources/images/loading-title.png +0 -0
- data/template/resources/images/loading.gif +0 -0
- data/template/resources/{member-collapsed.gif → images/member-collapsed.gif} +0 -0
- data/template/resources/{member-expanded.gif → images/member-expanded.gif} +0 -0
- data/template/resources/{member-hover.gif → images/member-hover.gif} +0 -0
- data/template/resources/images/methods.png +0 -0
- data/template/resources/images/model.png +0 -0
- data/template/resources/images/properties.png +0 -0
- data/template/resources/images/root-lines.png +0 -0
- data/template/resources/images/search-box.png +0 -0
- data/template/resources/images/singleton-m.png +0 -0
- data/template/resources/images/version-tabs.png +0 -0
- data/template/resources/images/x.png +0 -0
- data/template/resources/images/x12.png +0 -0
- metadata +84 -387
- data/lib/jsduck/cfg_table.rb +0 -21
- data/lib/jsduck/event_table.rb +0 -33
- data/lib/jsduck/inheritance_tree.rb +0 -42
- data/lib/jsduck/long_params.rb +0 -30
- data/lib/jsduck/method_table.rb +0 -45
- data/lib/jsduck/property_table.rb +0 -21
- data/lib/jsduck/short_params.rb +0 -24
- data/lib/jsduck/table.rb +0 -121
- data/template/resources/TabCloseMenu.js +0 -150
- data/template/resources/block-bottom.gif +0 -0
- data/template/resources/block-top.gif +0 -0
- data/template/resources/class.gif +0 -0
- data/template/resources/cmp.gif +0 -0
- data/template/resources/collapse-all.gif +0 -0
- data/template/resources/config.gif +0 -0
- data/template/resources/css/ext-all.css +0 -6993
- data/template/resources/css/xtheme-gray.css +0 -1654
- data/template/resources/docs.css +0 -361
- data/template/resources/docs.gif +0 -0
- data/template/resources/docs.js +0 -769
- data/template/resources/event.gif +0 -0
- data/template/resources/expand-all.gif +0 -0
- data/template/resources/expand-bg-over.gif +0 -0
- data/template/resources/expand-bg.gif +0 -0
- data/template/resources/expand-members.gif +0 -0
- data/template/resources/ext-all.js +0 -11
- data/template/resources/ext-base.js +0 -7
- data/template/resources/extanim32.gif +0 -0
- data/template/resources/fav.gif +0 -0
- data/template/resources/favicon.ico +0 -0
- data/template/resources/hd-bg.png +0 -0
- data/template/resources/hide-inherited.gif +0 -0
- data/template/resources/images/default/box/corners-blue.gif +0 -0
- data/template/resources/images/default/box/corners.gif +0 -0
- data/template/resources/images/default/box/l-blue.gif +0 -0
- data/template/resources/images/default/box/l.gif +0 -0
- data/template/resources/images/default/box/r-blue.gif +0 -0
- data/template/resources/images/default/box/r.gif +0 -0
- data/template/resources/images/default/box/tb-blue.gif +0 -0
- data/template/resources/images/default/box/tb.gif +0 -0
- data/template/resources/images/default/button/arrow.gif +0 -0
- data/template/resources/images/default/button/btn.gif +0 -0
- data/template/resources/images/default/button/group-cs.gif +0 -0
- data/template/resources/images/default/button/group-lr.gif +0 -0
- data/template/resources/images/default/button/group-tb.gif +0 -0
- data/template/resources/images/default/button/s-arrow-b-noline.gif +0 -0
- data/template/resources/images/default/button/s-arrow-b.gif +0 -0
- data/template/resources/images/default/button/s-arrow-bo.gif +0 -0
- data/template/resources/images/default/button/s-arrow-noline.gif +0 -0
- data/template/resources/images/default/button/s-arrow-o.gif +0 -0
- data/template/resources/images/default/button/s-arrow.gif +0 -0
- data/template/resources/images/default/dd/drop-add.gif +0 -0
- data/template/resources/images/default/dd/drop-no.gif +0 -0
- data/template/resources/images/default/dd/drop-yes.gif +0 -0
- data/template/resources/images/default/editor/tb-sprite.gif +0 -0
- data/template/resources/images/default/form/checkbox.gif +0 -0
- data/template/resources/images/default/form/clear-trigger.gif +0 -0
- data/template/resources/images/default/form/clear-trigger.psd +0 -0
- data/template/resources/images/default/form/date-trigger.gif +0 -0
- data/template/resources/images/default/form/date-trigger.psd +0 -0
- data/template/resources/images/default/form/error-tip-corners.gif +0 -0
- data/template/resources/images/default/form/exclamation.gif +0 -0
- data/template/resources/images/default/form/radio.gif +0 -0
- data/template/resources/images/default/form/search-trigger.gif +0 -0
- data/template/resources/images/default/form/search-trigger.psd +0 -0
- data/template/resources/images/default/form/text-bg.gif +0 -0
- data/template/resources/images/default/form/trigger-square.gif +0 -0
- data/template/resources/images/default/form/trigger-square.psd +0 -0
- data/template/resources/images/default/form/trigger-tpl.gif +0 -0
- data/template/resources/images/default/form/trigger.gif +0 -0
- data/template/resources/images/default/form/trigger.psd +0 -0
- data/template/resources/images/default/gradient-bg.gif +0 -0
- data/template/resources/images/default/grid/arrow-left-white.gif +0 -0
- data/template/resources/images/default/grid/arrow-right-white.gif +0 -0
- data/template/resources/images/default/grid/col-move-bottom.gif +0 -0
- data/template/resources/images/default/grid/col-move-top.gif +0 -0
- data/template/resources/images/default/grid/columns.gif +0 -0
- data/template/resources/images/default/grid/dirty.gif +0 -0
- data/template/resources/images/default/grid/done.gif +0 -0
- data/template/resources/images/default/grid/drop-no.gif +0 -0
- data/template/resources/images/default/grid/drop-yes.gif +0 -0
- data/template/resources/images/default/grid/footer-bg.gif +0 -0
- data/template/resources/images/default/grid/grid-blue-hd.gif +0 -0
- data/template/resources/images/default/grid/grid-blue-split.gif +0 -0
- data/template/resources/images/default/grid/grid-hrow.gif +0 -0
- data/template/resources/images/default/grid/grid-loading.gif +0 -0
- data/template/resources/images/default/grid/grid-split.gif +0 -0
- data/template/resources/images/default/grid/grid-vista-hd.gif +0 -0
- data/template/resources/images/default/grid/grid3-hd-btn.gif +0 -0
- data/template/resources/images/default/grid/grid3-hrow-over.gif +0 -0
- data/template/resources/images/default/grid/grid3-hrow.gif +0 -0
- data/template/resources/images/default/grid/grid3-special-col-bg.gif +0 -0
- data/template/resources/images/default/grid/grid3-special-col-sel-bg.gif +0 -0
- data/template/resources/images/default/grid/group-by.gif +0 -0
- data/template/resources/images/default/grid/group-collapse.gif +0 -0
- data/template/resources/images/default/grid/group-expand-sprite.gif +0 -0
- data/template/resources/images/default/grid/group-expand.gif +0 -0
- data/template/resources/images/default/grid/hd-pop.gif +0 -0
- data/template/resources/images/default/grid/hmenu-asc.gif +0 -0
- data/template/resources/images/default/grid/hmenu-desc.gif +0 -0
- data/template/resources/images/default/grid/hmenu-lock.gif +0 -0
- data/template/resources/images/default/grid/hmenu-lock.png +0 -0
- data/template/resources/images/default/grid/hmenu-unlock.gif +0 -0
- data/template/resources/images/default/grid/hmenu-unlock.png +0 -0
- data/template/resources/images/default/grid/invalid_line.gif +0 -0
- data/template/resources/images/default/grid/loading.gif +0 -0
- data/template/resources/images/default/grid/mso-hd.gif +0 -0
- data/template/resources/images/default/grid/nowait.gif +0 -0
- data/template/resources/images/default/grid/page-first-disabled.gif +0 -0
- data/template/resources/images/default/grid/page-first.gif +0 -0
- data/template/resources/images/default/grid/page-last-disabled.gif +0 -0
- data/template/resources/images/default/grid/page-last.gif +0 -0
- data/template/resources/images/default/grid/page-next-disabled.gif +0 -0
- data/template/resources/images/default/grid/page-next.gif +0 -0
- data/template/resources/images/default/grid/page-prev-disabled.gif +0 -0
- data/template/resources/images/default/grid/page-prev.gif +0 -0
- data/template/resources/images/default/grid/pick-button.gif +0 -0
- data/template/resources/images/default/grid/refresh.gif +0 -0
- data/template/resources/images/default/grid/row-check-sprite.gif +0 -0
- data/template/resources/images/default/grid/row-expand-sprite.gif +0 -0
- data/template/resources/images/default/grid/row-over.gif +0 -0
- data/template/resources/images/default/grid/row-sel.gif +0 -0
- data/template/resources/images/default/grid/sort-hd.gif +0 -0
- data/template/resources/images/default/grid/sort_asc.gif +0 -0
- data/template/resources/images/default/grid/sort_desc.gif +0 -0
- data/template/resources/images/default/grid/wait.gif +0 -0
- data/template/resources/images/default/layout/collapse.gif +0 -0
- data/template/resources/images/default/layout/expand.gif +0 -0
- data/template/resources/images/default/layout/gradient-bg.gif +0 -0
- data/template/resources/images/default/layout/mini-bottom.gif +0 -0
- data/template/resources/images/default/layout/mini-left.gif +0 -0
- data/template/resources/images/default/layout/mini-right.gif +0 -0
- data/template/resources/images/default/layout/mini-top.gif +0 -0
- data/template/resources/images/default/layout/ns-collapse.gif +0 -0
- data/template/resources/images/default/layout/ns-expand.gif +0 -0
- data/template/resources/images/default/layout/panel-close.gif +0 -0
- data/template/resources/images/default/layout/panel-title-bg.gif +0 -0
- data/template/resources/images/default/layout/panel-title-light-bg.gif +0 -0
- data/template/resources/images/default/layout/stick.gif +0 -0
- data/template/resources/images/default/layout/stuck.gif +0 -0
- data/template/resources/images/default/layout/tab-close-on.gif +0 -0
- data/template/resources/images/default/layout/tab-close.gif +0 -0
- data/template/resources/images/default/menu/checked.gif +0 -0
- data/template/resources/images/default/menu/group-checked.gif +0 -0
- data/template/resources/images/default/menu/item-over.gif +0 -0
- data/template/resources/images/default/menu/menu-parent.gif +0 -0
- data/template/resources/images/default/menu/menu.gif +0 -0
- data/template/resources/images/default/menu/unchecked.gif +0 -0
- data/template/resources/images/default/panel/corners-sprite.gif +0 -0
- data/template/resources/images/default/panel/left-right.gif +0 -0
- data/template/resources/images/default/panel/light-hd.gif +0 -0
- data/template/resources/images/default/panel/tool-sprite-tpl.gif +0 -0
- data/template/resources/images/default/panel/tool-sprites.gif +0 -0
- data/template/resources/images/default/panel/tools-sprites-trans.gif +0 -0
- data/template/resources/images/default/panel/top-bottom.gif +0 -0
- data/template/resources/images/default/panel/top-bottom.png +0 -0
- data/template/resources/images/default/panel/white-corners-sprite.gif +0 -0
- data/template/resources/images/default/panel/white-left-right.gif +0 -0
- data/template/resources/images/default/panel/white-top-bottom.gif +0 -0
- data/template/resources/images/default/progress/progress-bg.gif +0 -0
- data/template/resources/images/default/qtip/bg.gif +0 -0
- data/template/resources/images/default/qtip/close.gif +0 -0
- data/template/resources/images/default/qtip/tip-anchor-sprite.gif +0 -0
- data/template/resources/images/default/qtip/tip-sprite.gif +0 -0
- data/template/resources/images/default/s.gif +0 -0
- data/template/resources/images/default/shadow-c.png +0 -0
- data/template/resources/images/default/shadow-lr.png +0 -0
- data/template/resources/images/default/shadow.png +0 -0
- data/template/resources/images/default/shared/blue-loading.gif +0 -0
- data/template/resources/images/default/shared/calendar.gif +0 -0
- data/template/resources/images/default/shared/glass-bg.gif +0 -0
- data/template/resources/images/default/shared/hd-sprite.gif +0 -0
- data/template/resources/images/default/shared/large-loading.gif +0 -0
- data/template/resources/images/default/shared/left-btn.gif +0 -0
- data/template/resources/images/default/shared/loading-balls.gif +0 -0
- data/template/resources/images/default/shared/right-btn.gif +0 -0
- data/template/resources/images/default/shared/warning.gif +0 -0
- data/template/resources/images/default/sizer/e-handle-dark.gif +0 -0
- data/template/resources/images/default/sizer/e-handle.gif +0 -0
- data/template/resources/images/default/sizer/ne-handle-dark.gif +0 -0
- data/template/resources/images/default/sizer/ne-handle.gif +0 -0
- data/template/resources/images/default/sizer/nw-handle-dark.gif +0 -0
- data/template/resources/images/default/sizer/nw-handle.gif +0 -0
- data/template/resources/images/default/sizer/s-handle-dark.gif +0 -0
- data/template/resources/images/default/sizer/s-handle.gif +0 -0
- data/template/resources/images/default/sizer/se-handle-dark.gif +0 -0
- data/template/resources/images/default/sizer/se-handle.gif +0 -0
- data/template/resources/images/default/sizer/square.gif +0 -0
- data/template/resources/images/default/sizer/sw-handle-dark.gif +0 -0
- data/template/resources/images/default/sizer/sw-handle.gif +0 -0
- data/template/resources/images/default/slider/slider-bg.png +0 -0
- data/template/resources/images/default/slider/slider-thumb.png +0 -0
- data/template/resources/images/default/slider/slider-v-bg.png +0 -0
- data/template/resources/images/default/slider/slider-v-thumb.png +0 -0
- data/template/resources/images/default/tabs/scroll-left.gif +0 -0
- data/template/resources/images/default/tabs/scroll-right.gif +0 -0
- data/template/resources/images/default/tabs/scroller-bg.gif +0 -0
- data/template/resources/images/default/tabs/tab-btm-inactive-left-bg.gif +0 -0
- data/template/resources/images/default/tabs/tab-btm-inactive-right-bg.gif +0 -0
- data/template/resources/images/default/tabs/tab-btm-left-bg.gif +0 -0
- data/template/resources/images/default/tabs/tab-btm-over-left-bg.gif +0 -0
- data/template/resources/images/default/tabs/tab-btm-over-right-bg.gif +0 -0
- data/template/resources/images/default/tabs/tab-btm-right-bg.gif +0 -0
- data/template/resources/images/default/tabs/tab-close.gif +0 -0
- data/template/resources/images/default/tabs/tab-strip-bg.gif +0 -0
- data/template/resources/images/default/tabs/tab-strip-bg.png +0 -0
- data/template/resources/images/default/tabs/tab-strip-btm-bg.gif +0 -0
- data/template/resources/images/default/tabs/tabs-sprite.gif +0 -0
- data/template/resources/images/default/toolbar/bg.gif +0 -0
- data/template/resources/images/default/toolbar/btn-arrow-light.gif +0 -0
- data/template/resources/images/default/toolbar/btn-arrow.gif +0 -0
- data/template/resources/images/default/toolbar/btn-over-bg.gif +0 -0
- data/template/resources/images/default/toolbar/gray-bg.gif +0 -0
- data/template/resources/images/default/toolbar/more.gif +0 -0
- data/template/resources/images/default/toolbar/tb-bg.gif +0 -0
- data/template/resources/images/default/toolbar/tb-btn-sprite.gif +0 -0
- data/template/resources/images/default/toolbar/tb-xl-btn-sprite.gif +0 -0
- data/template/resources/images/default/toolbar/tb-xl-sep.gif +0 -0
- data/template/resources/images/default/tree/arrows.gif +0 -0
- data/template/resources/images/default/tree/drop-add.gif +0 -0
- data/template/resources/images/default/tree/drop-between.gif +0 -0
- data/template/resources/images/default/tree/drop-no.gif +0 -0
- data/template/resources/images/default/tree/drop-over.gif +0 -0
- data/template/resources/images/default/tree/drop-under.gif +0 -0
- data/template/resources/images/default/tree/drop-yes.gif +0 -0
- data/template/resources/images/default/tree/elbow-end-minus-nl.gif +0 -0
- data/template/resources/images/default/tree/elbow-end-minus.gif +0 -0
- data/template/resources/images/default/tree/elbow-end-plus-nl.gif +0 -0
- data/template/resources/images/default/tree/elbow-end-plus.gif +0 -0
- data/template/resources/images/default/tree/elbow-end.gif +0 -0
- data/template/resources/images/default/tree/elbow-line.gif +0 -0
- data/template/resources/images/default/tree/elbow-minus-nl.gif +0 -0
- data/template/resources/images/default/tree/elbow-minus.gif +0 -0
- data/template/resources/images/default/tree/elbow-plus-nl.gif +0 -0
- data/template/resources/images/default/tree/elbow-plus.gif +0 -0
- data/template/resources/images/default/tree/elbow.gif +0 -0
- data/template/resources/images/default/tree/folder-open.gif +0 -0
- data/template/resources/images/default/tree/folder.gif +0 -0
- data/template/resources/images/default/tree/leaf.gif +0 -0
- data/template/resources/images/default/tree/loading.gif +0 -0
- data/template/resources/images/default/tree/s.gif +0 -0
- data/template/resources/images/default/window/icon-error.gif +0 -0
- data/template/resources/images/default/window/icon-info.gif +0 -0
- data/template/resources/images/default/window/icon-question.gif +0 -0
- data/template/resources/images/default/window/icon-warning.gif +0 -0
- data/template/resources/images/default/window/left-corners.png +0 -0
- data/template/resources/images/default/window/left-corners.psd +0 -0
- data/template/resources/images/default/window/left-right.png +0 -0
- data/template/resources/images/default/window/left-right.psd +0 -0
- data/template/resources/images/default/window/right-corners.png +0 -0
- data/template/resources/images/default/window/right-corners.psd +0 -0
- data/template/resources/images/default/window/top-bottom.png +0 -0
- data/template/resources/images/default/window/top-bottom.psd +0 -0
- data/template/resources/images/gray/button/btn-arrow.gif +0 -0
- data/template/resources/images/gray/button/btn-sprite.gif +0 -0
- data/template/resources/images/gray/button/btn.gif +0 -0
- data/template/resources/images/gray/button/group-cs.gif +0 -0
- data/template/resources/images/gray/button/group-lr.gif +0 -0
- data/template/resources/images/gray/button/group-tb.gif +0 -0
- data/template/resources/images/gray/button/s-arrow-bo.gif +0 -0
- data/template/resources/images/gray/button/s-arrow-o.gif +0 -0
- data/template/resources/images/gray/form/clear-trigger.gif +0 -0
- data/template/resources/images/gray/form/date-trigger.gif +0 -0
- data/template/resources/images/gray/form/search-trigger.gif +0 -0
- data/template/resources/images/gray/form/trigger-square.gif +0 -0
- data/template/resources/images/gray/form/trigger.gif +0 -0
- data/template/resources/images/gray/gradient-bg.gif +0 -0
- data/template/resources/images/gray/grid/col-move-bottom.gif +0 -0
- data/template/resources/images/gray/grid/col-move-top.gif +0 -0
- data/template/resources/images/gray/grid/grid3-hd-btn.gif +0 -0
- data/template/resources/images/gray/grid/grid3-hrow-over.gif +0 -0
- data/template/resources/images/gray/grid/grid3-hrow-over2.gif +0 -0
- data/template/resources/images/gray/grid/grid3-hrow.gif +0 -0
- data/template/resources/images/gray/grid/grid3-hrow2.gif +0 -0
- data/template/resources/images/gray/grid/grid3-special-col-bg.gif +0 -0
- data/template/resources/images/gray/grid/grid3-special-col-bg2.gif +0 -0
- data/template/resources/images/gray/grid/grid3-special-col-sel-bg.gif +0 -0
- data/template/resources/images/gray/grid/group-collapse.gif +0 -0
- data/template/resources/images/gray/grid/group-expand-sprite.gif +0 -0
- data/template/resources/images/gray/grid/group-expand.gif +0 -0
- data/template/resources/images/gray/grid/page-first.gif +0 -0
- data/template/resources/images/gray/grid/page-last.gif +0 -0
- data/template/resources/images/gray/grid/page-next.gif +0 -0
- data/template/resources/images/gray/grid/page-prev.gif +0 -0
- data/template/resources/images/gray/grid/refresh.gif +0 -0
- data/template/resources/images/gray/grid/row-expand-sprite.gif +0 -0
- data/template/resources/images/gray/grid/sort_asc.gif +0 -0
- data/template/resources/images/gray/grid/sort_desc.gif +0 -0
- data/template/resources/images/gray/menu/group-checked.gif +0 -0
- data/template/resources/images/gray/menu/item-over-disabled.gif +0 -0
- data/template/resources/images/gray/menu/item-over.gif +0 -0
- data/template/resources/images/gray/menu/menu-parent.gif +0 -0
- data/template/resources/images/gray/panel/corners-sprite.gif +0 -0
- data/template/resources/images/gray/panel/left-right.gif +0 -0
- data/template/resources/images/gray/panel/light-hd.gif +0 -0
- data/template/resources/images/gray/panel/tool-sprite-tpl.gif +0 -0
- data/template/resources/images/gray/panel/tool-sprites.gif +0 -0
- data/template/resources/images/gray/panel/tools-sprites-trans.gif +0 -0
- data/template/resources/images/gray/panel/top-bottom.gif +0 -0
- data/template/resources/images/gray/panel/top-bottom.png +0 -0
- data/template/resources/images/gray/panel/white-corners-sprite.gif +0 -0
- data/template/resources/images/gray/panel/white-left-right.gif +0 -0
- data/template/resources/images/gray/panel/white-top-bottom.gif +0 -0
- data/template/resources/images/gray/progress/progress-bg.gif +0 -0
- data/template/resources/images/gray/qtip/bg.gif +0 -0
- data/template/resources/images/gray/qtip/close.gif +0 -0
- data/template/resources/images/gray/qtip/tip-anchor-sprite.gif +0 -0
- data/template/resources/images/gray/qtip/tip-sprite.gif +0 -0
- data/template/resources/images/gray/s.gif +0 -0
- data/template/resources/images/gray/shared/hd-sprite.gif +0 -0
- data/template/resources/images/gray/shared/left-btn.gif +0 -0
- data/template/resources/images/gray/shared/right-btn.gif +0 -0
- data/template/resources/images/gray/sizer/e-handle.gif +0 -0
- data/template/resources/images/gray/sizer/ne-handle.gif +0 -0
- data/template/resources/images/gray/sizer/nw-handle.gif +0 -0
- data/template/resources/images/gray/sizer/s-handle.gif +0 -0
- data/template/resources/images/gray/sizer/se-handle.gif +0 -0
- data/template/resources/images/gray/sizer/square.gif +0 -0
- data/template/resources/images/gray/sizer/sw-handle.gif +0 -0
- data/template/resources/images/gray/slider/slider-thumb.png +0 -0
- data/template/resources/images/gray/slider/slider-v-thumb.png +0 -0
- data/template/resources/images/gray/tabs/scroll-left.gif +0 -0
- data/template/resources/images/gray/tabs/scroll-right.gif +0 -0
- data/template/resources/images/gray/tabs/scroller-bg.gif +0 -0
- data/template/resources/images/gray/tabs/tab-btm-inactive-left-bg.gif +0 -0
- data/template/resources/images/gray/tabs/tab-btm-inactive-right-bg.gif +0 -0
- data/template/resources/images/gray/tabs/tab-btm-left-bg.gif +0 -0
- data/template/resources/images/gray/tabs/tab-btm-over-left-bg.gif +0 -0
- data/template/resources/images/gray/tabs/tab-btm-over-right-bg.gif +0 -0
- data/template/resources/images/gray/tabs/tab-btm-right-bg.gif +0 -0
- data/template/resources/images/gray/tabs/tab-close.gif +0 -0
- data/template/resources/images/gray/tabs/tab-strip-bg.gif +0 -0
- data/template/resources/images/gray/tabs/tab-strip-bg.png +0 -0
- data/template/resources/images/gray/tabs/tab-strip-btm-bg.gif +0 -0
- data/template/resources/images/gray/tabs/tabs-sprite.gif +0 -0
- data/template/resources/images/gray/toolbar/bg.gif +0 -0
- data/template/resources/images/gray/toolbar/btn-arrow-light.gif +0 -0
- data/template/resources/images/gray/toolbar/btn-arrow.gif +0 -0
- data/template/resources/images/gray/toolbar/btn-over-bg.gif +0 -0
- data/template/resources/images/gray/toolbar/gray-bg.gif +0 -0
- data/template/resources/images/gray/toolbar/more.gif +0 -0
- data/template/resources/images/gray/toolbar/tb-bg.gif +0 -0
- data/template/resources/images/gray/toolbar/tb-btn-sprite.gif +0 -0
- data/template/resources/images/gray/tree/arrows.gif +0 -0
- data/template/resources/images/gray/tree/elbow-end-minus-nl.gif +0 -0
- data/template/resources/images/gray/tree/elbow-end-minus.gif +0 -0
- data/template/resources/images/gray/tree/elbow-end-plus-nl.gif +0 -0
- data/template/resources/images/gray/tree/elbow-end-plus.gif +0 -0
- data/template/resources/images/gray/window/icon-error.gif +0 -0
- data/template/resources/images/gray/window/icon-info.gif +0 -0
- data/template/resources/images/gray/window/icon-question.gif +0 -0
- data/template/resources/images/gray/window/icon-warning.gif +0 -0
- data/template/resources/images/gray/window/left-corners.png +0 -0
- data/template/resources/images/gray/window/left-corners.pspimage +0 -0
- data/template/resources/images/gray/window/left-right.png +0 -0
- data/template/resources/images/gray/window/right-corners.png +0 -0
- data/template/resources/images/gray/window/top-bottom.png +0 -0
- data/template/resources/inherited.gif +0 -0
- data/template/resources/method.gif +0 -0
- data/template/resources/pkg-closed.gif +0 -0
- data/template/resources/pkg-open.gif +0 -0
- data/template/resources/pkg.gif +0 -0
- data/template/resources/prop.gif +0 -0
- data/template/resources/s.gif +0 -0
- data/template/resources/static.gif +0 -0
- data/template/resources/style.css +0 -291
- 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
|
data/lib/jsduck/app.rb
CHANGED
@@ -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/
|
9
|
+
require 'jsduck/search_data'
|
9
10
|
require 'jsduck/relations'
|
10
|
-
require 'jsduck/
|
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
|
-
@
|
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) {
|
117
|
+
@timer.time(:generating) { write_classes(@output_dir+"/output", relations) }
|
64
118
|
else
|
65
|
-
|
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) {
|
69
|
-
@timer.time(:generating) {
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
[:
|
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
|
-
|
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
|
-
[:
|
131
|
-
|
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
|
-
|
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
|
155
|
-
|
156
|
-
js = "Docs.
|
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
|
161
|
-
|
162
|
-
|
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] + ".
|
183
|
-
|
184
|
-
|
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
|
-
|
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
|
-
|
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
|