Created
August 2, 2016 17:18
-
-
Save ymek/c846281dcae8910e5c94e14ded3cfdbd to your computer and use it in GitHub Desktop.
Generate HTML/Markdown from RAML on file changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Attempts to regenerate HTML and Markdown files from RAML upon component | |
# file changes. | |
# | |
# NOTE: Requires `fswatch` | |
FSWATCH=$(which fswatch) | |
RAML2HTML=$(which raml2html) | |
RAML2MD=$(which raml2md) | |
EXCLUSION_PATTERN=".*" | |
INCLUSION_PATTERN=".*\.([ry]aml|example|schema|json)" | |
RAML_DOCNAME="agents" | |
WATCH_FOLDER="./" | |
# Check for supporting libs | |
[[ -e ${FSWATCH} ]] || echo "fswatch not found. Run 'brew install fswatch' and try again." | |
[[ -e ${RAML2HTML} ]] || echo "raml2html not found. Run 'npm install -g raml2tml' and try again." | |
[[ -e ${RAML2MD} ]] || echo "raml2md not found. Run 'npm install -g raml2md' and try again." | |
[[ -e ${FSWATCH} && -e ${RAML2HTML} && -e ${RAML2MD} ]] || exit 1 | |
${FSWATCH} -r -o -E -e "${EXCLUSION_PATTERN}" -i "${INCLUSION_PATTERN}" ${WATCH_FOLDER} | \ | |
xargs -I'{}' sh -c \ | |
"${RAML2HTML} ${RAML_DOCNAME}.raml > _generated/${RAML_DOCNAME}.html && \ | |
${RAML2MD} ${RAML_DOCNAME}.raml > _generated/${RAML_DOCNAME}.md" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment