Skip to content

Commit

Permalink
Move docs-related code into the docs build script, rename contivModel…
Browse files Browse the repository at this point in the history
…2raml.rb -> generate_raml.rb

Signed-off-by: Bill Robinson <dseevr@users.noreply.github.com>
  • Loading branch information
dseevr committed Mar 23, 2017
1 parent 2015959 commit 1cdf3ac
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 29 deletions.
25 changes: 1 addition & 24 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,7 @@ set -euo pipefail
bash generate.sh
go install ./ ./client/

# regenerate libraries/netmaster.raml which holds the type netmaster type data
docker run --rm \
-u $(id -u):$(id -g) \
-v $(pwd):/files \
-w /files/spec \
ruby:2.4.0-slim /usr/local/bin/ruby contivModel2raml.rb ./netmaster/libraries/netmaster.raml

# run the raml2html tool to generate docs under spec/docs
# update the docs based on the latest code
pushd spec
make docs
popd

# because we have to do some tidying up of the output HTML and it requires some
# external dependencies, we use a small Docker image to do it.
# this image uses the same ruby:2.4.0-slim base as above.
IMAGE_NAME="contiv_api_documentation_cleanup"

if [[ "$(docker images -q $IMAGE_NAME:latest 2>/dev/null)" == "" ]]; then
docker build -t $IMAGE_NAME -f spec/Dockerfile.cleanup .
fi

echo "Cleaning up HTML output"
docker run --rm \
-u $(id -u):$(id -g) \
-v $(pwd):/files \
-w /files/spec \
$IMAGE_NAME /usr/local/bin/ruby cleanup.rb
41 changes: 36 additions & 5 deletions spec/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,52 @@

set -euo pipefail

IMAGE_NAME="contiv/raml2html"

mkdir -p docs

docker build -t $IMAGE_NAME .
#
# regenerate libraries/netmaster.raml which holds the type netmaster type data
#
docker run --rm \
-u $(id -u):$(id -g) \
-v $(pwd)/../:/files \
-w /files/spec \
ruby:2.4.0-slim /usr/local/bin/ruby generate_raml.rb ./netmaster/libraries/netmaster.raml

#
# convert the raml into HTML output
#
RAML_IMAGE_NAME="contiv/raml2html"

if [[ "$(docker images -q $RAML_IMAGE_NAME:latest 2>/dev/null)" == "" ]]; then
docker build -t $RAML_IMAGE_NAME .
fi

echo "generating netmaster docs"
docker run --rm \
-u $(id -u):$(id -g) \
-v $(pwd):/contiv \
$IMAGE_NAME -i netmaster.raml -o docs/contiv.html
$RAML_IMAGE_NAME -i netmaster.raml -o docs/contiv.html

echo "generating auth_proxy docs"
docker run --rm \
-u $(id -u):$(id -g) \
-v $(pwd):/contiv \
$IMAGE_NAME -i auth_proxy.raml -o docs/auth_proxy.html
$RAML_IMAGE_NAME -i auth_proxy.raml -o docs/auth_proxy.html

#
# because we have to do some tidying up of the output HTML and it requires some
# external dependencies, we use a small Docker image to do it.
# this image uses the same ruby:2.4.0-slim base as above.
#
CLEANUP_IMAGE_NAME="contiv/api_documentation_cleanup"

if [[ "$(docker images -q $CLEANUP_IMAGE_NAME:latest 2>/dev/null)" == "" ]]; then
docker build -t $CLEANUP_IMAGE_NAME -f Dockerfile.cleanup .
fi

echo "Cleaning up HTML output"
docker run --rm \
-u $(id -u):$(id -g) \
-v $(pwd):/files \
-w /files \
$CLEANUP_IMAGE_NAME /usr/local/bin/ruby cleanup.rb
File renamed without changes.

0 comments on commit 1cdf3ac

Please sign in to comment.