summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/docs
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-22 22:23:27 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-22 22:23:27 +0000
commit7d42233b59568d140afc3ded2c4bc8745892a734 (patch)
tree54735f749f4a4907e09aa2df28d51c0b081e44a5 /chrome/common/extensions/docs
parent842301e204be1f9b5675aba0d1b64e7632f3ae68 (diff)
downloadchromium_src-7d42233b59568d140afc3ded2c4bc8745892a734.zip
chromium_src-7d42233b59568d140afc3ded2c4bc8745892a734.tar.gz
chromium_src-7d42233b59568d140afc3ded2c4bc8745892a734.tar.bz2
revert r21327, which broke MessagingExtensionTab
<http://build.chromium.org/buildbot/waterfall/waterfall?builder=Vista%20Tests> tbr=rafaelw Review URL: http://codereview.chromium.org/155955 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21334 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/docs')
-rwxr-xr-xchrome/common/extensions/docs/css/ApiRefStyles.css66
-rwxr-xr-xchrome/common/extensions/docs/js/api_page_generator.js102
-rwxr-xr-xchrome/common/extensions/docs/template/api_template.html403
3 files changed, 173 insertions, 398 deletions
diff --git a/chrome/common/extensions/docs/css/ApiRefStyles.css b/chrome/common/extensions/docs/css/ApiRefStyles.css
index 37bd248..2626359 100755
--- a/chrome/common/extensions/docs/css/ApiRefStyles.css
+++ b/chrome/common/extensions/docs/css/ApiRefStyles.css
@@ -1,12 +1,12 @@
-.todo {
- color: red;
-}
-
body {
font-family:Arial, Helvetica, sans-serif;
font-size: 13px;
}
+.todo {
+ color: red;
+}
+
h2,h3 {
margin-top: 2em;
}
@@ -88,60 +88,4 @@ p#classSummary {
.hidden {
display: none;
-}
-
-#container {
- height:auto !important;
- margin:0;
- max-width:1160px;
- min-height:100%;
- padding:0;
- position:relative;
-}
-
-#pageHeader {
- margin:9px 0 12px;
- padding:7px 0 0;
-}
-
-#pageTitle {
-}
-
-#pageContent {
-}
-
-#leftNav {
- clear:left;
- padding:0.5em 0 140px !important;
- display:block;
- float:left;
- margin:0;
- width:171px;
-}
-
-#leftNav ul {
- line-height:120%;
- margin:0;
- padding:0.6em 0 0;
-}
-
-#leftNav ul li {
- list-style-image:none;
- list-style-position:outside;
- list-style-type:none;
- margin:0;
- padding:0.2em 0 0.2em 1em;
-}
-
-#mainColumn {
- border-left:3px solid #E5ECF9;
- padding-left:24px;
- display:block;
- float:none;
- margin:0 0 0 171px;
- position:relative;
- width:auto;
-}
-
-#pageFooter {
-}
+} \ No newline at end of file
diff --git a/chrome/common/extensions/docs/js/api_page_generator.js b/chrome/common/extensions/docs/js/api_page_generator.js
index dcef86f..01ff9e2d 100755
--- a/chrome/common/extensions/docs/js/api_page_generator.js
+++ b/chrome/common/extensions/docs/js/api_page_generator.js
@@ -32,12 +32,6 @@ Array.prototype.each = function(f) {
}
}
-Object.prototype.extends = function(obj) {
- for (var k in obj) {
- this[k] = obj[k];
- }
-}
-
// name of the api this reference page is describing. i.e. "bookmarks", "tabs".
var apiName;
@@ -106,21 +100,15 @@ function fetchContent(url, onSuccess) {
* <body>.
* This uses the root <html> element (the entire document) as the template.
*/
-function renderTemplate(schemaContent) {
+function renderTemplate(schema) {
var apiDefinition;
- var schema = JSON.parse(schemaContent);
- schema.each(function(module) {
+ JSON.parse(schema).each(function(module) {
if (module.namespace == apiName)
apiDefinition = module;
});
- types = {};
- apiDefinition.types.each(function(t) {
- types[t.id] = t;
- });
-
- preprocessApi(apiDefinition, schema, types);
+ preprocessApi(apiDefinition);
// Render to template
var input = new JsEvalContext(apiDefinition);
@@ -132,91 +120,36 @@ function renderTemplate(schemaContent) {
}
/**
- * Augment the |module| with additional values that are required by the
- * template. |schema| is the full schema (including all modules). |types| is an
- * array of typeId -> typeSchema.
+ * Augment the |schema| with additional values that are required by the
+ * template.
*/
-function preprocessApi(module, schema, types) {
- module.functions.each(function(f) {
- f.fullName = "chrome." + module.namespace + "." + f.name;
- linkTypeReferences(f.parameters, types);
- assignTypeNames(f.parameters);
+function preprocessApi(schema) {
+ schema.functions.each(function(f) {
+ f.fullName = "chrome." + schema.namespace + "." + f.name;
+ assignTypeNames(f);
// Look for a callback that defines parameters.
if (f.parameters.length > 0) {
var lastParam = f.parameters[f.parameters.length - 1];
if (lastParam.type == "function" && lastParam.parameters) {
- linkTypeReferences(lastParam.parameters, types);
- assignTypeNames(lastParam.parameters);
+ assignTypeNames(lastParam);
f.callbackParameters = lastParam.parameters;
f.callbackSignature = generateSignatureString(lastParam.parameters);
- f.callbackParameters.each(function(p) {
- addPropertyListIfObject(p);
- });
}
}
-
- // Setup any type: "object" pameters to have an array of params (rather than
- // named properties).
- f.parameters.each(function(param) {
- addPropertyListIfObject(param);
- });
});
-
- module.events.each(function(e) {
- linkTypeReferences(e.parameters, types);
- assignTypeNames(e.parameters);
+
+ schema.events.each(function(e) {
+ assignTypeNames(e);
e.callSignature = generateSignatureString(e.parameters);
- e.parameters.each(function(p) {
- addPropertyListIfObject(p);
- });
});
-
- // Add a list of modules for the master TOC.
- module.apiModules = [];
- schema.each(function(s) {
- var m = {};
- m.module = s.namespace;
- m.name = s.namespace.substring(0, 1).toUpperCase() +
- s.namespace.substring(1);
- module.apiModules.push(m);
- });
- module.apiModules.sort(function(a, b) { return a.name > b.name; });
-}
-
-/*
- * For function, callback and event parameters, we want to document the
- * properties of any "object" type. This takes an param, and if it is an
- * "object" type, creates a "_parameterList" property in the form as
- * |parameters| list used by the template.
- */
-function addPropertyListIfObject(object) {
- if (object.type != "object" || !object.properties)
- return;
-
- var propertyList = [];
- for (var p in object.properties) {
- var prop = object.properties[p];
- prop.name = p;
- propertyList.push(prop);
- }
- assignTypeNames(propertyList);
- object._propertyList = propertyList;
}
-function linkTypeReferences(parameters, types) {
- parameters.each(function(p) {
- if (p.$ref) {
- p.extends(types[p.$ref]);
- }
- });
-}
-
/**
- * Assigns a typeName(param) to each of the |parameters|.
+ * Assigns a typeName(param) to each of the parameters of |f|.
*/
-function assignTypeNames(parameters) {
- parameters.each(function(p) {
+function assignTypeNames(f) {
+ f.parameters.each(function(p) {
p.typeName = typeName(p);
});
}
@@ -225,6 +158,9 @@ function assignTypeNames(parameters) {
* Generates a short text summary of the |schema| type
*/
function typeName(schema) {
+ if (schema.$ref)
+ return schema.$ref;
+
if (schema.choice) {
var typeNames = [];
schema.choice.each(function(c) {
diff --git a/chrome/common/extensions/docs/template/api_template.html b/chrome/common/extensions/docs/template/api_template.html
index fb96a77..0aa613d 100755
--- a/chrome/common/extensions/docs/template/api_template.html
+++ b/chrome/common/extensions/docs/template/api_template.html
@@ -1,273 +1,168 @@
- <div id="container">
- <a name="top"> </a>
+ <!-- BREADCRUMB -->
+ <!-- TODO: Fix these hrefs -->
+ <div id="breadcrumbs"><a href="../index.html">Chrome Extensions</a> &gt;
+ <a href="./index.html">Reference</a> &gt;
+ <a href="chrome-api-index.html">chrome.* API</a></div>
<!-- API HEADER -->
- <div id="pageHeader">
- <!-- BREADCRUMB -->
- <!-- TODO: Fix these hrefs -->
- <div id="breadcrumbs">
- <a href="../index.html">Chrome Extensions</a> &gt;
- <a href="./index.html">Reference</a> &gt;
- <a href="chrome-api-index.html">chrome.* API</a>
- </div>
- <div id="pageTitle">
- <h1 jscontent="namespace">chrome.apiname</h1>
- </div>
- </div> <!-- /pageHeader -->
-
- <div id="pageContent">
- <!-- SIDENAV -->
- <div id="leftNav">
- <ul>
- <li> Overview </li>
- <li> Programmer's Guide
- <ul>
- <li> Getting Started </li>
- <li> ... </li>
- </ul>
- </li>
- <li> Reference
- <ul>
- <li> chrome.* APIs
- <ul>
- <li jsselect="apiModules">
- <a jscontent="name" jsvalues=".href:module + '.html'">Foo</a>
- </li>
- </ul>
- </li>
- </ul>
- </li>
- </ul>
- </div>
-
- <div id="mainColumn">
- <!-- TABLE OF CONTENTS -->
- <div id="toc">
- <p>Contents</p>
+ <h1 jscontent="namespace">chrome.apiname</h1>
+
+ <!-- TABLE OF CONTENTS -->
+ <div id="toc">
+ <p>Contents</p>
+ <ol>
+ <li>
+ <a href="#overview">Description</a>
<ol>
- <li>
- <a href="#overview">Description</a>
- <ol>
- <li><a href="#overview-properties">Properties</a></li>
- <li><a href="#overview-examples">Examples</a></li>
- </ol>
- </li>
- <li>
- <a href="#methods">Methods</a>
- <ol>
- <li jsselect="functions">
- <a jscontent="name"
- jsvalues=".href:'#method-' + name"
- href="#method-anchor">methodName</a>
- </li>
- </ol>
- </li>
- <li>
- <a href="#events">Events</a>
- <ol>
- <li jsselect="events">
- <a jscontent="name"
- jsvalues=".href:'#event-' + name"
- href="#event-anchor">eventName</a>
- </li>
- </ol>
+ <li><a href="#overview-properties">Properties</a></li>
+ <li><a href="#overview-examples">Examples</a></li>
+ </ol>
+ </li>
+ <li>
+ <a href="#methods">Methods</a>
+ <ol>
+ <li jsselect="functions">
+ <a jscontent="name"
+ jsvalues=".href:'#method-' + name"
+ href="#method-anchor">methodName</a>
</li>
- <!-- TODO: What do we do about structs/types? -->
- <li>
- <a href="#structs">TODO: Structs</a>
- <ol>
- <li><a href="#struct-BookmarkTreeNode"></a></li>
- </ol>
+ </ol>
+ </li>
+ <li>
+ <a href="#events">Events</a>
+ <ol>
+ <li jsselect="events">
+ <a jscontent="name"
+ jsvalues=".href:'#event-' + name"
+ href="#event-anchor">eventName</a>
</li>
</ol>
- [PENDING: links to all h2s and h3s should go here -- would it be possible
- to link to overview h3s, as well? if so, how should we create their
- anchor/id values?]
- </div>
- <!-- /TABLE OF CONTENTS -->
-
-
- <!-- OVERVIEW PLACEHOLDER -- THIS GET REPLACED AUTHORED CONTENT -->
- <div id="overview"></div>
-
-
- <!-- METHODS -->
- <div class="apiGroup" id="methods">
- <a name="#methods"></a>
- <h2>Methods</h2>
-
- <!-- iterates over all functions -->
- <div class="apiItem" jsselect="functions">
- <a jsvalues=".name:'method-' + name"></a> <!-- method-anchor -->
- <h3 jscontent="name">method name</h3>
-
- <div class="summary">void
- <!-- Note: intentionally longer 80 columns -->
- <span jscontent="fullName">chrome.module.methodName</span>(<span jsselect="parameters" jsvalues="class:optional ? 'optional' : ''"><span jsdisplay="$index">, </span><span jscontent="typeName"></span>
- <var><span jscontent="name"></span></var></span>)</div>
-
- <div class="description">
- <p class="todo" jsdisplay="!description">Undocumented.</p>
- <p jsdisplay="description" jsvalues=".innerHTML:description">
- A description from the json schema def of the function goes here.
- </p>
-
- <!-- PARAMETERS -->
- <h4>Parameters</h4>
- <dl>
- <div jsselect="parameters">
- <dt>
- <!-- Note: intentionally longer 80 columns -->
- <var jscontent="name">paramName</var><em>
- (<span class="optional" jsdisplay="optional">optional </span><span jscontent="typeName">paramType</span>)</em>
- </dt>
- <dd class="todo" jsdisplay="!$this.description">
- Undocumented.
- </dd>
- <dd jsdisplay="$this.description"
- jsvalues=".innerHTML:$this.description">
- Description of this parameter from the json schema.
- </dd>
-
- <!-- OBJECT PROPERTIES -->
- <dd jsdisplay="_propertyList">
- <dl>
- <div jsselect="_propertyList">
- <dt>
- <!-- Note: intentionally longer 80 columns -->
- <var jscontent="name">paramName</var><em>
- (<span class="optional" jsdisplay="optional">optional </span><span jscontent="typeName">paramType</span>)</em>
- </dt>
- <dd class="todo" jsdisplay="!$this.description">
- Undocumented.
- </dd>
- <dd jsdisplay="$this.description"
- jsvalues=".innerHTML:$this.description">
- Description of this parameter from the json schema.
- </dd>
- </div>
- </dl>
- </dd>
- </div>
- </dl>
-
- <!-- CALLBACK -->
- <div jsdisplay="callbackParameters">
- <h4>Callback function</h4>
- <p>
- If you specify the <em>callback</em> parameter,
- it should specify a function that looks like this:
- </p>
-
+ </li>
+ <!-- TODO: What do we do about structs/types? -->
+ <li>
+ <a href="#structs">TODO: Structs</a>
+ <ol>
+ <li><a href="#struct-BookmarkTreeNode"></a></li>
+ </ol>
+ </li>
+ </ol>
+ [PENDING: links to all h2s and h3s should go here -- would it be possible
+ to link to overview h3s, as well? if so, how should we create their
+ anchor/id values?]
+ </div>
+ <!-- /TABLE OF CONTENTS -->
+
+
+ <!-- OVERVIEW PLACEHOLDER -- THIS GET REPLACED AUTHORED CONTENT -->
+ <div id="overview"></div>
+
+
+ <!-- METHODS -->
+ <div class="apiGroup" id="methods">
+ <a name="#methods"></a>
+ <h2>Methods</h2>
+
+ <!-- iterates over all functions -->
+ <div class="apiItem" jsselect="functions">
+ <a jsvalues=".name:'method-' + name"></a> <!-- method-anchor -->
+ <h3 jscontent="name">method name</h3>
+
+ <div class="summary">void
+ <!-- Note: intentionally longer 80 columns -->
+ <span jscontent="fullName">chrome.module.methodName</span>(<span jsselect="parameters" jsvalues="class:optional ? 'optional' : ''"><span jsdisplay="$index">, </span><span jscontent="typeName"></span>
+ <var><span jscontent="name"></span></var></span>)</div>
+
+ <div class="description">
+ <p class="todo" jsdisplay="!description">Undocumented.</p>
+ <p jsdisplay="description" jsvalues=".innerHTML:description">
+ A description from the json schema def of the function goes here.
+ </p>
+
+ <!-- PARAMETERS -->
+ <h4>Parameters</h4>
+ <dl>
+ <div jsselect="parameters">
+ <dt>
<!-- Note: intentionally longer 80 columns -->
- <pre>function(<span jscontent="callbackSignature">Type param1, Type param2</span>) <span class="subdued">{...}</span>);</pre>
- <dl>
- <div jsselect="callbackParameters">
- <dt>
- <!-- Note: intentionally longer 80 columns -->
- <var jscontent="name">paramName</var><em>
- (<span jscontent="typeName">paramType</span>)</em>
- </dt>
- <dd class="todo" jsdisplay="!$this.description">
- Undocumented.
- </dd>
- <dd jsdisplay="$this.description"
- jsvalues=".innerHTML:$this.description">
- Description of this parameter from the json schema.
- </dd>
- <!-- OBJECT PROPERTIES -->
- <dd jsdisplay="_propertyList">
- <dl>
- <div jsselect="_propertyList">
- <dt>
- <!-- Note: intentionally longer 80 columns -->
- <var jscontent="name">paramName</var><em>
- (<span class="optional" jsdisplay="optional">optional </span><span jscontent="typeName">paramType</span>)</em>
- </dt>
- <dd class="todo" jsdisplay="!$this.description">
- Undocumented.
- </dd>
- <dd jsdisplay="$this.description"
- jsvalues=".innerHTML:$this.description">
- Description of this parameter from the json schema.
- </dd>
- </div>
- </dl>
- </dd>
- </div>
- </dl>
+ <var jscontent="name">paramName</var><em>
+ (<span class="optional" jsdisplay="optional">optional </span><span jscontent="typeName">paramType</span>)</em>
+ </dt>
+ <dd class="todo" jsdisplay="!$this.description">Undocumented.</dd>
+ <dd jsdisplay="$this.description" jsvalues=".innerHTML:$this.description">
+ Description of this parameter from the json schema.
+ </dd>
+ </div>
+ </dl>
+
+ <!-- CALLBACK -->
+ <div jsdisplay="callbackParameters">
+ <h4>Callback function</h4>
+ <p>
+ If you specify the <em>callback</em> parameter,
+ it should specify a function that looks like this:
+ </p>
+
+ <!-- Note: intentionally longer 80 columns -->
+ <pre>function(<span jscontent="callbackSignature">Type param1, Type param2</span>) <span class="subdued">{...}</span>);</pre>
+ <dl>
+ <div jsselect="callbackParameters">
+ <dt>
+ <!-- Note: intentionally longer 80 columns -->
+ <var jscontent="name">paramName</var><em>
+ (<span jscontent="typeName">paramType</span>)</em>
+ </dt>
+ <dd class="todo" jsdisplay="!$this.description">Undocumented.</dd>
+ <dd jsdisplay="$this.description" jsvalues=".innerHTML:$this.description">
+ Description of this parameter from the json schema.
+ </dd>
</div>
+ </dl>
+ </div>
- </div> <!-- /description -->
+ </div> <!-- /description -->
- </div> <!-- /apiItem -->
+ </div> <!-- /apiItem -->
- </div> <!-- /apiGroup -->
+ </div> <!-- /apiGroup -->
- <!-- EVENTS -->
- <div class="apiGroup" id="events">
- <a name="#events"></a>
- <h2 id="events">Events</h2>
+ <!-- EVENTS -->
+ <div class="apiGroup" id="events">
+ <a name="#events"></a>
+ <h2 id="events">Events</h2>
- <!-- iterates over all events -->
- <div jsselect="events" class="apiItem" jsselect="functions">
- <a jsvalues=".name:'event-' + name"></a>
- <h3 jscontent="name">event name</h3>
+ <!-- iterates over all events -->
+ <div jsselect="events" class="apiItem" jsselect="functions">
+ <a jsvalues=".name:'event-' + name"></a>
+ <h3 jscontent="name">event name</h3>
- <div class="summary">
- <!-- Note: intentionally longer 80 columns -->
- <span class="subdued">chrome.bookmarks.</span><span jscontent="name">onEvent</span><span class="subdued">.addListener</span>(function(<span jscontent="callSignature">Type param1, Type param2</span>) <span class="subdued">{...}</span>);
- </div>
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span class="subdued">chrome.bookmarks.</span><span jscontent="name">onEvent</span><span class="subdued">.addListener</span>(function(<span jscontent="callSignature">Type param1, Type param2</span>) <span class="subdued">{...}</span>);
+ </div>
- <div class="description">
- <p class="todo" jsdisplay="!description">Undocumented.</p>
- <p jsdisplay="description" jsvalues=".innerHTML:description">
- A description from the json schema def of the event goes here.
- </p>
+ <div class="description">
+ <p class="todo" jsdisplay="!description">Undocumented.</p>
+ <p jsdisplay="description" jsvalues=".innerHTML:description">
+ A description from the json schema def of the event goes here.
+ </p>
- <!-- PARAMETERS -->
- <h4>Parameters</h4>
- <dl>
- <div jsselect="parameters">
- <dt>
- <!-- Note: intentionally longer 80 columns -->
- <var jscontent="name">paramName</var><em> (<span jscontent="typeName">paramType</span>)</em>
- </dt>
- <dd class="todo" jsdisplay="!$this.description">Undocumented.</dd>
- <dd jsdisplay="$this.description" jsvalues=".innerHTML:$this.description">
- Description of this parameter from the json schema.
- </dd>
-
- <!-- OBJECT PROPERTIES -->
- <dd jsdisplay="_propertyList">
- <dl>
- <div jsselect="_propertyList">
- <dt>
- <!-- Note: intentionally longer 80 columns -->
- <var jscontent="name">paramName</var><em>
- (<span class="optional" jsdisplay="optional">optional </span><span jscontent="typeName">paramType</span>)</em>
- </dt>
- <dd class="todo" jsdisplay="!$this.description">
- Undocumented.
- </dd>
- <dd jsdisplay="$this.description"
- jsvalues=".innerHTML:$this.description">
- Description of this parameter from the json schema.
- </dd>
- </div>
- </dl>
- </dd>
- </div>
- </dl>
+ <!-- PARAMETERS -->
+ <h4>Parameters</h4>
+ <dl>
+ <div jsselect="parameters">
+ <dt>
+ <!-- Note: intentionally longer 80 columns -->
+ <var jscontent="name">paramName</var><em> (<span jscontent="typeName">paramType</span>)</em>
+ </dt>
+ <dd class="todo" jsdisplay="!$this.description">Undocumented.</dd>
+ <dd jsdisplay="$this.description" jsvalues=".innerHTML:$this.description">
+ Description of this parameter from the json schema.
+ </dd>
+ </div>
+ </dl>
- </div> <!-- /decription -->
+ </div> <!-- /decription -->
- </div> <!-- /apiItem -->
+ </div> <!-- /apiItem -->
- </div> <!-- /apiGroup -->
- </div> <!-- /mainColumn -->
- </div> <!-- /pageContent -->
- <div id="pageFooter" -->
- TBD: copyright/license goes here
- </div> <!-- /pageFooter -->
- </div> <!-- /container --> \ No newline at end of file
+ </div> <!-- /apiGroup --> \ No newline at end of file