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

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

Issue 525363003: DevTools: [Documentation] Add signature section for renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@iliia-patch
Patch Set: Change page title, move isMethod function Created 6 years, 3 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 | « Source/devtools/front_end/documentation/DocumentationURLProvider.js ('k') | no next file » | 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 * @extends {WebInspector.View} 7 * @extends {WebInspector.View}
8 */ 8 */
9 WebInspector.DocumentationView = function() 9 WebInspector.DocumentationView = function()
10 { 10 {
11 WebInspector.View.call(this); 11 WebInspector.View.call(this);
12 this.element.classList.add("documentation-view"); 12 this.element.classList.add("documentation-view");
13 this.registerRequiredCSS("documentationView.css"); 13 this.registerRequiredCSS("documentationView.css");
14 } 14 }
15 15
16 /** 16 /**
17 * @param {string} url 17 * @param {string} url
18 * @param {string} searchItem 18 * @param {string} searchItem
19 */ 19 */
20 WebInspector.DocumentationView.showDocumentationURL = function(url, searchItem) 20 WebInspector.DocumentationView.showDocumentationURL = function(url, searchItem)
21 { 21 {
22 if (!WebInspector.DocumentationView._view) 22 if (!WebInspector.DocumentationView._view)
23 WebInspector.DocumentationView._view = new WebInspector.DocumentationVie w(); 23 WebInspector.DocumentationView._view = new WebInspector.DocumentationVie w();
24 var view = WebInspector.DocumentationView._view; 24 var view = WebInspector.DocumentationView._view;
25 view.element.removeChildren();
lushnikov 2014/09/04 12:51:37 this looks like a left-over from a rebaseline, it
semeny 2014/09/04 16:17:20 Done.
25 WebInspector.inspectorView.showCloseableViewInDrawer("documentation", WebIns pector.UIString("Documentation"), view); 26 WebInspector.inspectorView.showCloseableViewInDrawer("documentation", WebIns pector.UIString("Documentation"), view);
26 view.showDocumentation(url, searchItem); 27 view.showDocumentation(url, searchItem);
27 } 28 }
28 29
29 WebInspector.DocumentationView.prototype = { 30 WebInspector.DocumentationView.prototype = {
30 /** 31 /**
31 * @param {string} url 32 * @param {string} url
32 * @param {string} searchItem 33 * @param {string} searchItem
33 */ 34 */
34 showDocumentation: function(url, searchItem) 35 showDocumentation: function(url, searchItem)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 { 98 {
98 this._createPageTitle(this._article.pageTitle, this._searchItem); 99 this._createPageTitle(this._article.pageTitle, this._searchItem);
99 this._createStandardizationStatus(this._article.standardizationStatus); 100 this._createStandardizationStatus(this._article.standardizationStatus);
100 this._createTextSectionWithTitle("Summary", this._article.summary); 101 this._createTextSectionWithTitle("Summary", this._article.summary);
101 this._createSignatureSection(this._article.parameters, this._article.met hods); 102 this._createSignatureSection(this._article.parameters, this._article.met hods);
102 this._createReturnValueSection(this._article.methods); 103 this._createReturnValueSection(this._article.methods);
103 this._createExamplesSection(this._article.examples); 104 this._createExamplesSection(this._article.examples);
104 this._createTextSectionWithTitle("Remarks", this._article.remarks); 105 this._createTextSectionWithTitle("Remarks", this._article.remarks);
105 106
106 return this._element; 107 return this._element;
108
109 /**
110 * @param {string} name
111 * @return {boolean}
112 */
113 function isMethod(name)
lushnikov 2014/09/04 12:51:37 where do you use this method?
lushnikov 2014/09/04 12:51:37 wrong indent (9 chars?)
semeny 2014/09/04 16:17:20 Done.
114 {
115 var tokens = name.split(".");
116 var currentObject = window;
117 for (var i = 0; i < tokens.length; i++) {
lushnikov 2014/09/04 12:51:37 ++i
semeny 2014/09/04 16:17:20 Done.
118 currentObject = currentObject[tokens[i]];
119 if (!currentObject)
120 return false;
121 }
122 return (typeof(currentObject) === "function");
lushnikov 2014/09/04 12:51:37 typeof is operator - no need for brackets
semeny 2014/09/04 16:17:20 Done.
123 }
107 }, 124 },
108 125
109 /** 126 /**
110 * @param {string} titleText 127 * @param {string} titleText
111 * @param {string} searchItem 128 * @param {string} searchItem
112 */ 129 */
113 _createPageTitle: function(titleText, searchItem) 130 _createPageTitle: function(titleText, searchItem)
114 { 131 {
115 var pageTitle = this._element.createChild("div", "documentation-page-tit le"); 132 var pageTitle = this._element.createChild("div", "documentation-page-tit le");
116 if (titleText) 133 if (titleText)
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 appendApplicableItems: function(event, contextMenu, target) 302 appendApplicableItems: function(event, contextMenu, target)
286 { 303 {
287 if (!(target instanceof WebInspector.CodeMirrorTextEditor)) 304 if (!(target instanceof WebInspector.CodeMirrorTextEditor))
288 return; 305 return;
289 var textEditor = /** @type {!WebInspector.CodeMirrorTextEditor} */ (targ et); 306 var textEditor = /** @type {!WebInspector.CodeMirrorTextEditor} */ (targ et);
290 var descriptors = this._determineDescriptors(textEditor); 307 var descriptors = this._determineDescriptors(textEditor);
291 if (!descriptors.length) 308 if (!descriptors.length)
292 return; 309 return;
293 if (descriptors.length === 1) { 310 if (descriptors.length === 1) {
294 var formatString = WebInspector.useLowerCaseMenuTitles() ? "Show doc umentation for %s.%s" : "Show Documentation for %s.%s"; 311 var formatString = WebInspector.useLowerCaseMenuTitles() ? "Show doc umentation for %s.%s" : "Show Documentation for %s.%s";
295 contextMenu.appendItem(WebInspector.UIString(formatString, descripto rs[0].name(), descriptors[0].searchItem()), WebInspector.DocumentationView.showD ocumentationURL.bind(null, descriptors[0].url(), descriptors[0].searchItem())); 312 var methodName = String.sprintf("%s.%s", descriptors[0].name(), desc riptors[0].searchItem());
313 contextMenu.appendItem(WebInspector.UIString(formatString, descripto rs[0].name(), descriptors[0].searchItem()), WebInspector.DocumentationView.showD ocumentationURL.bind(null, descriptors[0].url(), methodName));
296 return; 314 return;
297 } 315 }
298 var subMenuItem = contextMenu.appendSubMenuItem(WebInspector.UIString(We bInspector.useLowerCaseMenuTitles() ? "Show documentation for..." : "Show Docume ntation for...")); 316 var subMenuItem = contextMenu.appendSubMenuItem(WebInspector.UIString(We bInspector.useLowerCaseMenuTitles() ? "Show documentation for..." : "Show Docume ntation for..."));
299 for (var i = 0; i < descriptors.length; ++i) 317 for (var i = 0; i < descriptors.length; ++i) {
300 subMenuItem.appendItem(String.sprintf("%s.%s", descriptors[i].name() , descriptors[i].searchItem()), WebInspector.DocumentationView.showDocumentation URL.bind(null, descriptors[i].url(), descriptors[i].searchItem())); 318 var methodName = String.sprintf("%s.%s", descriptors[i].name(), desc riptors[i].searchItem());
319 subMenuItem.appendItem(methodName, WebInspector.DocumentationView.sh owDocumentationURL.bind(null, descriptors[i].url(), methodName));
320 }
301 }, 321 },
302 322
303 /** 323 /**
304 * @param {!WebInspector.CodeMirrorTextEditor} textEditor 324 * @param {!WebInspector.CodeMirrorTextEditor} textEditor
305 * @return {!Array.<!WebInspector.DocumentationURLProvider.ItemDescriptor>} 325 * @return {!Array.<!WebInspector.DocumentationURLProvider.ItemDescriptor>}
306 */ 326 */
307 _determineDescriptors: function(textEditor) 327 _determineDescriptors: function(textEditor)
308 { 328 {
309 var urlProvider = WebInspector.DocumentationURLProvider.instance(); 329 var urlProvider = WebInspector.DocumentationURLProvider.instance();
310 var textSelection = textEditor.selection().normalize(); 330 var textSelection = textEditor.selection().normalize();
(...skipping 17 matching lines...) Expand all
328 function computeDescriptors(column) 348 function computeDescriptors(column)
329 { 349 {
330 var token = textEditor.tokenAtTextPosition(textSelection.startLine, column); 350 var token = textEditor.tokenAtTextPosition(textSelection.startLine, column);
331 if (!token) 351 if (!token)
332 return []; 352 return [];
333 var tokenText = textEditor.line(textSelection.startLine).substring(t oken.startColumn, token.endColumn); 353 var tokenText = textEditor.line(textSelection.startLine).substring(t oken.startColumn, token.endColumn);
334 return urlProvider.itemDescriptors(tokenText); 354 return urlProvider.itemDescriptors(tokenText);
335 } 355 }
336 } 356 }
337 } 357 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/documentation/DocumentationURLProvider.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698