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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/docs/input.ime.html ('k') | chrome/common/extensions/docs/management.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/js/api_page_generator.js
diff --git a/chrome/common/extensions/docs/js/api_page_generator.js b/chrome/common/extensions/docs/js/api_page_generator.js
index 25711c516d01fa9649587d5c5ea530548cc95143..ab4f0f70605ed7aa94923c41aba98df1fa3d0cab 100644
--- a/chrome/common/extensions/docs/js/api_page_generator.js
+++ b/chrome/common/extensions/docs/js/api_page_generator.js
@@ -18,7 +18,8 @@
*
*/
-var API_TEMPLATE = 'template/api_template.html';
+var API_TEMPLATE_EXTENSIONS = 'template/api_template.html';
+var API_TEMPLATE_APPS = 'template/api_template_apps.html';
var MODULE_SCHEMAS = [
'../api/alarms.json', // autogenerated
'../api/bookmarks.json',
@@ -156,8 +157,33 @@ function renderPage() {
pageName = pageBase.replace(/([A-Z])/g, ' $1');
pageName = pageName.substring(0, 1).toUpperCase() + pageName.substring(1);
+ // TODO(aa): Ugh, this is horrible. The problem is that these files are
+ // rendered at many locations:
+ //
+ // - file:///some/path/on/your/machine/chrome/common/extensions/docs/
+ // - http://chromeextensionsdocs.appspot.com/
+ // - code.google.com/chrome/extensions
+ // - etc
+ //
+ // At this point, we don't know what the root is, so we can't know for sure
+ // which path component should be the family. So we just base it off the
+ // current assumption that all our HTML files are currently in the root
+ // directory.
+ var docFamily = location.pathname.split("/");
+ docFamily = docFamily[docFamily.length - 2];
+ if (docFamily != "extensions" && docFamily != "apps")
+ docFamily = "";
+
+ var apiTemplate = {
+ "extensions": API_TEMPLATE_EXTENSIONS,
+ "apps": API_TEMPLATE_APPS
+ }[docFamily];
+
+ if (!apiTemplate)
+ throw new Error("Unexpected doc family: " + docFamily);
+
// Fetch the api template and insert into the <body>.
- fetchContent(API_TEMPLATE, function(templateContent) {
+ fetchContent(apiTemplate, function(templateContent) {
document.getElementsByTagName('body')[0].innerHTML = templateContent;
fetchStatic();
}, function(error) {
« no previous file with comments | « chrome/common/extensions/docs/input.ime.html ('k') | chrome/common/extensions/docs/management.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698