Skip to content

Commit

Permalink
Added CircleCI script for generating the profile resolution specifica…
Browse files Browse the repository at this point in the history
…tion (#23)
  • Loading branch information
david-waltermire authored and wendellpiez committed Jan 2, 2020
1 parent 1936a2b commit 258d061
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ jobs: # a collection of
name: Generate schema documentation
command: |
bash "$CICD_DIR/generate-model-documentation.sh" -w "$OSCAL_BUILD_DIR"
- run:
name: Generate specification documentation
command: |
bash "$CICD_DIR/generate-specification-documentation.sh" -w "$OSCAL_BUILD_DIR"
- run:
name: Compress built docs
command: |
Expand Down
77 changes: 77 additions & 0 deletions build/ci-cd/generate-specification-documentation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

if [[ -z "$OSCALDIR" ]]; then
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
source "$DIR/include/common-environment.sh"
fi
source "$OSCALDIR/build/ci-cd/include/saxon-init.sh"

# Option defaults
WORKING_DIR="${OSCALDIR}"
VERBOSE=false
HELP=false

usage() { # Function: Print a help message.
cat << EOF
Usage: $0 [options] [metaschema paths]
-h, --help Display help
-w DIR, --working-dir DIR Generate artifacts in DIR
-v Provide verbose output
EOF
}

OPTS=`getopt -o w:vh --long working-dir:,help -n "$0" -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; usage ; exit 1 ; fi

# Process arguments
eval set -- "$OPTS"
while [ $# -gt 0 ]; do
arg="$1"
case "$arg" in
-w|--working-dir)
WORKING_DIR="$(realpath "$2")"
shift # past path
;;
-v)
VERBOSE=true
;;
-h|--help)
usage
exit 0
;;
--) # end of options
shift
break;
;;
*) # unknown option
echo "Unhandled option: $1"
exit 1
;;
esac
shift # past argument
done

OTHER_ARGS=$@ # save the remaining args

echo -e ""
echo -e "${P_INFO}Generating XML <-> JSON Content Converters${P_END}"
echo -e "${P_INFO}==========================================${P_END}"

if [ "$VERBOSE" = "true" ]; then
echo -e "${P_INFO}Using working directory:${P_END} ${WORKING_DIR}"
fi

SPEC_SOURCE="${OSCALDIR}/src/specifications/profile-resolution/profile-resolution-specml.xml"
SPEC_OUTPUT="$WORKING_DIR/docs/content/documentation/specification/processing/profile-resolution.html"

result=$(xsl_transform "$OSCALDIR/src/specifications/profile-resolution//specml-html-hugo-uswds.xsl" "${SPEC_SOURCE}" "${SPEC_OUTPUT}" 2>&1)
cmd_exitcode=$?
if [ $cmd_exitcode -ne 0 ]; then
echo -e "${P_ERROR}Generating specification '${P_END}${SPEC_SOURCE}${P_ERROR}' to '${P_END}${SPEC_OUTPUT}${P_ERROR}'.${P_END}"
echo -e "${P_ERROR}${result}${P_END}"
exitcode=1
else
echo -e "${P_OK}Generating specification '${P_END}${SPEC_OUTPUT}${P_OK}' was successful for '${P_END}${SPEC_SOURCE}${P_OK}.${P_END}"
fi

0 comments on commit 258d061

Please sign in to comment.