feat: pass language to code components

This commit is contained in:
Bogdan Lyashenko
2019-02-08 21:38:04 +01:00
parent 0fee30ab26
commit 55068ca6ca
14 changed files with 57 additions and 25 deletions

View File

@@ -54,8 +54,7 @@ const buildCrumb = (params, crumbNodeLines) => ({
params
});
const setupdGetCommentsFromCode = (regex) => fileCode => {
const setupdGetCommentsFromCode = regex => fileCode => {
if (!fileCode) return [];
return fileCode.split('\n').reduce((comments, item, i) => {
@@ -64,7 +63,11 @@ const setupdGetCommentsFromCode = (regex) => fileCode => {
const matches = regex.exec(codeLine);
if (matches) {
return [...comments, { value: matches[matches.length - 1], nodeLines: [i, i] }];
const lineNumber = i + 1;
return [
...comments,
{ value: matches[matches.length - 1], nodeLines: [lineNumber, lineNumber] }
];
}
return comments;
@@ -73,7 +76,7 @@ const setupdGetCommentsFromCode = (regex) => fileCode => {
const getNodeLines = node => node.nodeLines;
const setupGetCrumbs = (getCommentsFromCode) => (fileCode, path) => {
const setupGetCrumbs = getCommentsFromCode => (fileCode, path) => {
const crumbsList = [];
const comments = getCommentsFromCode(fileCode);