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

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

Issue 10642015: Basic setup for generating app docs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 6 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.
11 * 2) The files located at MODULE_SCHEMAS which are shared with the extension 11 * 2) The files located at MODULE_SCHEMAS which are shared with the extension
12 * system and defines the methods and events contained in one api. 12 * system and 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_EXTENSIONS = 'template/api_template.html';
22 var API_TEMPLATE_APPS = 'template/api_template_apps.html';
22 var MODULE_SCHEMAS = [ 23 var MODULE_SCHEMAS = [
23 '../api/alarms.json', // autogenerated 24 '../api/alarms.json', // autogenerated
24 '../api/bookmarks.json', 25 '../api/bookmarks.json',
25 '../api/browser_action.json', 26 '../api/browser_action.json',
26 '../api/browsing_data.json', 27 '../api/browsing_data.json',
27 '../api/chrome_auth_private.json', 28 '../api/chrome_auth_private.json',
28 '../api/chromeos_info_private.json', 29 '../api/chromeos_info_private.json',
29 '../api/content_settings.json', 30 '../api/content_settings.json',
30 '../api/context_menus.json', 31 '../api/context_menus.json',
31 '../api/cookies.json', 32 '../api/cookies.json',
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // The page name minus the '.html' extension. 150 // The page name minus the '.html' extension.
150 pageBase = document.location.href.match(/\/([^\/]*)\.html/)[1]; 151 pageBase = document.location.href.match(/\/([^\/]*)\.html/)[1];
151 if (!pageBase) { 152 if (!pageBase) {
152 alert('Empty page name for: ' + document.location.href); 153 alert('Empty page name for: ' + document.location.href);
153 return; 154 return;
154 } 155 }
155 156
156 pageName = pageBase.replace(/([A-Z])/g, ' $1'); 157 pageName = pageBase.replace(/([A-Z])/g, ' $1');
157 pageName = pageName.substring(0, 1).toUpperCase() + pageName.substring(1); 158 pageName = pageName.substring(0, 1).toUpperCase() + pageName.substring(1);
158 159
160 // TODO(aa): Ugh, this is horrible. FIXME.
Yoyo Zhou 2012/06/22 19:05:55 Not sure of the best thing to do here, but one alt
Aaron Boodman 2012/06/22 22:16:48 Won't work. Added additional commentary.
Yoyo Zhou 2012/06/22 22:26:06 Oh, I misread the length - 2 as 2 for some reason.
Aaron Boodman 2012/06/22 22:34:14 It's not the hard-code number that bothers me, but
161 var docFamily = location.pathname.split("/");
162 docFamily = docFamily[docFamily.length - 2];
163 if (docFamily != "extensions" && docFamily != "apps")
164 docFamily = "";
165
166 var apiTemplate = docFamily == "extensions" ?
Yoyo Zhou 2012/06/22 19:05:55 I wonder if there should be an error if it's neith
Aaron Boodman 2012/06/22 22:16:48 Done.
167 API_TEMPLATE_EXTENSIONS : API_TEMPLATE_APPS;
168
159 // Fetch the api template and insert into the <body>. 169 // Fetch the api template and insert into the <body>.
160 fetchContent(API_TEMPLATE, function(templateContent) { 170 fetchContent(apiTemplate, function(templateContent) {
161 document.getElementsByTagName('body')[0].innerHTML = templateContent; 171 document.getElementsByTagName('body')[0].innerHTML = templateContent;
162 fetchStatic(); 172 fetchStatic();
163 }, function(error) { 173 }, function(error) {
164 alert('Failed to load ' + API_TEMPLATE + '. ' + error); 174 alert('Failed to load ' + API_TEMPLATE + '. ' + error);
165 }); 175 });
166 } 176 }
167 177
168 function fetchStatic() { 178 function fetchStatic() {
169 // Fetch the static content and insert into the 'static' <div>. 179 // Fetch the static content and insert into the 'static' <div>.
170 fetchContent(staticResource(pageBase), function(overviewContent) { 180 fetchContent(staticResource(pageBase), function(overviewContent) {
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 } 774 }
765 if (a.name > b.name) { 775 if (a.name > b.name) {
766 return 1; 776 return 1;
767 } 777 }
768 return 0; 778 return 0;
769 } 779 }
770 780
771 function disableDocs(obj) { 781 function disableDocs(obj) {
772 return !!obj.nodoc; 782 return !!obj.nodoc;
773 } 783 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698