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

Side by Side Diff: Source/devtools/front_end/documentation/DocumentationURLProvider.js

Issue 472483002: DevTools: Add properties and constants support to "Documentation" module (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove mistaken commentary Created 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | Source/devtools/front_end/documentation/DocumentationView.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.<{source: !Object, url: string, name: string}>} 14 * @type {!Array.<{source: !Object, url: string, name: string}>}
15 */ 15 */
16 WebInspector.DocumentationURLProvider._sources = [ 16 WebInspector.DocumentationURLProvider._sources = [
17 { source: window, url: "javascript/", name: "Global" }, 17 { source: window, url: "javascript/", name: "Global" },
18 { source: window.Node.prototype, url: "dom/Node/", name: "Node.prototype" }, 18 { source: window.Node.prototype, url: "dom/Node/", name: "Node.prototype" },
19 { source: window.Node, url: "dom/Node/", name: "Node" }, 19 { source: window.Node, url: "dom/Node/", name: "Node" },
20 { source: window.Object.prototype, url: "javascript/Object/", name: "Object. prototype" }, 20 { source: window.Object.prototype, url: "javascript/Object/", name: "Object. prototype" },
21 { source: window.Object, url: "javascript/Object/", name: "Object" }, 21 { source: window.Object, url: "javascript/Object/", name: "Object" },
22 { source: window.Math, url: "javascript/Math/", name: "Math" }, 22 { source: window.Math, url: "javascript/Math/", name: "Math" },
23 { source: window.Array.prototype, url: "javascript/Array/", name: "Array.pro totype" }, 23 { source: window.Array.prototype, url: "javascript/Array/", name: "Array.pro totype" },
24 { source: window.Array, url: "javascript/Array/", name: "Array" }, 24 { source: window.Array, url: "javascript/Array/", name: "Array" },
25 { source: window.String.prototype, url: "javascript/String/", name: "String. prototype" }, 25 { source: window.String.prototype, url: "javascript/String/", name: "String. prototype" },
26 { source: window.String, url: "javascript/String/", name: "String" }, 26 { source: window.String, url: "javascript/String/", name: "String" },
27 { source: window.Date.prototype, url: "javascript/Date/", name: "Date.protot ype" }, 27 { source: window.Date.prototype, url: "javascript/Date/", name: "Date.protot ype" },
28 { source: window.Date, url: "javascript/Date/", name: "Date" }, 28 { source: window.Date, url: "javascript/Date/", name: "Date" },
29 { source: window.JSON, url: "javascript/JSON/", name: "JSON" } 29 { source: window.JSON, url: "javascript/JSON/", name: "JSON" },
30 { source: window.Number, url: "javascript/Number/", name: "Number"},
31 { source: window.Number.prototype, url: "javascript/Number/", name: "Number. prototype"},
32 { source: window.Error.prototype, url: "javascript/Error/", name: "Error.pro totype"},
33 { source: window.RegExp.prototype, url: "javascript/RegExp/", name: "RegExp. prototype"}
30 ]; 34 ];
31 35
32 /** 36 /**
33 * @const 37 * @const
34 */ 38 */
35 WebInspector.DocumentationURLProvider._urlFormat = "http://docs.webplatform.org/ w/api.php?action=query&titles=%s%s&prop=revisions&rvprop=timestamp|content&forma t=json" 39 WebInspector.DocumentationURLProvider._urlFormat = "http://docs.webplatform.org/ w/api.php?action=query&titles=%s%s&prop=revisions&rvprop=timestamp|content&forma t=json"
36 40
37 WebInspector.DocumentationURLProvider.prototype = { 41 WebInspector.DocumentationURLProvider.prototype = {
38 /** 42 /**
39 * @param {string} searchTerm 43 * @param {string} searchTerm
40 * @return {!Array.<{url: string, name: string}>} 44 * @return {!Array.<{url: string, name: string}>}
41 */ 45 */
42 itemDescriptors: function(searchTerm) 46 itemDescriptors: function(searchTerm)
43 { 47 {
44 var possibleProperties = []; 48 var descriptors = [];
45 for (var i = 0; i < WebInspector.DocumentationURLProvider._sources.lengt h; ++i) { 49 for (var i = 0; i < WebInspector.DocumentationURLProvider._sources.lengt h; ++i) {
46 var sourceRef = WebInspector.DocumentationURLProvider._sources[i]; 50 var sourceRef = WebInspector.DocumentationURLProvider._sources[i];
47 if (sourceRef.source[searchTerm] instanceof Function) { 51 if (!sourceRef.source.hasOwnProperty(searchTerm))
48 var property = { 52 continue;
49 url: String.sprintf(WebInspector.DocumentationURLProvider._u rlFormat, sourceRef.url, searchTerm), 53 descriptors.push(createDescriptor(searchTerm.toUpperCase() === searc hTerm ? "constants" : searchTerm));
50 name: sourceRef.name
51 };
52 possibleProperties.push(property);
53 }
54 } 54 }
55 return possibleProperties; 55 return descriptors;
56
57 /**
58 * @param {string} searchTerm
59 * @return {{url: string, name: string}}
60 */
61 function createDescriptor(searchTerm)
62 {
63 return {
64 url: String.sprintf(WebInspector.DocumentationURLProvider._urlFo rmat, sourceRef.url, searchTerm),
65 name: sourceRef.name
66 };
67 }
56 } 68 }
57 } 69 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/documentation/DocumentationView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698