Browse Source

Use npm script to build & publish doc

pull/682/head
Vitaly Puzrin 5 years ago
parent
commit
1c8a8ac8d2
  1. 14
      Makefile
  2. 6
      package.json
  3. 15
      support/build_doc.js

14
Makefile

@ -47,18 +47,10 @@ coverage:
npm run coverage
doc:
rm -rf ./apidoc
ndoc --link-format "https://github.com/{package.repository}/blob/${CURR_HEAD}/{file}#L{line}"
npm run doc
gh-doc: doc
touch ./apidoc/.nojekyll
cd ./apidoc \
&& git init . \
&& git add . \
&& git commit -m "Auto-generate API doc" \
&& git remote add remote git@github.com:markdown-it/markdown-it.git \
&& git push --force remote +master:gh-pages
rm -rf ./apidoc
gh-doc:
npm run gh-doc
publish:
@if test 0 -ne `git status --porcelain | wc -l` ; then \

6
package.json

@ -19,7 +19,9 @@
"lint": "eslint .",
"test": "npm run lint && nyc mocha && node support/specsplit.js test/fixtures/commonmark/spec.txt",
"coverage": "npm run test && nyc report --reporter html",
"report-coveralls": "nyc report --reporter=text-lcov | coveralls"
"report-coveralls": "nyc report --reporter=text-lcov | coveralls",
"doc": "node support/build_doc.js",
"gh-doc": "npm run doc && gh-pages -d apidoc -f"
},
"files": [
"index.js",
@ -43,6 +45,7 @@
"coveralls": "^3.0.4",
"eslint": "^6.0.1",
"express": "^4.14.0",
"gh-pages": "^2.2.0",
"highlight.js": "^9.2.0",
"markdown-it-abbr": "^1.0.4",
"markdown-it-container": "^2.0.0",
@ -59,6 +62,7 @@
"ndoc": "^5.0.0",
"nyc": "^15.0.1",
"pug-cli": "^1.0.0-alpha6",
"shelljs": "^0.8.4",
"stylus": "^0.54.5",
"supertest": "^4.0.2",
"terser": "^4.1.2"

15
support/build_doc.js

@ -0,0 +1,15 @@
#!/usr/bin/env node
'use strict';
/* eslint-env es6 */
const shell = require('shelljs');
shell.rm('-rf', 'apidoc');
const head = shell.exec('git show-ref --hash HEAD').stdout.slice(0, 6);
const link_format = `https://github.com/{package.repository}/blob/${head}/{file}#L{line}`;
shell.exec(`node node_modules/.bin/ndoc --link-format "${link_format}"`);
Loading…
Cancel
Save