Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 */ | 7 */ |
| 8 WebInspector.DocumentationURLProvider = function() | 8 WebInspector.DocumentationURLProvider = function() |
| 9 { | 9 { |
| 10 } | 10 } |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * @const | 13 * @const |
| 14 * @type {!Array.<!Object, string>} | 14 * @type {!Array.<!Object, string, string>} |
|
apavlov
2014/08/12 12:54:16
This annotation is invalid. Should be:
@type {!Ar
semeny
2014/08/12 14:27:59
Done.
| |
| 15 */ | 15 */ |
| 16 WebInspector.DocumentationURLProvider._sources = [ | 16 WebInspector.DocumentationURLProvider._sources = [ |
| 17 { source: window, url: "javascript/" }, | 17 { source: window, url: "javascript/", name: "Global" }, |
| 18 { source: window.Node.prototype, url: "dom/Node/" }, | 18 { source: window.Node.prototype, url: "dom/Node/", name: "Node.prototype" }, |
| 19 { source: window.Node, url: "dom/Node/" }, | 19 { source: window.Node, url: "dom/Node/", name: "Node" }, |
| 20 { source: window.Object.prototype, url: "javascript/Object/" }, | 20 { source: window.Object.prototype, url: "javascript/Object/", name: "Object. prototype" }, |
| 21 { source: window.Object, url: "javascript/Object/" }, | 21 { source: window.Object, url: "javascript/Object/", name: "Object" }, |
| 22 { source: window.Math, url: "javascript/Math/" }, | 22 { source: window.Math, url: "javascript/Math/", name: "Math" }, |
| 23 { source: window.Array.prototype, url: "javascript/Array/" }, | 23 { source: window.Array.prototype, url: "javascript/Array/", name: "Array.pro totype" }, |
| 24 { source: window.Array, url: "javascript/Array/" }, | 24 { source: window.Array, url: "javascript/Array/", name: "Array" }, |
| 25 { source: window.String.prototype, url: "javascript/String/" }, | 25 { source: window.String.prototype, url: "javascript/String/", name: "String. prototype" }, |
| 26 { source: window.String, url: "javascript/String/" }, | 26 { source: window.String, url: "javascript/String/", name: "String" }, |
| 27 { source: window.Date.prototype, url: "javascript/Date/" }, | 27 { source: window.Date.prototype, url: "javascript/Date/", name: "Date.protot ype" }, |
| 28 { source: window.Date, url: "javascript/Date/" }, | 28 { source: window.Date, url: "javascript/Date/", name: "Date" }, |
| 29 { source: window.JSON, url: "javascript/JSON/" } | 29 { source: window.JSON, url: "javascript/JSON/", name: "JSON" } |
| 30 ]; | 30 ]; |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * @const | 33 * @const |
| 34 */ | 34 */ |
| 35 WebInspector.DocumentationURLProvider._urlFormat = "http://docs.webplatform.org/ w/api.php?action=query&titles=%s%s&prop=revisions&rvprop=timestamp|content&forma t=json" | 35 WebInspector.DocumentationURLProvider._urlFormat = "http://docs.webplatform.org/ w/api.php?action=query&titles=%s%s&prop=revisions&rvprop=timestamp|content&forma t=json" |
| 36 | 36 |
| 37 WebInspector.DocumentationURLProvider.prototype = { | 37 WebInspector.DocumentationURLProvider.prototype = { |
| 38 /** | 38 /** |
| 39 * @param {string} searchTerm | 39 * @param {string} searchTerm |
| 40 * @return {?string} | 40 * @return {!Array.<{url: string, name: string}>} |
| 41 */ | 41 */ |
| 42 itemPath: function(searchTerm) | 42 itemPath: function(searchTerm) |
|
yurys
2014/08/12 12:49:59
documentationUrls
apavlov
2014/08/12 12:54:16
This no longer returns a "path". Let's rename it t
semeny
2014/08/12 14:27:59
Done.
| |
| 43 { | 43 { |
| 44 var possiblePaths = []; | |
| 44 for (var i = 0; i < WebInspector.DocumentationURLProvider._sources.lengt h; ++i) { | 45 for (var i = 0; i < WebInspector.DocumentationURLProvider._sources.lengt h; ++i) { |
| 45 var sourceRef = WebInspector.DocumentationURLProvider._sources[i]; | 46 var sourceRef = WebInspector.DocumentationURLProvider._sources[i]; |
| 46 if (sourceRef.source[searchTerm] instanceof Function) | 47 if (sourceRef.source[searchTerm] instanceof Function) { |
|
yurys
2014/08/12 12:49:59
typeof sourceRef.source[searchTerm] !== "undefined
semeny
2014/08/12 14:27:59
Currently we are working only with methods, not pr
| |
| 47 return String.sprintf(WebInspector.DocumentationURLProvider._url Format, sourceRef.url, searchTerm); | 48 var property = {} |
|
apavlov
2014/08/12 12:54:16
You can initialize the fields right in the literal
semeny
2014/08/12 14:27:59
Done.
| |
| 49 property.url = String.sprintf(WebInspector.DocumentationURLProvi der._urlFormat, sourceRef.url, searchTerm); | |
| 50 property.name = sourceRef.name + "." + searchTerm; | |
| 51 possiblePaths.push(property); | |
| 52 } | |
| 48 } | 53 } |
| 49 return null; | 54 return possiblePaths; |
| 50 } | 55 } |
| 51 } | 56 } |
| OLD | NEW |