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 e9ce67a045719a85d94c0e618491a9ce95dacbb6..0bae335d320d1faf75905a7cdefb7a80a6e844e8 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); |
} |
@@ -61,14 +62,19 @@ WebInspector.DocumentationView.prototype = { |
return; |
} |
var wikiMarkupText = pages[wikiKeys[0]]["revisions"]["0"]["*"]; |
- var article = WebInspector.JSArticle.parse(wikiMarkupText); |
+ var article; |
+ try { |
+ article = WebInspector.JSArticle.parse(wikiMarkupText); |
+ } catch (error) { |
+ console.error("Article could not be parsed. " + error); |
+ } |
if (!article) { |
this._createEmptyPage(); |
return; |
} |
- var renderer = new WebInspector.DocumentationView.Renderer(article, searchItem); |
this.element.removeChildren(); |
+ var renderer = new WebInspector.DocumentationView.Renderer(article, searchItem); |
this.element.appendChild(renderer.renderJSArticle()); |
}, |
@@ -258,11 +264,11 @@ WebInspector.DocumentationView.Renderer.prototype = { |
/** |
* @param {!WebInspector.WikiParser.ArticleElement} article |
- * @return {!Element} |
+ * @return {?Element} |
*/ |
_renderBlock: function(article) |
{ |
- var element; |
+ var element = null; |
var elementTypes = WebInspector.WikiParser.ArticleElement.Type; |
switch (article.type()) { |
@@ -288,14 +294,16 @@ WebInspector.DocumentationView.Renderer.prototype = { |
if (article.isHighlighted()) |
element.classList.add("documentation-highlighted-text"); |
break; |
- default: |
- console.error("Unknown ArticleElement type " + article.type()); |
case elementTypes.Block: |
element = document.createElement(article.hasBullet() ? "li" : "p"); |
break; |
+ default: |
+ console.error("Unknown ArticleElement type " + article.type()); |
} |
- if (article instanceof WebInspector.WikiParser.Block || article instanceof WebInspector.WikiParser.Inline) { |
+ if (article.type() === WebInspector.WikiParser.ArticleElement.Type.Block |
+ || article.type() === WebInspector.WikiParser.ArticleElement.Type.Code |
+ || article.type() === WebInspector.WikiParser.ArticleElement.Type.Inline) { |
for (var i = 0; i < article.children().length; ++i) { |
var child = this._renderBlock(article.children()[i]); |
if (child) |