Skip to content

Commit

Permalink
Fixes #173: script added to generate documentation from multiple repo…
Browse files Browse the repository at this point in the history
…sitory
  • Loading branch information
poonai committed Jun 25, 2017
1 parent d2dec0f commit 00a0b84
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 6 deletions.
17 changes: 11 additions & 6 deletions generate.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

while getopts g:t:d:m:u:w: option
while getopts g:t:d:m:u:w:s: option
do
case "${option}"
in
Expand All @@ -10,18 +10,23 @@ do
m) EMAIL=${OPTARG};;
u) UNIQUEID=${OPTARG};;
w) WEBUI=${OPTARG};;
s) SUBPROJECT=${OPTARG};;
esac
done

# Ensures that BASE has contents of yaydoc repository
# and change current directory to git repository.
if [ "${WEBUI:-false}" == "true" ]; then
BASE=$(pwd)
mkdir -p temp/${EMAIL} && cd $_

echo -e "Cloning Repository...\n"
git clone -q ${GITURL} "$UNIQUEID" && cd $_
echo -e "Repository Cloned Successfully!\n"
if ! [ "${SUBPROJECT:-nothing}" == "nothing" ]; then
. ./multiple_generate.sh
exit 0
else
mkdir -p temp/${EMAIL} && cd $_
echo -e "Cloning Repository...\n"
git clone -q ${GITURL} "$UNIQUEID" && cd $_
echo -e "Repository Cloned Successfully!\n"
fi
else
git clone -q https://github.com/fossasia/yaydoc.git yaydocclone
BASE=$(pwd)/yaydocclone
Expand Down
100 changes: 100 additions & 0 deletions multiple_generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/bin/bash

#while getopts g:s:e:u: option
#do
# case "${option}"
# in
# g) GITURL=${OPTARG};;
# s) SUBPROJECT=${OPTARG};;
# e) EMAIL=${OPTARG};;
# u) UNIQUEID=${OPTARG};;
# esac
#done

function clean() {
rm -rf $BUILD_DIR
}

function cloner() {
URL_SPLIT=(${1//// })
REPONAME=(${URL_SPLIT[3]//./ })
git clone $1 ${REPONAME}_temp &
}

function repoCleaner() {
URL_SPLIT=(${1//// })
REPONAME=(${URL_SPLIT[3]//./ })
cd ${REPONAME}_temp
mkdir ../$REPONAME
cp -a docs/. ../$REPONAME/.
cd ..
rm -rf ${REPONAME}_temp
}

BASE=$(pwd)

if [ "${WEBUI:-false}" == "true" ]; then
BUILD_DIR=$(pwd)/temp/$EMAIL/$UNIQUEID
mkdir -p $BUILD_DIR
cd $BUILD_DIR
else
git clone https://github.com/fossasia/yaydoc.git yaydocclone
BASE=$(pwd)/yaydocclone
BUILD_DIR=$(pwd)/temp
echo -e "build dir"
echo -e $BUILD_DIR
mkdir -p $BUILD_DIR
cd $BUILD_DIR
fi

cloner $GITURL

IFS=', ' read -r -a SUBPROJECTS <<< "$SUBPROJECT"

for element in "${SUBPROJECTS[@]}"
do
cloner $element
done

wait

repoCleaner $GITURL
for element in "${SUBPROJECTS[@]}"
do
repoCleaner $element
done

cp -a ${BASE}/modules/scripts/ $BUILD_DIR/
cp -a ${BASE}/modules/templates/ $BUILD_DIR/

mkdir _themes

cp -a ${BASE}/fossasia_theme $BUILD_DIR/_themes/

URL_SPLIT=(${GITURL//// })
USERNAME=${URL_SPLIT[2]}
REPONAME=(${URL_SPLIT[3]//./ })

pip install -r $BASE/requirements.txt
sphinx-quickstart -q -v "($(date +%Y-%m-%d.%H:%M:%S))" -a $USERNAME -p $REPONAME -t templates/ -d html_theme=alabaster -d html_logo=$LOGO

rm index.rst

python $BASE/modules/scripts/genindex.py ./
make html
shopt -s extglob
if [ "${WEBUI:-false}" == "true" ]; then


rm -r !(_build)

cp -a _build/html/. ./

rm -r _build

cd ..
mv ${UNIQUEID} ${UNIQUEID}_preview
zip -r -q ${UNIQUEID}.zip ${UNIQUEID}_preview
else
source <(curl -s https://raw.githubusercontent.com/sch00lb0y/yaydoc/script/publish_docs.sh)
fi

0 comments on commit 00a0b84

Please sign in to comment.