Commit 7986087b authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Inital loading of documentation through JSON.

JSDuck now export JSON even in normal mode (without --json option).

When class name clicked in tree, the JSON is loaded and class
documentation displayd.  Currently we only show doc-comment of
the class.

Also turned off use of history.pushState - bringing it back in the
future.
parent 90a3f83f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ module JsDuck
        @timer.time(:generating) { write_src(@output_dir+"/source", parsed_files) }
        @timer.time(:generating) { write_tree(@output_dir+"/output/tree.js", relations) }
        @timer.time(:generating) { write_members(@output_dir+"/output/members.js", relations) }
        @timer.time(:generating) { write_pages(@output_dir+"/output", relations) }
        @timer.time(:generating) { write_json(@output_dir+"/output", relations) }
      end

      @timer.report if @verbose
+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@
  <script type="text/javascript" src="js/functions.js"></script>

  <script type="text/javascript" src="js/ClassTree.js"></script>
  <script type="text/javascript" src="js/OverviewPanel.js"></script>
  <script type="text/javascript" src="js/OverviewToolbar.js"></script>
  <script type="text/javascript" src="js/ClassPanel.js"></script>
  <script type="text/javascript" src="js/SourceCodePanel.js"></script>
+0 −6
Original line number Diff line number Diff line
@@ -23,14 +23,8 @@ Ext.define('Docs.ClassPanel', {
    },

    initComponent: function() {

        this.height = Ext.get('docContent').getHeight() - 55;
        this.items = [ Ext.create('Docs.OverviewPanel') ];

        if (!req.standAloneMode) {
            this.items.push(Ext.create('Docs.SourceCodePanel'));
        }

        this.callParent(arguments);
    }
});
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ Ext.define('Docs.ClassTree', {

    listeners: {
        itemclick: function(view, node) {
            var clsName = node.raw ? node.raw.clsName : node.data.clsName;
            var clsName = node.raw ? node.raw.id : node.data.id;

            if (clsName) {
                getDocClass(clsName);
+19 −33
Original line number Diff line number Diff line
@@ -26,24 +26,13 @@ var getDocClass = function(cls, noHistory) {
        cls = cls.substr(0, hashIdx);
    }

    if (req.standAloneMode) {
        if (window.location.href.match(/api/)) {
            window.location = cls + '.html';
        } else if (window.location.href.match(/guide/)){
            window.location = '../api/' + cls + '.html';
        } else {
            window.location = 'api/' + cls + '.html';
        }
        return;
    }

    var fullUrl = req.baseDocURL + "/api/" + cls;
    if (!noHistory && window.history && window.history.pushState) {
        window.history.pushState({
            docClass: cls
        },
        '', fullUrl);
    }
    // if (!noHistory && window.history && window.history.pushState) {
    //     var fullUrl = req.baseDocURL + "/" + cls;
    //     window.history.pushState({
    //         docClass: cls
    //     },
    //     '', fullUrl);
    // }

    var docTabPanel = Ext.getCmp('docTabPanel');
    if (docTabPanel) {
@@ -57,12 +46,12 @@ var getDocClass = function(cls, noHistory) {
            Ext.getCmp('doc-overview').setLoading(true);
        }

        Ext.data.JsonP.request({
            callbackKey: 'docsCallback',
            url     : req.baseDocURL + '/api/' + cls + '/ajax',
        Ext.Ajax.request({
            url: req.baseDocURL + '/output/' + cls + '.json',
            success: function(response, opts) {
                classCache[response.cls] = response;
                showClass(response, member);
                var json = Ext.JSON.decode(response.responseText);
                classCache[cls] = json;
                showClass(json, member);
            },
            failure : function(response, opts) {
              console.log('Fail');
@@ -71,13 +60,10 @@ var getDocClass = function(cls, noHistory) {
    }
};

var showClass = function(resp, anchor) {
    var docTabPanel = Ext.getCmp('docTabPanel');

    clsInfo = resp.clsInfo;
    req.docClass = resp.cls;
    req.source = resp.source;
var showClass = function(cls, anchor) {
    window.clsInfo = cls;

    var docTabPanel = Ext.getCmp('docTabPanel');
    if (!docTabPanel) {
         Ext.get('docContent').update('');
         Ext.create('Docs.ClassPanel');
@@ -91,14 +77,14 @@ var showClass = function(resp, anchor) {

    var docOverviewTab = Ext.getCmp('doc-overview');

    docOverviewTab.update(resp.content);
    docOverviewTab.update(cls.doc);
    docOverviewTab.removeDocked(Ext.getCmp('overview-toolbar'), true);
    docOverviewTab.addDocked(Ext.create('Docs.OverviewToolbar'));
    docOverviewTab.setLoading(false);

    prettyPrint();

    Ext.get('top-block').update(resp.title);
    Ext.get(Ext.DomQuery.selectNode('#top-block > h1')).update(cls.name);
    if (anchor) {
        Ext.getCmp('doc-overview').scrollToEl("a[name=" + anchor + "]");
    } else {