OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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. |
11 * 2) A file located at SCHEMA which is shared with the extension system and | 11 * 2) A file located at SCHEMA which is shared with the extension system and |
12 * defines the methods and events contained in one api. | 12 * defines the methods and events contained in one api. |
13 * 3) (Possibly) A static version of the current page url in /static/. I.e. | 13 * 3) (Possibly) A static version of the current page url in /static/. I.e. |
14 * if called as ../foo.html, it will look for ../static/foo.html. | 14 * if called as ../foo.html, it will look for ../static/foo.html. |
15 * | 15 * |
16 * The "shell" page may have a renderering already contained within it so that | 16 * The "shell" page may have a renderering already contained within it so that |
17 * the docs can be indexed. | 17 * the docs can be indexed. |
18 * | 18 * |
19 */ | 19 */ |
20 | 20 |
21 var API_TEMPLATE = 'template/api_template.html'; | 21 var API_TEMPLATE = 'template/api_template.html'; |
22 var SCHEMA = '../api/extension_api.json'; | 22 var SCHEMA = '../api/extension_api.json'; |
| 23 var MODULE_SCHEMAS = ['../api/extension.json']; |
23 var DEVTOOLS_SCHEMA = '../api/devtools_api.json'; | 24 var DEVTOOLS_SCHEMA = '../api/devtools_api.json'; |
24 var USE_DEVTOOLS_SCHEMA = | 25 var USE_DEVTOOLS_SCHEMA = |
25 /\.devtools[^/]*\.html/.test(location.pathname); | 26 /\.devtools[^/]*\.html/.test(location.pathname); |
26 var API_MODULE_PREFIX = 'chrome.'; | 27 var API_MODULE_PREFIX = 'chrome.'; |
27 var SAMPLES = 'samples.json'; | 28 var SAMPLES = 'samples.json'; |
28 var REQUEST_TIMEOUT = 2000; | 29 var REQUEST_TIMEOUT = 2000; |
29 | 30 |
30 function staticResource(name) { return 'static/' + name + '.html'; } | 31 function staticResource(name) { return 'static/' + name + '.html'; } |
31 | 32 |
32 // Base name of this page. (i.e. 'tabs', 'overview', etc...). | 33 // Base name of this page. (i.e. 'tabs', 'overview', etc...). |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 fetchSchema(); | 110 fetchSchema(); |
110 }); | 111 }); |
111 } | 112 } |
112 | 113 |
113 function fetchSchema() { | 114 function fetchSchema() { |
114 // Now the page is composed with the authored content, we fetch the schema | 115 // Now the page is composed with the authored content, we fetch the schema |
115 // and populate the templates. | 116 // and populate the templates. |
116 var is_experimental_index = /\/experimental\.html$/.test(location.pathname); | 117 var is_experimental_index = /\/experimental\.html$/.test(location.pathname); |
117 | 118 |
118 var schemas_to_retrieve = []; | 119 var schemas_to_retrieve = []; |
119 if (!USE_DEVTOOLS_SCHEMA || is_experimental_index) | 120 if (!USE_DEVTOOLS_SCHEMA || is_experimental_index) { |
120 schemas_to_retrieve.push(SCHEMA); | 121 schemas_to_retrieve.push(SCHEMA); |
| 122 schemas_to_retrieve = schemas_to_retrieve.concat(MODULE_SCHEMAS); |
| 123 } |
121 if (USE_DEVTOOLS_SCHEMA || is_experimental_index) | 124 if (USE_DEVTOOLS_SCHEMA || is_experimental_index) |
122 schemas_to_retrieve.push(DEVTOOLS_SCHEMA); | 125 schemas_to_retrieve.push(DEVTOOLS_SCHEMA); |
123 | 126 |
124 var schemas_retrieved = 0; | 127 var schemas_retrieved = 0; |
125 schema = []; | 128 schema = []; |
126 | 129 |
127 function onSchemaContent(content) { | 130 function onSchemaContent(content) { |
128 schema = schema.concat(JSON.parse(content)); | 131 schema = schema.concat(JSON.parse(content)); |
129 if (++schemas_retrieved < schemas_to_retrieve.length) | 132 if (++schemas_retrieved < schemas_to_retrieve.length) |
130 return; | 133 return; |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 | 576 |
574 function sortByName(a, b) { | 577 function sortByName(a, b) { |
575 if (a.name < b.name) { | 578 if (a.name < b.name) { |
576 return -1; | 579 return -1; |
577 } | 580 } |
578 if (a.name > b.name) { | 581 if (a.name > b.name) { |
579 return 1; | 582 return 1; |
580 } | 583 } |
581 return 0; | 584 return 0; |
582 } | 585 } |
OLD | NEW |