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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 var schemas_to_retrieve = []; | 179 var schemas_to_retrieve = []; |
180 if (!USE_DEVTOOLS_SCHEMA || is_experimental_index) | 180 if (!USE_DEVTOOLS_SCHEMA || is_experimental_index) |
181 schemas_to_retrieve = schemas_to_retrieve.concat(MODULE_SCHEMAS); | 181 schemas_to_retrieve = schemas_to_retrieve.concat(MODULE_SCHEMAS); |
182 if (USE_DEVTOOLS_SCHEMA || is_experimental_index) | 182 if (USE_DEVTOOLS_SCHEMA || is_experimental_index) |
183 schemas_to_retrieve.push(DEVTOOLS_SCHEMA); | 183 schemas_to_retrieve.push(DEVTOOLS_SCHEMA); |
184 | 184 |
185 var schemas_retrieved = 0; | 185 var schemas_retrieved = 0; |
186 schema = []; | 186 schema = []; |
187 | 187 |
188 function onSchemaContent(content) { | 188 function onSchemaContent(content) { |
189 schema = schema.concat(JSON.parse(JSON.minify(content))); | 189 if (content) |
| 190 schema = schema.concat(JSON.parse(JSON.minify(content))); |
190 if (++schemas_retrieved < schemas_to_retrieve.length) | 191 if (++schemas_retrieved < schemas_to_retrieve.length) |
191 return; | 192 return; |
192 if (pageName.toLowerCase() == 'samples') { | 193 if (pageName.toLowerCase() == 'samples') { |
193 fetchSamples(); | 194 fetchSamples(); |
194 } else { | 195 } else { |
195 renderTemplate(); | 196 renderTemplate(); |
196 } | 197 } |
197 } | 198 } |
198 | 199 |
199 for (var i = 0; i < schemas_to_retrieve.length; ++i) { | 200 for (var i = 0; i < schemas_to_retrieve.length; ++i) { |
200 var schema_path = schemas_to_retrieve[i]; | 201 var schema_path = schemas_to_retrieve[i]; |
201 fetchContent(schema_path, onSchemaContent, function(error) { | 202 fetchContent(schema_path, onSchemaContent, function(error) { |
202 alert('Failed to load ' + schema_path); | 203 onSchemaContent(""); |
203 }); | 204 }); |
204 } | 205 } |
205 } | 206 } |
206 | 207 |
207 function fetchSamples() { | 208 function fetchSamples() { |
208 // If we're rendering the samples directory, fetch the samples manifest. | 209 // If we're rendering the samples directory, fetch the samples manifest. |
209 fetchContent(SAMPLES, function(sampleManifest) { | 210 fetchContent(SAMPLES, function(sampleManifest) { |
210 var data = JSON.parse(JSON.minify(sampleManifest)); | 211 var data = JSON.parse(JSON.minify(sampleManifest)); |
211 samples = data.samples; | 212 samples = data.samples; |
212 apiMapping = data.api; | 213 apiMapping = data.api; |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 } | 694 } |
694 if (a.name > b.name) { | 695 if (a.name > b.name) { |
695 return 1; | 696 return 1; |
696 } | 697 } |
697 return 0; | 698 return 0; |
698 } | 699 } |
699 | 700 |
700 function disableDocs(obj) { | 701 function disableDocs(obj) { |
701 return !!obj.nodoc || !!obj.internal; | 702 return !!obj.nodoc || !!obj.internal; |
702 } | 703 } |
OLD | NEW |