Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: refactor json.js #10442

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions tools/doc/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function doJSON(input, filename, cb) {
current.list.push(tok);
current.list.level = 1;
} else if (type === 'html' && common.isYAMLBlock(tok.text)) {
current.meta = parseYAML(tok.text);
current.meta = common.extractAndParseYAML(tok.text);
} else {
current.desc = current.desc || [];
if (!Array.isArray(current.desc)) {
Expand Down Expand Up @@ -302,10 +302,6 @@ function processList(section) {
delete section.list;
}

function parseYAML(text) {
return common.extractAndParseYAML(text);
}

// textRaw = "someobject.someMethod(a[, b=100][, c])"
function parseSignature(text, sig) {
var params = text.match(paramExpr);
Expand All @@ -314,7 +310,7 @@ function parseSignature(text, sig) {
params = params.split(/,/);
var optionalLevel = 0;
var optionalCharDict = {'[': 1, ' ': 0, ']': -1};
params.forEach(function(p, i, _) {
params.forEach(function(p, i) {
p = p.trim();
if (!p) return;
var param = sig.params[i];
Expand Down Expand Up @@ -544,14 +540,12 @@ function deepCopy_(src) {

// these parse out the contents of an H# tag
var eventExpr = /^Event(?::|\s)+['"]?([^"']+).*$/i;
var classExpr = /^Class:\s*([^ ]+).*?$/i;
var propExpr = /^(?:property:?\s*)?[^.]+\.([^ .()]+)\s*?$/i;
var braceExpr = /^(?:property:?\s*)?[^.\[]+(\[[^\]]+\])\s*?$/i;
var classMethExpr =
/^class\s*method\s*:?[^.]+\.([^ .()]+)\([^)]*\)\s*?$/i;
var methExpr =
/^(?:method:?\s*)?(?:[^.]+\.)?([^ .()]+)\([^)]*\)\s*?$/i;
var newExpr = /^new ([A-Z][a-zA-Z]+)\([^)]*\)\s*?$/;
var classExpr = /^Class:\s*([^ ]+).*$/i;
var propExpr = /^[^.]+\.([^ .()]+)\s*$/;
var braceExpr = /^[^.[]+(\[[^\]]+\])\s*$/;
var classMethExpr = /^class\s*method\s*:?[^.]+\.([^ .()]+)\([^)]*\)\s*$/i;
var methExpr = /^(?:[^.]+\.)?([^ .()]+)\([^)]*\)\s*$/;
var newExpr = /^new ([A-Z][a-zA-Z]+)\([^)]*\)\s*$/;
var paramExpr = /\((.*)\);?$/;

function newSection(tok) {
Expand Down