From 155addd7b6cbae246601b41d2d85a25e7d7c6e8c Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Mon, 21 Jan 2019 11:44:30 +0100 Subject: [PATCH] Generate gh-pages correctly --- .gitignore | 4 ++-- .travis.yml | 4 ++-- scripts/update-docs.sh | 40 +++++++++++++++++++++++----------------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 8dd461e1..16606ba2 100644 --- a/.gitignore +++ b/.gitignore @@ -17,9 +17,9 @@ lib # os-generated files .DS_Store -# generated gitbook +# generated docs _book -gitbook +gh_pages # npm .npmrc diff --git a/.travis.yml b/.travis.yml index bc8051b4..a768dadd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ script: before_deploy: - echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc 2> /dev/null - yarn global add gitbook-cli - - yarn update-docs --scope=abi,light.js + - yarn update-docs deploy: - provider: script skip_cleanup: true @@ -28,7 +28,7 @@ deploy: - provider: pages github-token: $GH_TOKEN keep-history: true - local-dir: gitbook # The directory to be pushed to gh-pages branch + local-dir: gh_pages # The directory to be pushed to gh-pages branch skip-cleanup: true on: branch: master diff --git a/scripts/update-docs.sh b/scripts/update-docs.sh index db3237bf..1ef461d4 100755 --- a/scripts/update-docs.sh +++ b/scripts/update-docs.sh @@ -1,26 +1,20 @@ #!/bin/bash -# Generate docs for a package, and update the docs in parity-js/${package_name}, in the gh-pages branch. +# Generate docs for a package, and update the docs on the `gh-pages` branch. set -e -# Take the --scope flag if it exists -if [[ "$1" == --scope* ]]; then - SCOPES=`cut -d "=" -f 2 <<< "$1"` -fi +# These docs are generated by TypeDoc+Gitbook +GITBOOK_DOCS=(abi light.js) +# These docs are simple READMEs +README_DOCS=(api contracts electron light.js-react) -# Quit if there's no scope -[[ -z $SCOPES ]] && echo No scope provided. && exit 1 +# The directory that will be pushed to gh-pages +GHPAGES_DIR="$(pwd)/gh_pages" +mkdir -p $GHPAGES_DIR -# Find all scopes, separated by comma -IFS=',' read -r -a ARRAY <<< "$SCOPES" - -# The directory of generated gitbook html files to be pushed to gh-pages -GITBOOKDIR="$(pwd)/gitbook" -mkdir -p $GITBOOKDIR - -# Generate docs in the SCOPE folder -for SCOPE in "${ARRAY[@]}" +# Generate GITBOOK_DOCS +for SCOPE in "${GITBOOK_DOCS[@]}" do # Generate latest version of docs echo "Generating docs for $SCOPE" @@ -31,10 +25,22 @@ do gitbook build # Outputs inside a local `_book` folder # Copy these generated html docs temporarily in a temp folder - cp -r "_book" "$GITBOOKDIR/$SCOPE" + cp -r "_book" "$GHPAGES_DIR/$SCOPE" popd # Go back to root folder done +# Generate README_DOCS +for SCOPE in "${README_DOCS[@]}" +do + # Copy the README inside $GHPAGES_DIR + echo "Generating docs for $SCOPE" + mkdir -p "$GHPAGES_DIR/$SCOPE" + cp "packages/$SCOPE/README.md" "$GHPAGES_DIR/$SCOPE" +done + +# Finally, copy the main README into $GHPAGES_DIR +cp README.md $GHPAGES_DIR + # Docs are updated on master, we commit back git checkout master git add .