Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(784)

Side by Side Diff: chrome/common/extensions/docs/js/api_page_generator.js

Issue 10797039: Extensions Docs Server: devtools API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move parsing logic into utils Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 16 matching lines...) Expand all
27 '../../api/browser_action.json', 27 '../../api/browser_action.json',
28 '../../api/browsing_data.json', 28 '../../api/browsing_data.json',
29 '../../api/chrome_auth_private.json', 29 '../../api/chrome_auth_private.json',
30 '../../api/chromeos_info_private.json', 30 '../../api/chromeos_info_private.json',
31 '../../api/content_settings.json', 31 '../../api/content_settings.json',
32 '../../api/context_menus.json', 32 '../../api/context_menus.json',
33 '../../api/cookies.json', 33 '../../api/cookies.json',
34 '../../api/debugger.json', 34 '../../api/debugger.json',
35 '../../api/declarative_web_request.json', 35 '../../api/declarative_web_request.json',
36 '../../api/devtools.json', 36 '../../api/devtools.json',
37 '../../api/devtools/experimental_audits.json',
38 '../../api/devtools/experimental_console.json',
39 '../../api/devtools/inspected_window.json',
40 '../../api/devtools/network.json',
41 '../../api/devtools/panels.json',
37 '../../api/downloads.json', // autogenerated 42 '../../api/downloads.json', // autogenerated
38 '../../api/events.json', 43 '../../api/events.json',
39 '../../api/experimental_accessibility.json', 44 '../../api/experimental_accessibility.json',
40 '../../api/experimental_app.json', 45 '../../api/experimental_app.json',
41 '../../api/experimental_bluetooth.json', // autogenerated 46 '../../api/experimental_bluetooth.json', // autogenerated
42 '../../api/experimental_bookmark_manager.json', 47 '../../api/experimental_bookmark_manager.json',
43 '../../api/experimental_commands.json', 48 '../../api/experimental_commands.json',
44 '../../api/experimental_discovery.json', // autogenerated 49 '../../api/experimental_discovery.json', // autogenerated
45 '../../api/experimental_identity.json', // autogenerated 50 '../../api/experimental_identity.json', // autogenerated
46 '../../api/experimental_infobars.json', 51 '../../api/experimental_infobars.json',
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 '../../api/types.json', 92 '../../api/types.json',
88 '../../api/wallpaper_private.json', 93 '../../api/wallpaper_private.json',
89 '../../api/web_navigation.json', 94 '../../api/web_navigation.json',
90 '../../api/web_request.json', 95 '../../api/web_request.json',
91 '../../api/web_socket_proxy_private.json', 96 '../../api/web_socket_proxy_private.json',
92 '../../api/webstore.json', 97 '../../api/webstore.json',
93 '../../api/webstore_private.json', 98 '../../api/webstore_private.json',
94 '../../api/windows.json', 99 '../../api/windows.json',
95 ] 100 ]
96 var PERMISSION_FEATURES = '../../api/_permission_features.json'; 101 var PERMISSION_FEATURES = '../../api/_permission_features.json';
97 var DEVTOOLS_SCHEMA = '../../api/devtools_api.json';
98 var USE_DEVTOOLS_SCHEMA =
99 /devtools[^/]*\.html/.test(location.pathname);
100 var API_MODULE_PREFIX = 'chrome.'; 102 var API_MODULE_PREFIX = 'chrome.';
101 var SAMPLES = '../samples.json'; 103 var SAMPLES = '../samples.json';
102 var REQUEST_TIMEOUT = 2000; 104 var REQUEST_TIMEOUT = 2000;
103 105
104 function staticResource(name) { return '../static/' + name + '.html'; } 106 function staticResource(name) { return '../static/' + name + '.html'; }
105 107
106 // Base name of this page. (i.e. 'tabs', 'overview', etc...). 108 // Base name of this page. (i.e. 'tabs', 'overview', etc...).
107 var pageBase; 109 var pageBase;
108 110
109 // Data to feed as context into the template. 111 // Data to feed as context into the template.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 }, function(error) { 210 }, function(error) {
209 alert('Failed to load ' + PERMISSION_FEATURES + '. ' + error); 211 alert('Failed to load ' + PERMISSION_FEATURES + '. ' + error);
210 }); 212 });
211 } 213 }
212 214
213 function fetchSchema() { 215 function fetchSchema() {
214 // Now the page is composed with the authored content, we fetch the schema 216 // Now the page is composed with the authored content, we fetch the schema
215 // and populate the templates. 217 // and populate the templates.
216 var is_experimental_index = /\/experimental\.html$/.test(location.pathname); 218 var is_experimental_index = /\/experimental\.html$/.test(location.pathname);
217 219
218 var schemas_to_retrieve = []; 220 var schemas_to_retrieve = MODULE_SCHEMAS;
219 if (!USE_DEVTOOLS_SCHEMA || is_experimental_index)
220 schemas_to_retrieve = schemas_to_retrieve.concat(MODULE_SCHEMAS);
221 if (USE_DEVTOOLS_SCHEMA || is_experimental_index)
222 schemas_to_retrieve.push(DEVTOOLS_SCHEMA);
223
224 var schemas_retrieved = 0; 221 var schemas_retrieved = 0;
225 schema = []; 222 schema = [];
226 223
227 function qualifyRefs(namespace, obj) { 224 function qualifyRefs(namespace, obj) {
228 if (typeof(obj) == "object") { 225 if (typeof(obj) == "object") {
229 for (var i in obj) { 226 for (var i in obj) {
230 if (typeof(obj[i]) == "object") { 227 if (typeof(obj[i]) == "object") {
231 obj[i] = qualifyRefs(namespace, obj[i]); 228 obj[i] = qualifyRefs(namespace, obj[i]);
232 } else if (i == "$ref") { 229 } else if (i == "$ref") {
233 if (obj[i].indexOf('.') == -1) { 230 if (obj[i].indexOf('.') == -1) {
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 } 852 }
856 if (a.name > b.name) { 853 if (a.name > b.name) {
857 return 1; 854 return 1;
858 } 855 }
859 return 0; 856 return 0;
860 } 857 }
861 858
862 function disableDocs(obj) { 859 function disableDocs(obj) {
863 return !!obj.nodoc; 860 return !!obj.nodoc;
864 } 861 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698