Chromium Code Reviews| Index: Source/devtools/front_end/documentation/DocumentationView.js |
| diff --git a/Source/devtools/front_end/documentation/DocumentationView.js b/Source/devtools/front_end/documentation/DocumentationView.js |
| index 5e782965a5ae9b94703114a957809ef2cd9a23cc..100b4a9239f4ce04d16f3be9e3764c23abba8321 100644 |
| --- a/Source/devtools/front_end/documentation/DocumentationView.js |
| +++ b/Source/devtools/front_end/documentation/DocumentationView.js |
| @@ -22,6 +22,7 @@ WebInspector.DocumentationView.showDocumentationURL = function(url, searchItem) |
| if (!WebInspector.DocumentationView._view) |
| WebInspector.DocumentationView._view = new WebInspector.DocumentationView(); |
| var view = WebInspector.DocumentationView._view; |
| + view.element.removeChildren(); |
| WebInspector.inspectorView.showCloseableViewInDrawer("documentation", WebInspector.UIString("Documentation"), view); |
| view.showDocumentation(url, searchItem); |
| } |
| @@ -97,8 +98,9 @@ WebInspector.DocumentationView.Renderer.prototype = { |
| { |
| this._createPageTitle(this._article.pageTitle, this._searchItem); |
| this._createStandardizationStatus(this._article.standardizationStatus); |
| - this._createTextSectionWithTitle("Summary", this._article.summary); |
| this._createSignatureSection(this._article.parameters, this._article.methods); |
| + this._createTextSectionWithTitle("Summary", this._article.summary); |
| + this._createParametersSection(this._article.parameters); |
| this._createReturnValueSection(this._article.methods); |
| this._createExamplesSection(this._article.examples); |
| this._createTextSectionWithTitle("Remarks", this._article.remarks); |
| @@ -143,6 +145,7 @@ WebInspector.DocumentationView.Renderer.prototype = { |
| title.textContent = titleText; |
| var text = this._renderBlock(article); |
| text.classList.add("documentation-text"); |
| + text.classList.add("documentation-section-content"); |
| section.appendChild(text); |
| }, |
| @@ -152,6 +155,38 @@ WebInspector.DocumentationView.Renderer.prototype = { |
| */ |
| _createSignatureSection: function(parameters, method) |
| { |
| + if (!method) |
| + return; |
| + var section = this._element.createChild("p", "documentation-section"); |
| + var signature = section.createChild("div", "documentation-method-signature"); |
|
lushnikov
2014/09/05 15:20:44
lets use "span" here instead of "div" and get rid
semeny
2014/09/08 10:03:56
Done.
|
| + var methodName = signature.createChild("span", "documentation-method-name"); |
| + methodName.textContent = this._searchItem.split(".").peekLast() + "("; |
| + for (var i = 0; i < parameters.length; ++i) { |
| + if (i > 0) { |
| + var separator = signature.createChild("inline"); |
|
lushnikov
2014/09/05 15:20:44
there's no tag "inline". You probably would like t
apavlov
2014/09/05 16:43:00
Yes, I meant that the variable should be inlined
semeny
2014/09/08 10:03:57
Done.
|
| + separator.textContent = ", "; |
| + } |
| + var parameterType = signature.createChild("span", "documentation-parameter-data-type-value"); |
| + var optional = ""; |
| + if (parameters[i].optional) { |
| + parameterType.className = "documentation-parameter-data-type-value"; |
|
lushnikov
2014/09/05 15:20:44
You've already set this className in element creat
semeny
2014/09/08 10:03:57
Done.
|
| + optional = "="; |
| + } |
| + parameterType.classList.add("documentation-color-box"); |
|
apavlov
2014/09/05 16:43:00
This class can be provided during the element cons
semeny
2014/09/08 10:03:56
Done.
|
| + parameterType.textContent = parameters[i].dataType + optional; |
|
lushnikov
2014/09/05 15:20:44
parameterType.textContent = parameters[i].dataType
semeny
2014/09/08 10:03:56
Done.
|
| + } |
| + var separator = signature.createChild("inline"); |
|
lushnikov
2014/09/05 15:20:44
ditto
semeny
2014/09/08 10:03:56
Done.
|
| + separator.textContent = ") : "; |
|
lushnikov
2014/09/05 15:20:44
lets avoid space after ")"
semeny
2014/09/08 10:03:56
Done.
|
| + var returnTypeElement = signature.createChild("span", "documentation-parameter-data-type-value"); |
| + returnTypeElement.classList.add("documentation-color-box"); |
| + returnTypeElement.textContent = method.returnValueName; |
| + }, |
| + |
| + /** |
| + * @param {!Array.<!WebInspector.JSArticle.Parameter>} parameters |
| + */ |
| + _createParametersSection: function(parameters) |
| + { |
| if (!parameters.length) |
| return; |
| var section = this._element.createChild("div", "documentation-section"); |
| @@ -159,16 +194,23 @@ WebInspector.DocumentationView.Renderer.prototype = { |
| title.textContent = "Parameters"; |
| for (var i = 0; i < parameters.length; ++i) { |
| var parameter = section.createChild("div", "documentation-parameter"); |
| + parameter.classList.add("documentation-section-content"); |
|
apavlov
2014/09/05 16:43:00
Ditto
semeny
2014/09/08 10:03:56
Done.
|
| var header = parameter.createChild("div", "documentation-parameter-header"); |
| var name = header.createChild("span", "documentation-parameter-name"); |
| name.textContent = parameters[i].name; |
| var dataTypeValue = header.createChild("span", "documentation-parameter-data-type-value"); |
| + dataTypeValue.classList.add("documentation-color-box"); |
|
apavlov
2014/09/05 16:43:00
Ditto for these two classes
semeny
2014/09/08 10:03:57
Done.
|
| + dataTypeValue.classList.add("documentation-parameter-margin"); |
| dataTypeValue.textContent = parameters[i].dataType; |
| if (parameters[i].optional) { |
| var optional = header.createChild("span", "documentation-parameter-optional"); |
| + optional.classList.add("documentation-color-box"); |
|
apavlov
2014/09/05 16:43:00
Ditto for these two classes
semeny
2014/09/08 10:03:56
Done.
|
| + optional.classList.add("documentation-parameter-margin"); |
| optional.textContent = WebInspector.UIString("Optional"); |
| } |
| - parameter.appendChild(this._renderBlock(parameters[i].description)); |
| + var description = this._renderBlock(parameters[i].description); |
| + description.classList.add("documentation-text"); |
| + parameter.appendChild(description); |
| } |
| }, |
| @@ -183,9 +225,10 @@ WebInspector.DocumentationView.Renderer.prototype = { |
| var section = this._element.createChild("div", "documentation-section"); |
| var title = section.createChild("div", "documentation-section-title"); |
| title.textContent = "Return Value"; |
| - var returnValueName = section.createChild("div", "documentation-return-value"); |
| + var returnValueName = section.createChild("div", "documentation-section-content"); |
| returnValueName.textContent = WebInspector.UIString("Returns an object of type " + method.returnValueName + "."); |
| - var returnValueDescription = section.createChild("div", "documentation-return-value"); |
| + var returnValueDescription = section.createChild("div", "documentation-section-content"); |
| + returnValueDescription.classList.add("documentation-text"); |
|
apavlov
2014/09/05 16:43:00
Ditto
semeny
2014/09/08 10:03:56
Done.
|
| returnValueDescription.textContent = WebInspector.UIString(method.returnValueDescription); |
| }, |
| @@ -203,13 +246,17 @@ WebInspector.DocumentationView.Renderer.prototype = { |
| for (var i = 0; i < examples.length; ++i) { |
| var example = section.createChild("div", "documentation-example"); |
| + example.classList.add("documentation-section-content"); |
|
apavlov
2014/09/05 16:43:00
Ditto here and below
semeny
2014/09/08 10:03:56
Done.
|
| var exampleDescription = example.createChild("div", "documentation-example-description-section"); |
| if (examples[i].liveUrl) { |
| var liveUrl = exampleDescription.createChild("a", "documentation-example-link"); |
| + liveUrl.classList.add("documentation-color-box"); |
| liveUrl.href = examples[i].liveUrl; |
| liveUrl.textContent = WebInspector.UIString("Example"); |
| } |
| - exampleDescription.appendChild(this._renderBlock(examples[i].description)); |
| + var description = this._renderBlock(examples[i].description); |
| + description.classList.add("documentation-text"); |
| + exampleDescription.appendChild(description); |
| var code = example.createChild("div", "documentation-example-code"); |
| code.classList.add("source-code"); |
| code.textContent = examples[i].code; |
| @@ -292,12 +339,15 @@ WebInspector.DocumentationView.ContextMenuProvider.prototype = { |
| return; |
| if (descriptors.length === 1) { |
| var formatString = WebInspector.useLowerCaseMenuTitles() ? "Show documentation for %s.%s" : "Show Documentation for %s.%s"; |
| - contextMenu.appendItem(WebInspector.UIString(formatString, descriptors[0].name(), descriptors[0].searchItem()), WebInspector.DocumentationView.showDocumentationURL.bind(null, descriptors[0].url(), descriptors[0].searchItem())); |
| + var methodName = String.sprintf("%s.%s", descriptors[0].name(), descriptors[0].searchItem()); |
| + contextMenu.appendItem(WebInspector.UIString(formatString, descriptors[0].name(), descriptors[0].searchItem()), WebInspector.DocumentationView.showDocumentationURL.bind(null, descriptors[0].url(), methodName)); |
| return; |
| } |
| var subMenuItem = contextMenu.appendSubMenuItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Show documentation for..." : "Show Documentation for...")); |
| - for (var i = 0; i < descriptors.length; ++i) |
| - subMenuItem.appendItem(String.sprintf("%s.%s", descriptors[i].name(), descriptors[i].searchItem()), WebInspector.DocumentationView.showDocumentationURL.bind(null, descriptors[i].url(), descriptors[i].searchItem())); |
| + for (var i = 0; i < descriptors.length; ++i) { |
| + var methodName = String.sprintf("%s.%s", descriptors[i].name(), descriptors[i].searchItem()); |
| + subMenuItem.appendItem(methodName, WebInspector.DocumentationView.showDocumentationURL.bind(null, descriptors[i].url(), methodName)); |
| + } |
| }, |
| /** |
| @@ -334,4 +384,4 @@ WebInspector.DocumentationView.ContextMenuProvider.prototype = { |
| return urlProvider.itemDescriptors(tokenText); |
| } |
| } |
| -} |
| +} |