Skip to content

Commit

Permalink
feat(comments): improve comments handling with latest larix
Browse files Browse the repository at this point in the history
  • Loading branch information
kollhof committed Apr 9, 2020
1 parent 12f8d2a commit f7cbca3
Show file tree
Hide file tree
Showing 18 changed files with 512 additions and 389 deletions.
2 changes: 0 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module.exports = {
modulePathIgnorePatterns: ['<rootDir>/build/'],

testMatch: [
'<rootDir>/**/*.test.js',
'<rootDir>/**/*.test.fnk'
],
testPathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/build/'],
Expand All @@ -27,7 +26,6 @@ module.exports = {

collectCoverage: true,
collectCoverageFrom: [
'<rootDir>/src/**/*.js',
'<rootDir>/src/**/*.fnk'
],
coveragePathIgnorePatterns: [
Expand Down
689 changes: 389 additions & 300 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@fink/loxia",
"name": "@fink/loxia-dev",
"version": "0.0.0-semantically-released",
"license": "MIT",
"engines": {
Expand All @@ -21,7 +21,8 @@
"build": "run build:*",
"build:dir": "mkdir -p ./build/pkg/",
"build:fnk": "fnk --src ./src --out-dir ./build/pkg --ignore '**/*.test.fnk'",
"build:files": "cp ./package.json ./README.md ./LICENSE ./build/pkg/",
"build:files": "cp ./README.md ./LICENSE ./build/pkg/",
"build:pkg": "./scripts/build-pkg-json",
"test": "run test:build-helpers jest",
"test:build-helpers": "fnk --src ./src/testing --out-dir build/test-helpers",
"jest": "jest --verbose --runInBand --no-cache ",
Expand All @@ -36,16 +37,17 @@
"devDependencies": {
"@fink/cli": "^2.3.0",
"@fink/jest": "^1.1.0",
"@fink/larix": "^4.8.1",
"commitizen": "^4.0.3",
"@fink/larix": "^4.9.0",
"@fink/loxia": "^4.8.2",
"commitizen": "^4.0.4",
"cz-conventional-changelog": "^3.1.0",
"jest-cli": "^25.2.4",
"jest-cli": "^25.3.0",
"npx-run": "^2.1.2",
"semantic-release": "^17.0.4"
},
"dependencies": {
"@babel/generator": "^7.8.6",
"@babel/traverse": "^7.8.6",
"@babel/types": "^7.8.6"
"@babel/generator": "^7.9.5",
"@babel/traverse": "^7.9.5",
"@babel/types": "^7.9.5"
}
}
1 change: 1 addition & 0 deletions scripts/build-pkg-json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sed 's/loxia-dev/loxia/' package.json > build/pkg/package.json
6 changes: 3 additions & 3 deletions src/lang/async/index.test.fnk.snap
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`await compiles 1`] = `
"const task1 = async foo => -(await foo);
"const task1 = async (foo) => -(await foo);
const task2 = async foo => await (foo + 4);
const task2 = async (foo) => await (foo + 4);
const task3 = async foo => {
const task3 = async (foo) => {
const bar = await foo();
return bar + 123;
};
Expand Down
2 changes: 1 addition & 1 deletion src/lang/call/call.test.fnk.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`call compiles 1`] = `
"const call1 = a(ni, x = 123, ...x);
const call2 = a(ni);
const call3 = a();
const call4 = a(x => x * 2);
const call4 = a((x) => x * 2);
Object.assign(module.exports, {
call1,
call2,
Expand Down
24 changes: 18 additions & 6 deletions src/lang/comments/index.fnk
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@

get_comments = fn {comment=null}:
match comment:
null: {}
else:
{value, loc} = comment
{leadingComments: [{type: 'CommentBlock', value: `${value} `, loc}]}
transform_comment = fn {op, value, loc, ...rest}:
match op:
'---': {type: 'CommentBlock', value, loc}
else: {type: 'CommentLine', value, loc}


transform_comments = fn comments:
pipe comments:
map comment: transform_comment:: comment


get_comments = fn {comments={}}:
{leading=[], trailing=[]} = comments

{
leadingComments: [...transform_comments:: leading],
trailingComments: [...transform_comments:: trailing]
}


wrap_with_comment_loc = fn js_node, larix_node:
Expand Down
2 changes: 2 additions & 0 deletions src/lang/comments/index.test.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ describe:: 'comment', fn:
Shrub ni.
---
bar = fn:
--- single line block ---
spam

# trailing module
`) eq snapshot

9 changes: 6 additions & 3 deletions src/lang/comments/index.test.fnk.snap
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`comment compiles 1`] = `
"/* leading expression */
"// leading expression
const spam = ni;
/*
Shrub ni.
*/
const bar = () => spam;
const bar = () =>
/* single line block */
spam;
Object.assign(module.exports, {
spam,
bar
});"
});
// trailing module"
`;
Loading

0 comments on commit f7cbca3

Please sign in to comment.