Commit cdd6982e authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Included documentation browser UI template.

The source comes from official ExtJS documentation (included in
ExtJS release package).  This includes the minified version of
ExtJS 3.3.1 with gray style.

The original ext-3.3.1/docs/resouces contained a lot of unused
CSS and image files - these were all excluded as unnecessary crap.

JsDuck now includes --template command-line-option to specify
alternate template to use.  By default the template/ dir included
with jsduck will be used.
parent badc6fa2
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -74,11 +74,21 @@ module JsDuck
      File.open(filename, 'w') {|f| f.write( Page.new(cls).to_html ) }
    end
  end

  def self.copy_template(template_dir, dir, verbose)
    puts "Copying template files to #{dir}..." if verbose
    if File.exists?(dir)
      FileUtils.rm_r(dir)
    end
    FileUtils.cp_r(template_dir, dir)
    FileUtils.mkdir(dir + "/output")
  end
end


if __FILE__ == $0 then
  output_dir = nil
  template_dir = File.dirname(File.dirname(__FILE__)) + "/template"
  verbose = false

  opts = OptionParser.new do | opts |
@@ -88,6 +98,10 @@ if __FILE__ == $0 then
      output_dir = path
    end

    opts.on('-t', '--template=PATH', "Directory containing doc-browser UI template.") do |path|
      template_dir = path
    end

    opts.on('-v', '--verbose', "This will fill up your console.") do
      verbose = true
    end
@@ -106,16 +120,17 @@ if __FILE__ == $0 then
  elsif !output_dir
    puts "You should also specify an output directory, where I could write all this amazing documentation."
    exit(1)
  elsif !File.exists?(output_dir)
    puts "Output directory doesn't exist.  I'll take the pride of creating it..."
    FileUtils.mkdir(output_dir)
  elsif !File.directory?(output_dir)
  elsif File.exists?(output_dir) && !File.directory?(output_dir)
    puts "Oh noes!  The output directory is not really a directory at all :("
    exit(1)
  elsif !File.exists?(File.dirname(output_dir))
    puts "Oh noes!  The parent directory for #{output_dir} doesn't exist."
    exit(1)
  end

  classes = JsDuck.filter_classes(JsDuck.parse_files(input_files, verbose))
  JsDuck.write_tree(output_dir+"/tree.js", classes)
  JsDuck.write_pages(output_dir, classes, verbose)
  JsDuck.copy_template(template_dir, output_dir, verbose)
  JsDuck.write_tree(output_dir+"/output/tree.js", classes)
  JsDuck.write_pages(output_dir+"/output", classes, verbose)
end

template/index.html

0 → 100644
+48 −0
Original line number Diff line number Diff line
<html lang="en" xmlns:ext="http://www.sencha.com/docs">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>JsDuck Generated Documentation</title>

<link rel="stylesheet" type="text/css" href="resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="resources/css/xtheme-gray.css" />
<link rel="stylesheet" type="text/css" href="resources/docs.css" />
<link rel="stylesheet" type="text/css" href="resources/style.css" />
<link rel="shortcut icon" href="resources/favicon.ico" />
<link rel="icon" href="resources/favicon.ico" />
<style type="text/css"></style>
<!-- GC -->
<script type="text/javascript" src="resources/ext-base.js"></script>
<script type="text/javascript" src="resources/ext-all.js"></script>
<script type="text/javascript" src="resources/TabCloseMenu.js"></script>
<script type="text/javascript" src="resources/docs.js"></script>
<script type="text/javascript" src="output/tree.js"></script>
</head>
<body scroll="no" id="docs">
<div id="loading-mask"></div>
<div id="loading">
    <div class="loading-indicator">
        <img src="resources/extanim32.gif" width="32" height="32" style="margin-right:8px;" align="absmiddle" />
        Loading&hellip;
    </div>
</div>

<div id="header">
    <img style="margin-left: 5px" src="resources/title-ext.png" alt="Ext JS API Documentation" height="49" width="380" />
    <div style="float:right; margin-top: 15px;margin-right: 10px;color: #CCC">
        <a href="http://dev.sencha.com/deploy/dev/examples/" style="padding:5px">examples</a> |
        <a href="http://www.sencha.com/" style="padding:5px">sencha.com</a>
    </div>
</div>

<div id="classes"></div>

<div id="main"></div>

<select id="search-options" style="display:none">
    <option>Starts with</option>
    <option>Ends with</option>
    <option>Any Match</option>
</select>
</body>
</html>
+150 −0
Original line number Diff line number Diff line
/*!
 * Ext JS Library 3.2.1
 * Copyright(c) 2006-2010 Ext JS, Inc.
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
/**
 * @class Ext.ux.TabCloseMenu
 * @extends Object 
 * Plugin (ptype = 'tabclosemenu') for adding a close context menu to tabs. Note that the menu respects
 * the closable configuration on the tab. As such, commands like remove others and remove all will not
 * remove items that are not closable.
 * 
 * @constructor
 * @param {Object} config The configuration options
 * @ptype tabclosemenu
 */
Ext.ux.TabCloseMenu = Ext.extend(Object, {
    /**
     * @cfg {String} closeTabText
     * The text for closing the current tab. Defaults to <tt>'Close Tab'</tt>.
     */
    closeTabText: 'Close Tab',

    /**
     * @cfg {String} closeOtherTabsText
     * The text for closing all tabs except the current one. Defaults to <tt>'Close Other Tabs'</tt>.
     */
    closeOtherTabsText: 'Close Other Tabs',
    
    /**
     * @cfg {Boolean} showCloseAll
     * Indicates whether to show the 'Close All' option. Defaults to <tt>true</tt>. 
     */
    showCloseAll: true,

    /**
     * @cfg {String} closeAllTabsText
     * <p>The text for closing all tabs. Defaults to <tt>'Close All Tabs'</tt>.
     */
    closeAllTabsText: 'Close All Tabs',
    
    constructor : function(config){
        Ext.apply(this, config || {});
    },

    //public
    init : function(tabs){
        this.tabs = tabs;
        tabs.on({
            scope: this,
            contextmenu: this.onContextMenu,
            destroy: this.destroy
        });
    },
    
    destroy : function(){
        Ext.destroy(this.menu);
        delete this.menu;
        delete this.tabs;
        delete this.active;    
    },

    // private
    onContextMenu : function(tabs, item, e){
        this.active = item;
        var m = this.createMenu(),
            disableAll = true,
            disableOthers = true,
            closeAll = m.getComponent('closeall');
        
        m.getComponent('close').setDisabled(!item.closable);
        tabs.items.each(function(){
            if(this.closable){
                disableAll = false;
                if(this != item){
                    disableOthers = false;
                    return false;
                }
            }
        });
        m.getComponent('closeothers').setDisabled(disableOthers);
        if(closeAll){
            closeAll.setDisabled(disableAll);
        }
        
        e.stopEvent();
        m.showAt(e.getPoint());
    },
    
    createMenu : function(){
        if(!this.menu){
            var items = [{
                itemId: 'close',
                text: this.closeTabText,
                scope: this,
                handler: this.onClose
            }];
            if(this.showCloseAll){
                items.push('-');
            }
            items.push({
                itemId: 'closeothers',
                text: this.closeOtherTabsText,
                scope: this,
                handler: this.onCloseOthers
            });
            if(this.showCloseAll){
                items.push({
                    itemId: 'closeall',
                    text: this.closeAllTabsText,
                    scope: this,
                    handler: this.onCloseAll
                });
            }
            this.menu = new Ext.menu.Menu({
                items: items
            });
        }
        return this.menu;
    },
    
    onClose : function(){
        this.tabs.remove(this.active);
    },
    
    onCloseOthers : function(){
        this.doClose(true);
    },
    
    onCloseAll : function(){
        this.doClose(false);
    },
    
    doClose : function(excludeActive){
        var items = [];
        this.tabs.items.each(function(item){
            if(item.closable){
                if(!excludeActive || item != this.active){
                    items.push(item);
                }    
            }
        }, this);
        Ext.each(items, function(item){
            this.tabs.remove(item);
        }, this);
    }
});

Ext.preg('tabclosemenu', Ext.ux.TabCloseMenu);
 No newline at end of file
+3.06 KiB
Loading image diff...
+915 B
Loading image diff...
Loading