Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #173: script added to generate documentation from multiple repository #174

Merged
merged 1 commit into from
Jun 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}" == "" ]; 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
89 changes: 89 additions & 0 deletions multiple_generate.sh
Original file line number Diff line number Diff line change
@@ -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 ./
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The index generated by genindex.py differs from what is needed as the index for a master project. For now assume that the user provides a suitable index and proceed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right now build dir will look like this

Project1
Project2

all the files will be removed and docs/ folder files will be copied to specific project folder. Then I'm generating index.rst from the root.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last issue, what about the README's of the sub-projects. since they won't be in subproject/docs, they won't be included in the build. How about, if we copy the entire repo inside BUILD_DIR and visit subproject/docs and generate index if needed for each subproject and then, for the main index, we just add a toctree with links to all sub-indices? views @Sch00lb0y @imujjwal96

Copy link
Contributor Author

@poonai poonai Jun 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it is a good idea. Should I work on this now? or to raise a new issue after the merge. Cause meanwhile I can work on WEBUI and you guys can work on travis

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool. Just create a new issue and this PR should be good to go

Copy link
Contributor Author

@poonai poonai Jun 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@imujjwal96

From where have you generated the start page?

Please check this discussion for this

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