Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
Merge 155addd into 4522821
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Jan 21, 2019
2 parents 4522821 + 155addd commit 1c96d88
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Expand Up @@ -17,9 +17,9 @@ lib
# os-generated files
.DS_Store

# generated gitbook
# generated docs
_book
gitbook
gh_pages

# npm
.npmrc
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -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
Expand All @@ -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
40 changes: 23 additions & 17 deletions 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"
Expand All @@ -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 .
Expand Down

0 comments on commit 1c96d88

Please sign in to comment.