Fix documentation previews in pull requests (#2015)

* migrate to openzeppelin-docs-preview script

* update netlify configuration

* update docs-preview-script dependency

* remove old docs directory from gitignore

* update oz-docs script for live reload

* update oz-docs scripts to latest

* replace child_process.execFileSync with spawnSync

* update oz-docs-preview
pull/2020/head
Francisco Giordano 5 years ago committed by GitHub
parent 0c644cc470
commit b56e00eb61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .gitignore
  2. 4
      netlify.toml
  3. 3843
      package-lock.json
  4. 7
      package.json
  5. 26
      scripts/docs.sh
  6. 6
      scripts/prepare-docs.sh
  7. 6
      scripts/prepare.js

1
.gitignore vendored

@ -43,7 +43,6 @@ build/
# docs artifacts # docs artifacts
docs/modules/api docs/modules/api
openzeppelin-docs
# only used to package @openzeppelin/contracts # only used to package @openzeppelin/contracts
contracts/build/ contracts/build/

@ -1,3 +1,3 @@
[build] [build]
command = "npm run docs build" command = "npm run docs"
publish = "openzeppelin-docs/build/site" publish = "build/site"

3843
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -12,7 +12,8 @@
"scripts": { "scripts": {
"compile": "scripts/compile.sh", "compile": "scripts/compile.sh",
"coverage": "scripts/coverage.sh", "coverage": "scripts/coverage.sh",
"docs": "scripts/docs.sh", "docs": "oz-docs -c docs",
"docs:watch": "npm run docs watch contracts 'docs/*.hbs'",
"prepare-docs": "scripts/prepare-docs.sh", "prepare-docs": "scripts/prepare-docs.sh",
"lint": "npm run lint:js && npm run lint:sol", "lint": "npm run lint:js && npm run lint:sol",
"lint:fix": "npm run lint:js:fix", "lint:fix": "npm run lint:js:fix",
@ -49,7 +50,6 @@
"@openzeppelin/test-environment": "^0.1.1", "@openzeppelin/test-environment": "^0.1.1",
"@openzeppelin/test-helpers": "^0.5.4", "@openzeppelin/test-helpers": "^0.5.4",
"chai": "^4.2.0", "chai": "^4.2.0",
"concurrently": "^5.0.0",
"eslint": "^6.5.1", "eslint": "^6.5.1",
"eslint-config-standard": "^14.1.0", "eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.18.2", "eslint-plugin-import": "^2.18.2",
@ -59,11 +59,10 @@
"eslint-plugin-standard": "^4.0.1", "eslint-plugin-standard": "^4.0.1",
"ethereumjs-util": "^6.2.0", "ethereumjs-util": "^6.2.0",
"ganache-core-coverage": "https://github.com/OpenZeppelin/ganache-core-coverage/releases/download/2.5.3-coverage/ganache-core-coverage-2.5.3.tgz", "ganache-core-coverage": "https://github.com/OpenZeppelin/ganache-core-coverage/releases/download/2.5.3-coverage/ganache-core-coverage-2.5.3.tgz",
"http-server": "^0.11.1",
"lodash.startcase": "^4.4.0", "lodash.startcase": "^4.4.0",
"micromatch": "^4.0.2", "micromatch": "^4.0.2",
"mocha": "^6.2.2", "mocha": "^6.2.2",
"nodemon": "^2.0.1", "openzeppelin-docs-preview": "github:OpenZeppelin/docs-preview-script",
"solhint": "2.3.0", "solhint": "2.3.0",
"solidity-coverage": "github:rotcivegaf/solidity-coverage#5875f5b7bc74d447f3312c9c0e9fc7814b482477", "solidity-coverage": "github:rotcivegaf/solidity-coverage#5875f5b7bc74d447f3312c9c0e9fc7814b482477",
"solidity-docgen": "^0.3.13" "solidity-docgen": "^0.3.13"

@ -1,26 +0,0 @@
#!/usr/bin/env bash
if [ "$1" != "build" -a "$1" != "start" ];then
echo "usage: npm run docs (build|start)" >&2
exit 1
fi
set -o errexit
if [ ! -d openzeppelin-docs ]; then
git clone https://github.com/frangio/openzeppelin-docs.git openzeppelin-docs
fi
git -C openzeppelin-docs pull -q
if [ "$1" = "build" ]; then
npm run prepare-docs
cd docs
env DISABLE_PREPARE_DOCS= node ../openzeppelin-docs/build-local.js
elif [ "$1" = "start" ]; then
npx concurrently \
'nodemon --delay 1 -e "*" -w contracts -w "docs/*.hbs" -x npm run prepare-docs' \
'cd docs; env DISABLE_PREPARE_DOCS= nodemon --delay 1 -e adoc,yml ../openzeppelin-docs/build-local.js' \
'http-server -c-1 openzeppelin-docs/build/site'
fi

@ -1,8 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o errexit
OUTDIR=docs/modules/api/pages/ OUTDIR=docs/modules/api/pages/
npm ci if [ ! -d node_modules ]; then
npm ci
fi
rm -rf "$OUTDIR" rm -rf "$OUTDIR"
solidity-docgen -t docs -o "$OUTDIR" -e contracts/mocks,contracts/examples solidity-docgen -t docs -o "$OUTDIR" -e contracts/mocks,contracts/examples

@ -7,15 +7,11 @@ const path = require('path');
const cp = require('child_process'); const cp = require('child_process');
const match = require('micromatch'); const match = require('micromatch');
function exec (cmd, ...args) {
cp.execFileSync(cmd, args, { stdio: 'inherit' });
}
function readJSON (path) { function readJSON (path) {
return JSON.parse(fs.readFileSync(path)); return JSON.parse(fs.readFileSync(path));
} }
exec('npm', 'run', 'compile'); cp.spawnSync('npm', ['run', 'compile'], { stdio: 'inherit' });
const pkgFiles = readJSON('package.json').files; const pkgFiles = readJSON('package.json').files;

Loading…
Cancel
Save