Commit 8f76c3f7 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Write all docs app data to one date.js file.

Instead of tree.js and searchData.js there now is just data.js.
All the data in there will be in Docs.data namespace:

- classes
- icons
- guides
- videos
- search
parent f161aa8b
Loading
Loading
Loading
Loading
+11 −17
Original line number Diff line number Diff line
@@ -80,8 +80,7 @@ module JsDuck
        end
        create_index_html
        @timer.time(:generating) { write_src(parsed_files) }
        @timer.time(:generating) { write_tree }
        @timer.time(:generating) { write_search_data }
        @timer.time(:generating) { write_app_data }
        @timer.time(:generating) { write_classes }
        @timer.time(:generating) { @guides.write(@opts.output_dir+"/guides") }
        @timer.time(:generating) { @videos.write(@opts.output_dir+"/videos") }
@@ -129,23 +128,18 @@ module JsDuck
      Relations.new(classes, @opts.external_classes)
    end

    # Writes classes tree, icons map, and guides tree to tree.js
    def write_tree
    # Writes classes, guides, videos, and search data to one big .js file
    def write_app_data
      tree = Tree.new.create(@relations.classes)
      icons = TreeIcons.new.extract_icons(tree)
      js = "Docs.classData = " + JsonDuck.generate( tree ) + ";"
      js += "Docs.icons = " + JsonDuck.generate( icons ) + ";"
      js += "Docs.guides = " + JsonDuck.generate( @guides.to_array ) + ";"
      js += "Docs.videos = " + JsonDuck.generate( @videos.to_array ) + ";"
      File.open(@opts.output_dir+"/output/tree.js", 'w') {|f| f.write(js) }
    end

    # Given all classes, generates members data for search and writes in
    # in JSON form into a file.
    def write_search_data
      search_data = SearchData.new.create(@relations.classes)
      js = "Docs.searchData = " + JsonDuck.generate( {:data => search_data} ) + ";"
      File.open(@opts.output_dir+"/output/searchData.js", 'w') {|f| f.write(js) }
      js = "Docs.data = " + JsonDuck.generate({
        :classes => tree,
        :icons => icons,
        :guides => @guides.to_array,
        :videos => @videos.to_array,
        :search => SearchData.new.create(@relations.classes),
      }) + ";\n"
      File.open(@opts.output_dir+"/data.js", 'w') {|f| f.write(js) }
    end

    # Writes JSON export or JsonP file for each class
+1 −1
Original line number Diff line number Diff line
@@ -162,7 +162,7 @@ Ext.define('Docs.controller.Search', {
        var reBeg = new RegExp("^" + safeText, "i");
        var reMid = new RegExp(safeText, "i");

        Ext.Array.forEach(Docs.searchData.data, function(r) {
        Ext.Array.forEach(Docs.data.search, function(r) {
            // when search text has "." in it, search from the full name (e.g. "Ext.Component.focus")
            // Otherwise search from just the member name (e.g. "focus" or "Component")
            var name = hasDot ? r.cls + (r.type === "cls" ? "" : "." + r.member) : r.member;
+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ Ext.define('Docs.controller.Videos', {

    videoIds: function() {
        if (!this._videoIds) {
            this._videoIds = Ext.Array.flatten(Ext.Array.map(Docs.videos, function(v) { return Ext.Array.map(v.videos, function(w) { return w.id; }); }));
            this._videoIds = Ext.Array.flatten(Ext.Array.map(Docs.data.videos, function(v) { return Ext.Array.map(v.videos, function(w) { return w.id; }); }));
        }
        return this._videoIds;
    }
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ Ext.define('Docs.view.FavoritesPanel', {
                title: 'Favorites',
                iconCls: 'icon-fav',
                store: Ext.getStore('Favorites'),
                icons: Docs.icons
                icons: Docs.data.icons
            }
        ];

+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ Ext.define('Docs.view.Viewport', {
                        items: [
                            {
                                xtype: 'classtree',
                                root: Docs.classData
                                root: Docs.data.classes
                            },
                            {
                                xtype: 'examplestree'
Loading