Skip to content

Commit

Permalink
fix: some MySQL and MariaDB fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Oct 26, 2019
1 parent 14d2a95 commit baee0c0
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 35 deletions.
24 changes: 6 additions & 18 deletions src/MariaDB.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,12 @@ const createDoc = function($, element) {
break;
case 'default value:':
case 'default:':
/*var defaults = valueKey
.find('code')
.get()
.map(el => $(el).text());
if (defaults.length === 0) {
doc.default = valueKey.text().replace(valueKey.find('strong').text(), '').trim();
doc.default = doc.default.split('\n').join(',');
} else {
doc.default = defaults.join(',');
}*/
doc.default = valueKey
.text()
.replace(valueKey.find('strong').text(), '')
.trim();
doc.default = doc.default
.split('\n')
.map(el => cleaner.cleanDefault(el.trim()))
.join(', ');
doc.default = cleaner.cleanDefault(
valueKey
.text()
.replace(valueKey.find('strong').text(), '')
.trim()
);
break;
case 'valid values:':
doc.validValues = valueKey
Expand Down
38 changes: 32 additions & 6 deletions src/MySQL.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,8 @@ function completeDoc($, rows, doc) {
}
break;
case 'default value':
doc.default = cleaner.cleanDefault(
value
.text()
.toLowerCase()
.trim()
);
case 'default, range':
doc.default = cleaner.cleanDefault(value.text().trim());
break;
case 'valid values':
doc.validValues = $(value)
Expand All @@ -97,6 +93,15 @@ function completeDoc($, rows, doc) {
case 'command-line format':
doc.cli = cleaner.cleanCli(value.text().trim());
break;
case 'command line':
if (typeof doc.cli !== 'string') {
doc.cli =
value
.text()
.toLowerCase()
.trim() === 'yes';
}
break;
}
});
}
Expand Down Expand Up @@ -141,7 +146,25 @@ function parsePage($, cbSuccess) {
.first()
.attr('name'),
};
if (typeof doc.id !== 'string') {
doc.id = $(elem)
.prevAll()
.find('.link')
.first()
.attr('href')
.split('#')[1];
}
createDoc($, elem, doc);
if (typeof doc.cli === 'boolean') {
doc.cli = $(elem)
.prevAll()
.find('.option')
.first()
.text();
if (doc.cli === '') {
delete doc.cli;
}
}
if (!doc.name && doc.cli) {
var matches = doc.cli.match(cleaner.regexCli);
doc.name = matches[2].replace(/-/g, '_');
Expand Down Expand Up @@ -219,6 +242,9 @@ const pages = [
];

module.exports = {
parsePage: parsePage,
createDoc: createDoc,
completeDoc: completeDoc,
run: () => {
return common.processDataExtraction(pages, 'mysql-', parsePage);
},
Expand Down
35 changes: 24 additions & 11 deletions src/cleaner.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,37 @@ const cleanRange = function(range) {
/**
* Clean a default value
* @param {String} defaultValue The default value
* @returns {String} The same or an alternative formated text
*/
const cleanDefault = function(defaultValue) {
if (defaultValue === 'Autosized (see description)') {
defaultValue = '(autosized)';
return defaultValue
.split('\n')
.map(el => cleanTextDefault(el.trim()))
.join(', ');
};

/**
* Clean text of a default value
* @param {String} defaultTextValue The default text value
* @returns {String} The same or an alternative text
*/
const cleanTextDefault = function(defaultTextValue) {
if (defaultTextValue === 'Autosized (see description)') {
defaultTextValue = '(autosized)';
}
if (defaultValue.indexOf('Based on the number of processors') !== -1) {
defaultValue = '(based on the number of processors)';
if (defaultTextValue.indexOf('Based on the number of processors') !== -1) {
defaultTextValue = '(based on the number of processors)';
}
if (defaultValue === 'The MariaDB data directory') {
defaultValue = '(the MariaDB data directory)';
if (defaultTextValue === 'The MariaDB data directory') {
defaultTextValue = '(the MariaDB data directory)';
}
if (defaultValue.match(/-1 \(signifies (autoscaling); do not assign this literal value\)/g)) {
defaultValue = '(-1 signifies autoscaling; do not use -1)';
if (defaultTextValue.match(/-1 \(signifies (autoscaling); do not assign this literal value\)/g)) {
defaultTextValue = '(-1 signifies autoscaling; do not use -1)';
}
if (defaultValue.match(/-1 \(signifies (autosizing); do not assign this literal value\)/g)) {
defaultValue = '(-1 signifies autosizing; do not use -1)';
if (defaultTextValue.match(/-1 \(signifies (autosizing); do not assign this literal value\)/g)) {
defaultTextValue = '(-1 signifies autosizing; do not use -1)';
}
return defaultValue;
return defaultTextValue;
};

module.exports = {
Expand Down

0 comments on commit baee0c0

Please sign in to comment.