From aafd9b757e728c902174db702bc11489eda05a6c Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Thu, 30 Jun 2016 10:58:29 -0700 Subject: [PATCH 01/11] Test for readability, equality, etc --- package.json | 19 +++++++++++++++ script/test-readability | 53 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 package.json create mode 100755 script/test-readability diff --git a/package.json b/package.json new file mode 100644 index 00000000000..1d2c07a5576 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "open-source-handbook", + "private": true, + "devDependencies": { + "async": "^1.5.2", + "glob": "^7.0.5", + "remark-lint": "^4.0.1", + "remark-parse": "^1.0.0", + "remark-retext": "^2.0.0", + "remark-stringify": "^1.0.0", + "retext": "^3.0.0", + "retext-english": "^2.0.0", + "retext-equality": "^2.3.2", + "retext-readability": "^2.0.0", + "to-vfile": "^1.0.0", + "unified": "^4.1.2", + "vfile-reporter": "^2.0.0" + } +} diff --git a/script/test-readability b/script/test-readability new file mode 100755 index 00000000000..f7254f266de --- /dev/null +++ b/script/test-readability @@ -0,0 +1,53 @@ +#!/usr/bin/env node + +// Retext stuff +var unified = require('unified'); +var readability = require('retext-readability'); +var english = require('retext-english'); +var equality = require('retext-equality'); + +// Remark stuff +var parse = require('remark-parse'); +var lint = require('remark-lint'); +var remark2retext = require('remark-retext'); +var stringify = require('remark-stringify'); + +// Util stuff +var report = require('vfile-reporter'); +var glob = require('glob'); +var fs = require('fs'); +var async = require('async'); + +var options = { + // https://github.com/wooorm/remark-lint/blob/master/doc/rules.md + "lint": { + "first-heading-level": 2, // First heading should be an h2 + "list-item-indent": "space", // As the gods intended. + "maximum-line-length": false, // turn off line length linting + "no-html": false // Sadly, need HTML for video embeds + }, + "readability": { + "age": 18 + }, +}; + +var warnings = async.map(glob.sync("_content/**/*.md"), function(file, callback) { + fs.readFile(file, function(err, contents) { + unified() + .use(parse) + .use(lint, options["lint"]) + .use(remark2retext, unified() + .use(english) + .use(equality) + .use(readability, options["readability"]) + ) + .use(stringify) + .process(contents.toString(), function (err, result) { + result.filename = file; + callback(err, result); + }); + }); +}, function (err, results) { + console.log("reporting"); + console.log(report(results)); +}); From 3b685f44b8f86feaeb0319708a51c6e3098829d5 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Thu, 30 Jun 2016 11:09:12 -0700 Subject: [PATCH 02/11] Add simplify package --- package.json | 1 + script/test-readability | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 1d2c07a5576..848af896145 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "retext-english": "^2.0.0", "retext-equality": "^2.3.2", "retext-readability": "^2.0.0", + "retext-simplify": "^2.0.0", "to-vfile": "^1.0.0", "unified": "^4.1.2", "vfile-reporter": "^2.0.0" diff --git a/script/test-readability b/script/test-readability index f7254f266de..939ff10bdf3 100755 --- a/script/test-readability +++ b/script/test-readability @@ -2,9 +2,6 @@ // Retext stuff var unified = require('unified'); -var readability = require('retext-readability'); -var english = require('retext-english'); -var equality = require('retext-equality'); // Remark stuff var parse = require('remark-parse'); @@ -29,6 +26,12 @@ var options = { "readability": { "age": 18 }, + "simplify": { + ignore: [ + "modify", + "contribute" + ] + } }; var warnings = async.map(glob.sync("_content/**/*.md"), function(file, callback) { @@ -37,9 +40,10 @@ var warnings = async.map(glob.sync("_content/**/*.md"), function(file, callback) .use(parse) .use(lint, options["lint"]) .use(remark2retext, unified() - .use(english) - .use(equality) - .use(readability, options["readability"]) + .use(require('retext-english')) + .use(require('retext-simplify'), options["simplify"]) + .use(require('retext-equality')) + .use(require('retext-readability'), options["readability"]) ) .use(stringify) .process(contents.toString(), function (err, result) { From 840206fdcdb6f6585da25fdd0ca8197c949aec93 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Sat, 23 Jul 2016 00:01:32 -0400 Subject: [PATCH 03/11] Ignore node_modules directory --- .gitignore | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 653d0b0d144..25d9db75e7f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -.DS_Store -.jekyll-metadata _site/ .bundle +.DS_Store +.jekyll-metadata bin +node_modules vendor From fb781fe572354d5b39b847842e32d7eca252d358 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Mon, 25 Jul 2016 10:40:50 -0400 Subject: [PATCH 04/11] Rename test script --- script/{test-readability => test-prose} | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) rename script/{test-readability => test-prose} (85%) diff --git a/script/test-readability b/script/test-prose similarity index 85% rename from script/test-readability rename to script/test-prose index 939ff10bdf3..25748a27141 100755 --- a/script/test-readability +++ b/script/test-prose @@ -18,10 +18,11 @@ var async = require('async'); var options = { // https://github.com/wooorm/remark-lint/blob/master/doc/rules.md "lint": { - "first-heading-level": 2, // First heading should be an h2 - "list-item-indent": "space", // As the gods intended. + "list-item-indent": "space", // As the gods intended. "maximum-line-length": false, // turn off line length linting - "no-html": false // Sadly, need HTML for video embeds + "no-html": false, // Sadly, need HTML for video embeds + "no-heading-punctuation": false, + "list-item-spacing": false, }, "readability": { "age": 18 @@ -29,7 +30,8 @@ var options = { "simplify": { ignore: [ "modify", - "contribute" + "contribute", + "previous" ] } }; From b6e3d8d5172e19b71621412c0cf4ff25231d37fe Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Mon, 25 Jul 2016 10:55:21 -0400 Subject: [PATCH 05/11] Add script/bootstrap --- script/bootstrap | 3 +++ 1 file changed, 3 insertions(+) diff --git a/script/bootstrap b/script/bootstrap index 599f07e2e7d..ac3de3c6931 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -7,3 +7,6 @@ echo "==> Installing gem dependencies…" bundle check --path vendor/gems 2>&1 > /dev/null || { time bundle install --binstubs bin --path vendor/gems } + +echo "==> Installing node dependencies…" +npm install From 7424babe0aa1d8908658e566d4f9b0adc29b9ad3 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Mon, 25 Jul 2016 10:55:53 -0400 Subject: [PATCH 06/11] Add script/test --- package.json | 3 +++ script/test | 1 + 2 files changed, 4 insertions(+) diff --git a/package.json b/package.json index 848af896145..4ebd22a1e8e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,9 @@ { "name": "open-source-handbook", "private": true, + "scripts": { + "test": "script/test" + }, "devDependencies": { "async": "^1.5.2", "glob": "^7.0.5", diff --git a/script/test b/script/test index b79c950fdb8..212a6921362 100755 --- a/script/test +++ b/script/test @@ -5,3 +5,4 @@ set -e script/build --config _config.yml,test/_config.yml bundle exec rake script/html-proofer +script/test-prose From 6e879590c211d4e8c01b7e6ee8bae86648a6a4bb Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Mon, 25 Jul 2016 14:52:26 -0400 Subject: [PATCH 07/11] Remove variable assignment --- script/test-prose | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/test-prose b/script/test-prose index 25748a27141..50966ac2521 100755 --- a/script/test-prose +++ b/script/test-prose @@ -36,7 +36,7 @@ var options = { } }; -var warnings = async.map(glob.sync("_content/**/*.md"), function(file, callback) { +async.map(glob.sync("_content/**/*.md"), function(file, callback) { fs.readFile(file, function(err, contents) { unified() .use(parse) From 6cac8c9d0ef971f5ab0dfe663c98cc8e76bd1be7 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Tue, 9 Aug 2016 19:43:10 -0500 Subject: [PATCH 08/11] Ignore paths excluded by jekyll --- _config.yml | 3 +++ package.json | 1 + script/test-prose | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/_config.yml b/_config.yml index 7bb0deb670d..c4494f8281a 100644 --- a/_config.yml +++ b/_config.yml @@ -2,8 +2,11 @@ baseurl: "/open-source-handbook" exclude: - bin + - CONTRIBUTING.md - docs - Gemfile* + - node_modules + - package.json - Rakefile - README.md - script diff --git a/package.json b/package.json index 4ebd22a1e8e..d2ab26a9602 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "devDependencies": { "async": "^1.5.2", "glob": "^7.0.5", + "ignore": "^3.1.3", "remark-lint": "^4.0.1", "remark-parse": "^1.0.0", "remark-retext": "^2.0.0", diff --git a/script/test-prose b/script/test-prose index 50966ac2521..0a609c0f80f 100755 --- a/script/test-prose +++ b/script/test-prose @@ -14,6 +14,9 @@ var report = require('vfile-reporter'); var glob = require('glob'); var fs = require('fs'); var async = require('async'); +var yaml = require('js-yaml'); +var jekyllConfig = yaml.safeLoad(fs.readFileSync('_config.yml', 'utf8')); +var ignore = require('ignore')().add(jekyllConfig["exclude"]) var options = { // https://github.com/wooorm/remark-lint/blob/master/doc/rules.md @@ -36,7 +39,7 @@ var options = { } }; -async.map(glob.sync("_content/**/*.md"), function(file, callback) { +async.map(ignore.filter(glob.sync("**/*.md")), function(file, callback) { fs.readFile(file, function(err, contents) { unified() .use(parse) @@ -54,6 +57,5 @@ async.map(glob.sync("_content/**/*.md"), function(file, callback) { }); }); }, function (err, results) { - console.log("reporting"); console.log(report(results)); }); From 90718874a86e7ccb38eb756f8bc46b3dcd06d096 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Tue, 9 Aug 2016 19:56:19 -0500 Subject: [PATCH 09/11] Make the robots happy about node --- script/cibuild | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/cibuild b/script/cibuild index ecb1ca01868..d9ce5a31f8f 100755 --- a/script/cibuild +++ b/script/cibuild @@ -2,8 +2,9 @@ set -e -export PATH="/usr/share/rbenv/shims:$PATH" +export PATH="/usr/share/rbenv/shims:/usr/local/share/nodenv/shims:$PATH" export RBENV_VERSION="2.1.7-github" +export NODENV_VERSION="v0.10.21" # clean out the ruby environment export RUBYLIB= export RUBYOPT= From 11503f485118e3e432fb3528af9a808361820f6e Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Tue, 9 Aug 2016 19:58:16 -0500 Subject: [PATCH 10/11] Add js-yaml dependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index d2ab26a9602..de9b9f396b2 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "async": "^1.5.2", "glob": "^7.0.5", "ignore": "^3.1.3", + "js-yaml": "^3.6.1", "remark-lint": "^4.0.1", "remark-parse": "^1.0.0", "remark-retext": "^2.0.0", From 03d6c3295ed871c9f36d734d026f7bcfe538f180 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Thu, 11 Aug 2016 15:06:59 -0500 Subject: [PATCH 11/11] Disable prose checks for now I would like to enable these one-by-one so we can make small PRs to enable rules and fix some of the warnings. --- script/test-prose | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/script/test-prose b/script/test-prose index 0a609c0f80f..06d268adeae 100755 --- a/script/test-prose +++ b/script/test-prose @@ -44,12 +44,12 @@ async.map(ignore.filter(glob.sync("**/*.md")), function(file, callback) { unified() .use(parse) .use(lint, options["lint"]) - .use(remark2retext, unified() - .use(require('retext-english')) - .use(require('retext-simplify'), options["simplify"]) - .use(require('retext-equality')) - .use(require('retext-readability'), options["readability"]) - ) + // .use(remark2retext, unified() + // .use(require('retext-english')) + // .use(require('retext-simplify'), options["simplify"]) + // .use(require('retext-equality')) + // .use(require('retext-readability'), options["readability"]) + // ) .use(stringify) .process(contents.toString(), function (err, result) { result.filename = file;