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

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

Issue 3117029: Several small extensions docs system fixes... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 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/index.html ('k') | chrome/common/extensions/docs/manifest.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 56756)
+++ chrome/common/extensions/docs/js/api_page_generator.js (working copy)
@@ -381,6 +381,33 @@
return retval;
}
+// This function looks in the description for strings of the form
+// "$ref:TYPE_ID" (where TYPE_ID is something like "Tab" or "HistoryItem") and
+// substitutes a link to the documentation for that type.
+function substituteTypeRefs(description) {
+ var regexp = /\$ref\:\w+/g;
+ var matches = description.match(regexp);
+ if (!matches) {
+ return description;
+ }
+ var result = description;
+ for (var i = 0; i < matches.length; i++) {
+ var type = matches[i].split(":")[1];
+ var page = null;
+ try {
+ page = getTypeRefPage({"$ref": type});
+ } catch (error) {
+ console.log("substituteTypeRefs couldn't find page for type " + type);
+ continue;
+ }
+ var replacement = "<a href='" + page + "#type-" + type + "'>" + type +
+ "</a>";
+ result = result.replace(matches[i], replacement);
+ }
+
+ return result;
+}
+
function getTypeRefPage(type) {
return typeModule[type.$ref].namespace + ".html";
}
« no previous file with comments | « chrome/common/extensions/docs/index.html ('k') | chrome/common/extensions/docs/manifest.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698