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

Unified Diff: Source/devtools/front_end/documentation/WikiParser.js

Issue 454873006: DevTools: Fix "documentation" module code style (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix test 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/documentation/JSArticle.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/documentation/WikiParser.js
diff --git a/Source/devtools/front_end/documentation/WikiParser.js b/Source/devtools/front_end/documentation/WikiParser.js
index f93e3c4dc7e8e7ddf8fa5446822ca5d370af914a..adb7d46b01f7da0d415e87fb9257864ddfaba3a9 100644
--- a/Source/devtools/front_end/documentation/WikiParser.js
+++ b/Source/devtools/front_end/documentation/WikiParser.js
@@ -13,7 +13,11 @@ WebInspector.WikiParser = function(wikiMarkupText)
this._document = this._parse();
}
-WebInspector.WikiParser._State = {
+/**
+ * @package
+ * @enum {number}
+ */
+WebInspector.WikiParser.State = {
Error: 0,
FirstOpen: 1,
SecondOpen: 2,
@@ -24,7 +28,11 @@ WebInspector.WikiParser._State = {
SecondClose: 7
}
-WebInspector.WikiParser._ValueState = {
+/**
+ * @package
+ * @enum {number}
+ */
+WebInspector.WikiParser.ValueState = {
Error: 0,
Outside: 1,
InsideSquare: 2,
@@ -56,7 +64,7 @@ WebInspector.WikiParser.prototype = {
while (this._position < this._wikiMarkupText.length) {
var field = this._parseField();
for (var key in field) {
- console.assert((typeof(obj[key]) === "undefined"), "equal keys! " + key);
+ console.assert(typeof obj[key] === "undefined", "Duplicate key: " + key);
obj[key] = field[key];
}
}
@@ -67,46 +75,46 @@ WebInspector.WikiParser.prototype = {
* @return {string}
*/
_parseValue: function() {
- var states = WebInspector.WikiParser._ValueState;
+ var states = WebInspector.WikiParser.ValueState;
var state = states.Outside;
var value = "";
while (this._position < this._wikiMarkupText.length) {
switch (state) {
- case states.Outside:
- if (this._wikiMarkupText[this._position] === '|' || (this._wikiMarkupText[this._position] === '}' && this._wikiMarkupText[this._position + 1] === '}'))
- return value;
- switch (this._wikiMarkupText[this._position]) {
- case '<':
- var indexClose = this._wikiMarkupText.indexOf('>', this._position);
- if (indexClose !== -1) {
- value += this._wikiMarkupText.substring(this._position, indexClose + 1);
- this._position = indexClose;
- }
- break;
- case'[':
- state = states.InsideSquare;
- value += this._wikiMarkupText[this._position];
- break;
- default:
- value += this._wikiMarkupText[this._position];
+ case states.Outside:
+ if (this._wikiMarkupText[this._position] === "|" || (this._wikiMarkupText[this._position] === "}" && this._wikiMarkupText[this._position + 1] === "}"))
+ return value;
+ switch (this._wikiMarkupText[this._position]) {
+ case "<":
+ var indexClose = this._wikiMarkupText.indexOf(">", this._position);
+ if (indexClose !== -1) {
+ value += this._wikiMarkupText.substring(this._position, indexClose + 1);
+ this._position = indexClose;
}
break;
- case states.InsideSquare:
- if (this._wikiMarkupText[this._position] === '[') {
- var indexClose = this._wikiMarkupText.indexOf("]]", this._position);
- if (indexClose !== -1) {
- value += this._wikiMarkupText.substring(this._position, indexClose + 2);
- this._position = indexClose + 1;
- }
- } else {
- var indexClose = this._wikiMarkupText.indexOf(']', this._position);
- if (indexClose !== -1) {
- value += this._wikiMarkupText.substring(this._position, indexClose + 1);
- this._position = indexClose;
- }
- }
- state = states.Outside;
+ case "[":
+ state = states.InsideSquare;
+ value += this._wikiMarkupText[this._position];
break;
+ default:
+ value += this._wikiMarkupText[this._position];
+ }
+ break;
+ case states.InsideSquare:
+ if (this._wikiMarkupText[this._position] === "[") {
+ var indexClose = this._wikiMarkupText.indexOf("]]", this._position);
+ if (indexClose !== -1) {
+ value += this._wikiMarkupText.substring(this._position, indexClose + 2);
+ this._position = indexClose + 1;
+ }
+ } else {
+ var indexClose = this._wikiMarkupText.indexOf("]", this._position);
+ if (indexClose !== -1) {
+ value += this._wikiMarkupText.substring(this._position, indexClose + 1);
+ this._position = indexClose;
+ }
+ }
+ state = states.Outside;
+ break;
}
this._position++;
}
@@ -122,102 +130,102 @@ WebInspector.WikiParser.prototype = {
var title = "";
var propertyName = "";
var propertyValue = "";
- var states = WebInspector.WikiParser._State;
+ var states = WebInspector.WikiParser.State;
var state = states.FirstOpen;
while (this._position < this._wikiMarkupText.length) {
var skipIncrement = false;
switch (state) {
- case states.FirstOpen:
- if (this._wikiMarkupText[this._position] === '{')
- state = states.SecondOpen;
- else
- state = states.Error;
- break;
- case states.SecondOpen:
- if (this._wikiMarkupText[this._position] === '{')
- state = states.Title;
- else
- state = states.Error;
- break;
- case states.Title:
- if (this._wikiMarkupText[this._position] === '|') {
- title = this._deleteTrailingSpaces(title);
- if (title !== "")
- obj[title] = {};
- state = states.PropertyName;
- } else if (this._wikiMarkupText[this._position] === '}') {
- title = this._deleteTrailingSpaces(title);
- if (title !== "")
- obj[title] = {};
+ case states.FirstOpen:
+ if (this._wikiMarkupText[this._position] === "{")
+ state = states.SecondOpen;
+ else
+ state = states.Error;
+ break;
+ case states.SecondOpen:
+ if (this._wikiMarkupText[this._position] === "{")
+ state = states.Title;
+ else
+ state = states.Error;
+ break;
+ case states.Title:
+ if (this._wikiMarkupText[this._position] === "|") {
+ title = this._deleteTrailingSpaces(title);
+ if (title !== "")
+ obj[title] = {};
+ state = states.PropertyName;
+ } else if (this._wikiMarkupText[this._position] === "}") {
+ title = this._deleteTrailingSpaces(title);
+ if (title !== "")
+ obj[title] = {};
+ state = states.FirstClose;
+ } else {
+ title += (this._wikiMarkupText[this._position] === "\n" ? "" : this._wikiMarkupText[this._position]);
+ }
+ break;
+ case states.PropertyName:
+ if (this._wikiMarkupText[this._position] === "=") {
+ state = states.PropertyValue;
+ this._deleteTrailingSpaces(propertyName);
+ if (propertyName !== "")
+ obj[title][propertyName] = [];
+ } else {
+ if (this._wikiMarkupText[this._position] === "}") {
+ propertyName = this._deleteTrailingSpaces(propertyName);
+ obj[title] = propertyName;
state = states.FirstClose;
} else {
- title += (this._wikiMarkupText[this._position] === '\n' ? "" : this._wikiMarkupText[this._position]);
+ propertyName += this._wikiMarkupText[this._position];
}
- break;
- case states.PropertyName:
- if (this._wikiMarkupText[this._position] === '=') {
- state = states.PropertyValue;
- this._deleteTrailingSpaces(propertyName);
- if (propertyName !== "")
- obj[title][propertyName] = [];
- } else {
- if (this._wikiMarkupText[this._position] === '}') {
- propertyName = this._deleteTrailingSpaces(propertyName);
- obj[title] = propertyName;
- state = states.FirstClose;
- } else {
- propertyName += this._wikiMarkupText[this._position];
- }
- }
- break;
- case states.PropertyValue:
- if (this._wikiMarkupText[this._position] === '{' && this._wikiMarkupText[this._position + 1] === '{') {
- propertyValue = this._parseField();
- obj[title][propertyName].push(propertyValue);
- propertyValue = "";
- skipIncrement = true;
- } else if (this._wikiMarkupText[this._position] === '|') {
- propertyValue = this._deleteTrailingSpaces(propertyValue);
- if (propertyValue !== "")
- obj[title][propertyName] = propertyValue;
+ }
+ break;
+ case states.PropertyValue:
+ if (this._wikiMarkupText[this._position] === "{" && this._wikiMarkupText[this._position + 1] === "{") {
+ propertyValue = this._parseField();
+ obj[title][propertyName].push(propertyValue);
+ propertyValue = "";
+ skipIncrement = true;
+ } else if (this._wikiMarkupText[this._position] === "|") {
+ propertyValue = this._deleteTrailingSpaces(propertyValue);
+ if (propertyValue !== "")
+ obj[title][propertyName] = propertyValue;
- state = states.PropertyName;
- if (Array.isArray(obj[title][propertyName]) && obj[title][propertyName].length === 1) {
- var newObj = obj[title][propertyName][0];
- obj[title][propertyName] = newObj;
- }
-
- propertyName = "";
- propertyValue = "";
- } else if (this._position + 1 < this._wikiMarkupText.length && this._wikiMarkupText[this._position] === '}' && this._wikiMarkupText[this._position + 1] === '}') {
- propertyValue = this._deleteTrailingSpaces(propertyValue);
- if (propertyValue !== "")
- obj[title][propertyName].push(propertyValue);
- if (Array.isArray(obj[title][propertyName]) && obj[title][propertyName].length === 1) {
- var newObj = obj[title][propertyName][0];
- obj[title][propertyName] = newObj;
- }
+ state = states.PropertyName;
+ if (Array.isArray(obj[title][propertyName]) && obj[title][propertyName].length === 1) {
+ var newObj = obj[title][propertyName][0];
+ obj[title][propertyName] = newObj;
+ }
- propertyValue = "";
- state = states.FirstClose;
- } else {
- propertyValue = this._parseValue();
- skipIncrement = true;
+ propertyName = "";
+ propertyValue = "";
+ } else if (this._position + 1 < this._wikiMarkupText.length && this._wikiMarkupText[this._position] === "}" && this._wikiMarkupText[this._position + 1] === "}") {
+ propertyValue = this._deleteTrailingSpaces(propertyValue);
+ if (propertyValue !== "")
+ obj[title][propertyName].push(propertyValue);
+ if (Array.isArray(obj[title][propertyName]) && obj[title][propertyName].length === 1) {
+ var newObj = obj[title][propertyName][0];
+ obj[title][propertyName] = newObj;
}
- break;
- case states.FirstClose:
- if (this._wikiMarkupText[this._position] === '}')
- state = states.SecondClose;
- else
- state = states.Error;
- break;
- case states.SecondClose:
- while (this._position < this._wikiMarkupText.length && this._wikiMarkupText[this._position] === '\n')
- this._position++;
- return obj;
- case states.Error:
- this._position = this._wikiMarkupText.length;
- return {};
+
+ propertyValue = "";
+ state = states.FirstClose;
+ } else {
+ propertyValue = this._parseValue();
+ skipIncrement = true;
+ }
+ break;
+ case states.FirstClose:
+ if (this._wikiMarkupText[this._position] === "}")
+ state = states.SecondClose;
+ else
+ state = states.Error;
+ break;
+ case states.SecondClose:
+ while (this._position < this._wikiMarkupText.length && this._wikiMarkupText[this._position] === "\n")
+ this._position++;
+ return obj;
+ case states.Error:
+ this._position = this._wikiMarkupText.length;
+ return {};
}
if (!skipIncrement)
this._position++;
« no previous file with comments | « Source/devtools/front_end/documentation/JSArticle.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698