Chromium Code Reviews| Index: Source/devtools/front_end/documentation/DocumentationURLProvider.js |
| diff --git a/Source/devtools/front_end/documentation/DocumentationURLProvider.js b/Source/devtools/front_end/documentation/DocumentationURLProvider.js |
| index 1527136a7af67384e28df4e1b9ce2dfdaedacf58..d3bbd52747c8e083d63040861b81ac57b19b800d 100644 |
| --- a/Source/devtools/front_end/documentation/DocumentationURLProvider.js |
| +++ b/Source/devtools/front_end/documentation/DocumentationURLProvider.js |
| @@ -26,7 +26,11 @@ WebInspector.DocumentationURLProvider._sources = [ |
| { source: window.String, url: "javascript/String/", name: "String" }, |
| { source: window.Date.prototype, url: "javascript/Date/", name: "Date.prototype" }, |
| { source: window.Date, url: "javascript/Date/", name: "Date" }, |
| - { source: window.JSON, url: "javascript/JSON/", name: "JSON" } |
| + { source: window.JSON, url: "javascript/JSON/", name: "JSON" }, |
| + { source: window.Number, url: "javascript/Number/", name: "Number"}, |
| + { source: window.Number.prototype, url: "javascript/Number/", name: "Number.prototype"}, |
| + { source: window.Error.prototype, url: "javascript/Error/", name: "Error.prototype"}, |
| + { source: window.RegExp.prototype, url: "javascript/RegExp/", name: "RegExp.prototype"} |
| ]; |
| /** |
| @@ -34,6 +38,20 @@ WebInspector.DocumentationURLProvider._sources = [ |
| */ |
| WebInspector.DocumentationURLProvider._urlFormat = "http://docs.webplatform.org/w/api.php?action=query&titles=%s%s&prop=revisions&rvprop=timestamp|content&format=json" |
| +/** |
| + * @param {string} sourceUrl |
| + * @param {string} objectName |
| + * @param {string} searchTerm |
| + * @return {{url: string, name: string}} |
| + */ |
| +WebInspector.DocumentationURLProvider._createProperty = function(sourceUrl, objectName, searchTerm) |
|
apavlov
2014/08/13 13:35:35
Turn this into a nested function inside itemDescri
semeny
2014/08/13 14:10:17
Done.
|
| +{ |
| + return { |
| + url: String.sprintf(WebInspector.DocumentationURLProvider._urlFormat, sourceUrl, searchTerm), |
| + name: objectName |
| + } |
|
apavlov
2014/08/13 13:35:35
Missing ';'
lushnikov
2014/08/13 13:42:15
semicolon
semeny
2014/08/13 14:10:18
Done.
|
| +} |
| + |
| WebInspector.DocumentationURLProvider.prototype = { |
| /** |
| * @param {string} searchTerm |
| @@ -44,13 +62,13 @@ WebInspector.DocumentationURLProvider.prototype = { |
| var possibleProperties = []; |
|
apavlov
2014/08/13 13:35:34
var descriptors = [];
semeny
2014/08/13 14:10:18
Done.
|
| for (var i = 0; i < WebInspector.DocumentationURLProvider._sources.length; ++i) { |
| var sourceRef = WebInspector.DocumentationURLProvider._sources[i]; |
| - if (sourceRef.source[searchTerm] instanceof Function) { |
| - var property = { |
| - url: String.sprintf(WebInspector.DocumentationURLProvider._urlFormat, sourceRef.url, searchTerm), |
| - name: sourceRef.name |
| - }; |
| - possibleProperties.push(property); |
| - } |
| + if (!(searchTerm in sourceRef.source)) |
|
lushnikov
2014/08/13 13:42:15
lets use hasOwnProperty instead of "in"
semeny
2014/08/13 14:10:18
Done.
|
| + continue; |
| + if (searchTerm.toUpperCase() === searchTerm) |
| + var property = WebInspector.DocumentationURLProvider._createProperty(sourceRef.url, sourceRef.name, "constants"); |
|
apavlov
2014/08/13 13:35:35
We discourage multiple var declarations in conditi
semeny
2014/08/13 14:10:17
Done.
|
| + else |
| + var property = WebInspector.DocumentationURLProvider._createProperty(sourceRef.url, sourceRef.name, searchTerm); |
| + possibleProperties.push(property); |
| } |
| return possibleProperties; |
| } |