summaryrefslogtreecommitdiffstats
path: root/o3d/documentation
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-05 04:15:12 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-05 04:15:12 +0000
commit96ba3f3624defbbb523023d3e731d56793083927 (patch)
tree7ec64d17aaa699c22d2fc76d9801b435f6a2baf7 /o3d/documentation
parentcf066e493d140b20125adf2335f8b891d7e4b536 (diff)
downloadchromium_src-96ba3f3624defbbb523023d3e731d56793083927.zip
chromium_src-96ba3f3624defbbb523023d3e731d56793083927.tar.gz
chromium_src-96ba3f3624defbbb523023d3e731d56793083927.tar.bz2
Added default values to property documentation.
Fixed a few more docs issues. Review URL: http://codereview.chromium.org/159894 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/documentation')
-rw-r--r--o3d/documentation/jsdoc-toolkit-templates/publish.js97
1 files changed, 65 insertions, 32 deletions
diff --git a/o3d/documentation/jsdoc-toolkit-templates/publish.js b/o3d/documentation/jsdoc-toolkit-templates/publish.js
index 0899958..75937ba 100644
--- a/o3d/documentation/jsdoc-toolkit-templates/publish.js
+++ b/o3d/documentation/jsdoc-toolkit-templates/publish.js
@@ -40,14 +40,20 @@ var g_symbolArray;
var g_filePrefix;
var g_skipRE;
var g_validJSDOCTypes = {
+ 'boolean': true,
+ 'Event': true,
+ 'Element': true,
+ 'null': true,
'number': true,
'Number': true,
'object': true,
'Object': true,
'*': true,
'...': true,
+ 'RegExp': true,
'string': true,
'String': true,
+ 'XMLHttpRequest': true,
'void': true,
'undefined': true};
var g_unknownTypes = { };
@@ -567,6 +573,15 @@ function endsWith(str, suffix) {
}
/**
+ * Returns a string stripped of leading and trailing whitespace.
+ * @param {string} str String to strip.
+ * @return {string} stripped string.
+ */
+function stripWhitespace(str) {
+ return str.replace(/^\s+/, '').replace(/\s+$/, '');
+}
+
+/**
* Converts a camelCase name to underscore as in TypeOfFruit becomes
* type_of_fruit.
* @param {string} str CamelCase string.
@@ -679,6 +694,11 @@ function generatePlaceError(place, msg) {
* @return {string} linkified string.
*/
function linkifySingleType(place, type) {
+ if (!type) {
+ generatePlaceError(place, 'type is empty');
+ return '';
+ }
+ type = stripWhitespace(type);
var not = '';
var equals = '';
// Remove ! if it exists.
@@ -702,6 +722,20 @@ function linkifySingleType(place, type) {
link = 'Array.&lt;' +
linkifySingleType(place, type.substring(7, closingAngle)) + '>';
}
+ } else if (startsWith(type, 'Object.<')) {
+ var closingAngle = getIndexOfClosingCharacter(type, 6);
+ if (closingAngle < 0) {
+ generatePlaceError(place, 'Unmatched "<" in Object type : ' + type);
+ } else {
+ var objectSpec = type.substring(8, closingAngle);
+ var elements = objectSpec.split(/\s*,\s*/);
+ if (elements.length != 2) {
+ generatePlaceError(place, 'An Object spec must have exactly 2 types');
+ }
+ link = 'Object.&lt;' +
+ linkifySingleType(place, elements[0]) + ', ' +
+ linkifySingleType(place, elements[1]) + '>';
+ }
} else if (startsWith(type, 'function(')) {
var closingParen = getIndexOfClosingCharacter(type, 8);
if (closingParen < 0) {
@@ -728,33 +762,28 @@ function linkifySingleType(place, type) {
linkifyTypeSpec(place, end.substring(2));
}
}
- } else if (type.indexOf(':') >= 0) { // check for records.
- if (type.indexOf('::') >= 0) { // check for CPP scope
- generatePlaceError(place,
- 'CPP "::" scope operator found for type "' + type +
- '" must be Javascript "." scope operator.');
- } else {
- var elements = type.split(/\s*,\s*/);
- var output = '{';
- for (var ii = 0; ii < elements.length; ++ii) {
- if (ii > 0) {
- output += ', ';
- }
- var element = elements[ii];
- var colon = element.indexOf(': ');
- if (colon < 0) {
- generatePlaceError(place,
- 'Malformed record specification. Format must be ' +
- '{id1: type1, id2: type2, ...}.');
- output += element;
- } else {
- var name = element.substring(0, colon);
- var subType = element.substring(colon + 2);
- output += name + ':&nbsp;' + linkifyTypeSpec(place, subType)
- }
+ } else if (startsWith(type, '{') && endsWith(type, '}')) {
+ // found a record.
+ var elements = type.substr(1, type.length - 2).split(/\s*,\s*/);
+ var output = '{';
+ for (var ii = 0; ii < elements.length; ++ii) {
+ if (ii > 0) {
+ output += ', ';
+ }
+ var element = elements[ii];
+ var colon = element.indexOf(': ');
+ if (colon < 0) {
+ generatePlaceError(place,
+ 'Malformed record specification. Format must be ' +
+ '{id1: type1, id2: type2, ...}.');
+ output += element;
+ } else {
+ var name = element.substring(0, colon);
+ var subType = element.substring(colon + 2);
+ output += name + ':&nbsp;' + linkifyTypeSpec(place, subType);
}
- link = output + '}';
}
+ link = output + '}';
} else {
var symbol = getSymbol(type);
if (symbol) {
@@ -762,6 +791,7 @@ function linkifySingleType(place, type) {
type + '</a>';
} else {
// See if the symbol is a property or field.
+ var found = false;
var period = type.lastIndexOf('.');
if (period >= 0 && type != '...') {
var subType = type.substring(0, period);
@@ -770,13 +800,16 @@ function linkifySingleType(place, type) {
var field = type.substring(period + 1);
link = '<a class="el" href="' + getLinkToSymbol(symbol) + '#' +
field + '">' + type + '</a>';
- } else {
- if (subType[0] == '?') {
- subType = subType.substring(1);
- }
- if (!g_validJSDOCTypes[subType]) {
- reportUnknownType(place, type);
- }
+ found = true;
+ }
+ }
+
+ if (!found) {
+ if (type[0] == '?') {
+ type = type.substring(1);
+ }
+ if (!g_validJSDOCTypes[type]) {
+ reportUnknownType(place, type);
}
}
}