1010# Generate JSFiddle output as part of the build process.
1111NAME=$1 # The name of the folder, taken from package.json "build" line.
1212
13- # Relative path to the top-level of the examples folder.
14- # PATH_TO_DOCS=/Users/[USERNAME]/git/js-api-samples/samples
15- PATH_TO_DOCS=" $( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd ) "
16-
17- OUTPUT_DIR=${PATH_TO_DOCS}
18- DIST_DIR=" ../../dist/samples/${NAME} /jsfiddle"
13+ # /Users/[USERNAME]/git/js-api-samples/samples or similar
14+ SAMPLES_DIR=" $( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd ) " # Script directory (/samples)
15+ PROJECT_ROOT=$( dirname " $SAMPLES_DIR " ) # Get the parent directory (js-api-samples)
16+ DIST_DIR=" ${PROJECT_ROOT} /dist"
1917
2018# Create a new folder.
21- mkdir -p ${DIST_DIR}
19+ mkdir -p " ${DIST_DIR} /samples/ ${NAME} /jsfiddle "
2220
2321# Copy files
24- cp " ${OUTPUT_DIR} /${NAME} /index.js" " ${DIST_DIR} /index.js"
25- cp " ${OUTPUT_DIR} /${NAME} /index.html" " ${DIST_DIR} /index.html"
26- cp " ${OUTPUT_DIR} /${NAME} /style.css" " ${DIST_DIR} /style.css"
22+ echo " Copy ${SAMPLES_DIR} /${NAME} /index.js to ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
23+ cp " ${SAMPLES_DIR} /${NAME} /index.js" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
24+ cp " ${SAMPLES_DIR} /${NAME} /index.html" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.html"
25+ cp " ${SAMPLES_DIR} /${NAME} /style.css" " ${DIST_DIR} /samples/${NAME} /jsfiddle/style.css"
2726
2827# Remove region tags from files by type, since they all have different comment conventions.
29- sed -i " " " s/\/\/ \[START .*]//g" " ${DIST_DIR} /index.js"
30- sed -i " " " s/\/\/ \[END .*]//g" " ${DIST_DIR} /index.js"
28+ echo " Remove region tags from ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
29+ sed -i " " " s/\/\/ \[START .*]//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
30+ sed -i " " " s/\/\/ \[END .*]//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.js"
3131
32- sed -i " " " s/<!--\s*\[START .*\]\s*-->//g" " ${DIST_DIR} /index.html"
33- sed -i " " " s/<!--\s*\[END .*\]\s*-->//g" " ${DIST_DIR} /index.html"
32+ echo " Remove region tags from ${DIST_DIR} /samples/${NAME} /jsfiddle/index.html"
33+ sed -i " " " s/<!--\s*\[START .*\]\s*-->//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.html"
34+ sed -i " " " s/<!--\s*\[END .*\]\s*-->//g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/index.html"
3435
35- sed -i " " " s/\/\* \[START maps_.*] \*\///g" " ${DIST_DIR} /style.css"
36- sed -i " " " s/\/\* \[END maps_.*] \*\///g" " ${DIST_DIR} /style.css"
36+ echo " Remove region tags from ${DIST_DIR} /samples/${NAME} /jsfiddle/style.css"
37+ sed -i " " " s/\/\* \[START maps_.*] \*\///g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/style.css"
38+ sed -i " " " s/\/\* \[END maps_.*] \*\///g" " ${DIST_DIR} /samples/${NAME} /jsfiddle/style.css"
3739
3840# Generate demo.details.
39- touch " ${DIST_DIR} /demo.details"
40- cat > " ${DIST_DIR} /demo.details" << EOF
41+ echo " Generate ${DIST_DIR} /samples/${NAME} /jsfiddle/demo.details"
42+ touch " ${DIST_DIR} /samples/${NAME} /jsfiddle/demo.details"
43+ cat > " ${DIST_DIR} /samples/${NAME} /jsfiddle/demo.details" << EOF
4144name: ${NAME}
4245authors:
4346 - Geo Developer IX Documentation Team
44- tags:
47+ tags:s
4548 - google maps
4649load_type: h
47- description: Sample code for Google Maps Platform JavaScript API
48- EOF
50+ description: Sample code supporting Google Maps Platform JavaScript API documentation.
51+ EOF
0 commit comments