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

Unified Diff: chrome/common/extensions/docs/js/api_page_generator.js

Issue 10829301: Extension docs: Manual merge crrev.com/143652 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1180/src/
Patch Set: 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 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
===================================================================
--- chrome/common/extensions/docs/js/api_page_generator.js (revision 151318)
+++ chrome/common/extensions/docs/js/api_page_generator.js (working copy)
@@ -114,6 +114,9 @@
// Mapping from typeId to module.
var typeModule = {};
+// Mapping from typeId to type.
+var typeIdType = {};
+
// Auto-created page name as default
var pageName;
@@ -200,9 +203,44 @@
var schemas_retrieved = 0;
schema = [];
+ function qualifyRefs(namespace, obj) {
+ if (typeof(obj) == "object") {
+ for (var i in obj) {
+ if (typeof(obj[i]) == "object") {
+ obj[i] = qualifyRefs(namespace, obj[i]);
+ } else if (i == "$ref") {
+ if (obj[i].indexOf('.') == -1) {
+ obj[i] = namespace + '.' + obj[i];
+ }
+ }
+ }
+ }
+ return obj;
+ }
+
+ function qualifyTypes(schema) {
+ schema.forEach(function(mod) {
+ if (mod.types) {
+ mod.types.forEach(function(type) {
+ type.prettyId = type.id;
+ if (type.prettyId.indexOf(mod.namespace) == 0) {
+ type.prettyId = type.prettyId.substring(mod.namespace.length + 1);
+ }
+ if (type.id.indexOf(mod.namespace) != 0) {
+ type.id = mod.namespace + '.' + type.id;
+ }
+ typeModule[type.id] = mod;
+ typeIdType[type.id] = type;
+ });
+ }
+ mod = qualifyRefs(mod.namespace, mod);
+ });
+ return schema;
+ }
+
function onSchemaContent(content) {
if (content)
- schema = schema.concat(JSON.parse(JSON.minify(content)));
+ schema = schema.concat(qualifyTypes(JSON.parse(JSON.minify(content))));
if (++schemas_retrieved < schemas_to_retrieve.length)
return;
if (pageName.toLowerCase() == 'samples') {
@@ -711,6 +749,10 @@
return schema.type;
}
+function getPrettyTypeId(typeName) {
+ return typeIdType[typeName].prettyId;
+}
+
function hasPrimitiveValue(schema) {
var type = typeof(schema.value);
return type === 'string' || type === 'number';
« 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