Skip to content

Commit

Permalink
fix(eslint): too many statement
Browse files Browse the repository at this point in the history
  • Loading branch information
h13i32maru committed Feb 26, 2017
1 parent ad0a33d commit de4f78c
Showing 1 changed file with 50 additions and 43 deletions.
93 changes: 50 additions & 43 deletions src/ESDoc.js
Expand Up @@ -85,27 +85,15 @@ export default class ESDoc {
this._generateForTest(config, results, asts);
}

// ignore unexported and undocumented
for (const tag of results) {
if (tag.export === false) tag.ignore = true;
if (tag.undocument === true) tag.ignore = true;
}

// config.index
if (config.index) {
try {
const indexContent = fs.readFileSync(config.index, {encode: 'utf8'}).toString();
const tag = {
kind: 'index',
content: indexContent,
longname: path.resolve(config.index),
name: config.index,
static: true,
access: 'public'
};
results.push(tag);
} catch (e) {
// ignore
}
results.push(this._generateForIndex(config));
}

// manual
Expand Down Expand Up @@ -140,35 +128,8 @@ export default class ESDoc {
// ignore
}

try {
const write = (content, filePath) =>{
const _filePath = path.resolve(config.destination, filePath);
content = Plugin.onHandleContent(content, _filePath);

// todo: remove deprecated code
const ext = path.extname(filePath).toLowerCase();
if (ext === '.html') content = Plugin.onHandleHTML(content, _filePath);

console.log(`output: ${_filePath}`);
fs.outputFileSync(_filePath, content);
};

const copy = (srcPath, destPath) => {
const _destPath = path.resolve(config.destination, destPath);
console.log(`output: ${_destPath}`);
fs.copySync(srcPath, _destPath);
};

const read = (filePath) => {
const _filePath = path.resolve(config.destination, filePath);
return fs.readFileSync(_filePath).toString();
};

Plugin.onPublish(write, copy, read);
} catch (e) {
InvalidCodeLogger.showError(e);
process.exit(1);
}
// publish
this._publish(config);

Plugin.onComplete();
}
Expand Down Expand Up @@ -332,6 +293,20 @@ export default class ESDoc {
return {results: factory.results, ast: ast};
}

static _generateForIndex(config) {
const indexContent = fs.readFileSync(config.index, {encode: 'utf8'}).toString();
const tag = {
kind: 'index',
content: indexContent,
longname: path.resolve(config.index),
name: config.index,
static: true,
access: 'public'
};

return tag;
}

static _generateForManual(config) {
const results = [];

Expand Down Expand Up @@ -379,4 +354,36 @@ export default class ESDoc {

return results;
}

static _publish(config) {
try {
const write = (content, filePath) =>{
const _filePath = path.resolve(config.destination, filePath);
content = Plugin.onHandleContent(content, _filePath);

// todo: remove deprecated code
const ext = path.extname(filePath).toLowerCase();
if (ext === '.html') content = Plugin.onHandleHTML(content, _filePath);

console.log(`output: ${_filePath}`);
fs.outputFileSync(_filePath, content);
};

const copy = (srcPath, destPath) => {
const _destPath = path.resolve(config.destination, destPath);
console.log(`output: ${_destPath}`);
fs.copySync(srcPath, _destPath);
};

const read = (filePath) => {
const _filePath = path.resolve(config.destination, filePath);
return fs.readFileSync(_filePath).toString();
};

Plugin.onPublish(write, copy, read);
} catch (e) {
InvalidCodeLogger.showError(e);
process.exit(1);
}
}
}

0 comments on commit de4f78c

Please sign in to comment.