OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview This file is the controller for generating extension | 6 * @fileoverview This file is the controller for generating extension |
7 * doc pages. | 7 * doc pages. |
8 * | 8 * |
9 * It expects to have available via XHR (relative path): | 9 * It expects to have available via XHR (relative path): |
10 * 1) API_TEMPLATE which is the main template for the api pages. | 10 * 1) API_TEMPLATE which is the main template for the api pages. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 var schemas_to_retrieve = []; | 176 var schemas_to_retrieve = []; |
177 if (!USE_DEVTOOLS_SCHEMA || is_experimental_index) | 177 if (!USE_DEVTOOLS_SCHEMA || is_experimental_index) |
178 schemas_to_retrieve = schemas_to_retrieve.concat(MODULE_SCHEMAS); | 178 schemas_to_retrieve = schemas_to_retrieve.concat(MODULE_SCHEMAS); |
179 if (USE_DEVTOOLS_SCHEMA || is_experimental_index) | 179 if (USE_DEVTOOLS_SCHEMA || is_experimental_index) |
180 schemas_to_retrieve.push(DEVTOOLS_SCHEMA); | 180 schemas_to_retrieve.push(DEVTOOLS_SCHEMA); |
181 | 181 |
182 var schemas_retrieved = 0; | 182 var schemas_retrieved = 0; |
183 schema = []; | 183 schema = []; |
184 | 184 |
185 function onSchemaContent(content) { | 185 function onSchemaContent(content) { |
186 schema = schema.concat(JSON.parse(content)); | 186 schema = schema.concat(JSON.parse(JSON.minify(content))); |
187 if (++schemas_retrieved < schemas_to_retrieve.length) | 187 if (++schemas_retrieved < schemas_to_retrieve.length) |
188 return; | 188 return; |
189 if (pageName.toLowerCase() == 'samples') { | 189 if (pageName.toLowerCase() == 'samples') { |
190 fetchSamples(); | 190 fetchSamples(); |
191 } else { | 191 } else { |
192 renderTemplate(); | 192 renderTemplate(); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 for (var i = 0; i < schemas_to_retrieve.length; ++i) { | 196 for (var i = 0; i < schemas_to_retrieve.length; ++i) { |
197 var schema_path = schemas_to_retrieve[i]; | 197 var schema_path = schemas_to_retrieve[i]; |
198 fetchContent(schema_path, onSchemaContent, function(error) { | 198 fetchContent(schema_path, onSchemaContent, function(error) { |
199 alert('Failed to load ' + schema_path); | 199 alert('Failed to load ' + schema_path); |
200 }); | 200 }); |
201 } | 201 } |
202 } | 202 } |
203 | 203 |
204 function fetchSamples() { | 204 function fetchSamples() { |
205 // If we're rendering the samples directory, fetch the samples manifest. | 205 // If we're rendering the samples directory, fetch the samples manifest. |
206 fetchContent(SAMPLES, function(sampleManifest) { | 206 fetchContent(SAMPLES, function(sampleManifest) { |
207 var data = JSON.parse(sampleManifest); | 207 var data = JSON.parse(JSON.minify(sampleManifest)); |
208 samples = data.samples; | 208 samples = data.samples; |
209 apiMapping = data.api; | 209 apiMapping = data.api; |
210 renderTemplate(); | 210 renderTemplate(); |
211 }, function(error) { | 211 }, function(error) { |
212 renderTemplate(); | 212 renderTemplate(); |
213 }); | 213 }); |
214 } | 214 } |
215 | 215 |
216 /** | 216 /** |
217 * Fetches |url| and returns it's text contents from the xhr.responseText in | 217 * Fetches |url| and returns it's text contents from the xhr.responseText in |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 } | 670 } |
671 if (a.name > b.name) { | 671 if (a.name > b.name) { |
672 return 1; | 672 return 1; |
673 } | 673 } |
674 return 0; | 674 return 0; |
675 } | 675 } |
676 | 676 |
677 function disableDocs(obj) { | 677 function disableDocs(obj) { |
678 return !!obj.nodoc || !!obj.internal; | 678 return !!obj.nodoc || !!obj.internal; |
679 } | 679 } |
OLD | NEW |