From 9b0b8cb9fea75e4cd565d6b714424d33de9cda93 Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Wed, 13 Dec 2017 21:58:22 -0800 Subject: [PATCH] fix local documentation problems; closes #3157 [ci skip] - update `Gemfile.lock` - rename `prebuild-docs.js` to `docs-update-toc.js` - fix `buildDocs` and `serveDocs` options and ensure TOC is updated - trim extra newlines from EOF in `index.md` after TOC update is run --- Gemfile.lock | 1 + package.json | 7 ++++--- scripts/{pre-build-docs.js => docs-update-toc.js} | 8 +++++--- 3 files changed, 10 insertions(+), 6 deletions(-) rename scripts/{pre-build-docs.js => docs-update-toc.js} (78%) diff --git a/Gemfile.lock b/Gemfile.lock index 33a59259ef..0844f4a345 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,4 +1,5 @@ GEM + remote: https://rubygems.org/ specs: addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) diff --git a/package.json b/package.json index 1fcbd718ed..c1161d9b74 100644 --- a/package.json +++ b/package.json @@ -304,9 +304,10 @@ "test": "make clean && make test", "prepublishOnly": "npm test && make clean && make mocha.js", "coveralls": "nyc report --reporter=text-lcov | coveralls", - "prebuildDocs": "node scripts/pre-build-docs.js", - "buildDocs": "bundle exec jekyll build --source docs --destination docs/_site --layouts docs/_layouts --safe --drafts", - "serveDocs": "bundle exec jekyll serve --config docs/_config.yml --safe --drafts --watch" + "prebuildDocs": "node scripts/docs-update-toc.js", + "buildDocs": "bundle exec jekyll build --source ./docs --destination ./docs/_site --config ./docs/_config.yml --safe --drafts", + "prewatchDocs": "node scripts/docs-update-toc.js", + "watchDocs": "bundle exec jekyll serve --source ./docs --destination ./docs/_site --config ./docs/_config.yml --safe --drafts --watch" }, "dependencies": { "browser-stdout": "1.3.0", diff --git a/scripts/pre-build-docs.js b/scripts/docs-update-toc.js similarity index 78% rename from scripts/pre-build-docs.js rename to scripts/docs-update-toc.js index e4e661602e..93da9aadca 100755 --- a/scripts/pre-build-docs.js +++ b/scripts/docs-update-toc.js @@ -24,8 +24,10 @@ fs.createReadStream(docsFilepath) .on('close', () => { console.log('Done.'); }) - .pipe(utils.concat( - input => fs.writeFileSync(docsFilepath, toc.insert(String(input), { + .pipe(utils.concat(input => { + const output = toc.insert(String(input), { bullets: '-', maxdepth: 2 - })))); + }).replace(/\n\n$/, '\n'); + return fs.writeFileSync(docsFilepath, output); + }));