Skip to content

Commit 6f5420c

Browse files
author
Ian Gordon
committed
Allow script to be run from anywhere in the repo. Update script to deal with our new paths.
Reviewers: featherless, #material_components_ios_owners Reviewed By: featherless, #material_components_ios_owners Projects: #material_components_ios Differential Revision: http://codereview.cc/D111
1 parent 2b3bc8a commit 6f5420c

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

scripts/gendocs.sh

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,49 @@
11
#!/bin/bash
22

3+
JAZZY_VERSION=`jazzy --version`
4+
if [[ $? != 0 ]]; then
5+
echo "Cannot find jazzy. To install try:"
6+
echo "[sudo] gem install jazzy"
7+
exit 1
8+
fi
9+
10+
REPO_NAME="material-components-ios"
11+
12+
ORIGINAL_WORKING_DIR=`pwd`
13+
14+
#if [[ ! REPO_NAME =~ ORIGINAL_WORKING_DIR ]]; then
15+
if [[ ! $ORIGINAL_WORKING_DIR =~ $REPO_NAME ]]; then
16+
echo "Cannot find repo $REPO_NAME in $ORIGINAL_WORKING_DIR"
17+
exit 1
18+
fi
19+
20+
REPO_ROOT_DIR=`echo $ORIGINAL_WORKING_DIR | sed -n s/$REPO_NAME.*$/$REPO_NAME/p`
21+
322
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
423

5-
pushd $(dirname $DIR) >> /dev/null
24+
pushd $REPO_ROOT_DIR >> /dev/null
625

726
mkdir -p docs
827
echo -n "[" > docs/index.json
928

1029
first=true
1130

1231
# Enumerate all documentable folders
13-
for d in */.jazzy.yaml; do
32+
for d in components/*/.jazzy.yaml; do
1433
if [ "$first" = false ]; then
1534
echo -n "," >> docs/index.json
1635
fi
1736

1837
folder=$(dirname $d)
38+
component=$(basename $folder)
1939

20-
echo "Generating docs for $folder..."
40+
echo "Generating docs for $component..."
2141

2242
pushd $folder >> /dev/null
23-
jazzy --output ../docs/$folder >> /dev/null 2> /dev/null
43+
jazzy --output $REPO_ROOT_DIR/docs/$component >> /dev/null 2> /dev/null
2444
popd >> /dev/null
2545

26-
echo -n "\"$folder\"" >> docs/index.json
46+
echo -n "\"$component\"" >> docs/index.json
2747

2848
first=false
2949
done

0 commit comments

Comments
 (0)