From fa645e434b489f1e414f569df2b26acbab2da276 Mon Sep 17 00:00:00 2001 From: Yaydoc Bot Date: Sun, 25 Jun 2017 17:25:57 +0530 Subject: [PATCH] Fixes #173: script added to generate documentation from multiple repository --- generate.sh | 17 ++++++--- multiple_generate.sh | 89 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 6 deletions(-) create mode 100755 multiple_generate.sh diff --git a/generate.sh b/generate.sh index d23a75d7..66c0e734 100755 --- a/generate.sh +++ b/generate.sh @@ -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 @@ -10,6 +10,7 @@ do m) EMAIL=${OPTARG};; u) UNIQUEID=${OPTARG};; w) WEBUI=${OPTARG};; + s) SUBPROJECT=${OPTARG};; esac done @@ -17,11 +18,15 @@ done # 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}" == "" ]; 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 diff --git a/multiple_generate.sh b/multiple_generate.sh new file mode 100755 index 00000000..cb604e77 --- /dev/null +++ b/multiple_generate.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +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/fossasia/yaydoc/master/publish_docs.sh) +fi