Skip to content

Instantly share code, notes, and snippets.

@sumchattering
Created July 12, 2011 09:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sumchattering/1077672 to your computer and use it in GitHub Desktop.
Save sumchattering/1077672 to your computer and use it in GitHub Desktop.
Script to be used within xcode as a build phase to generate documentation with appledoc
#!/bin/sh
# Script to be used within xcode to generate documentation through appledoc
# Prior to the execution of this script the appledoc executable and templates should have been copied
# to the appledoc folder in the project root directory
#
# Created by Sumeru Chatterjee when he was awake till 7 AM on July 12 2011
# https://gist.github.com/1077672
#Company Name the only variable that I cant seem to grab from the environment_variables
COMPANY=My_Company_Name
#path to the appledoc directory
DOC_DIR="$PROJECT_DIR"/appledoc
#Path to Appledoc executable
APPLEDOC="$DOC_DIR"/appledoc
echo "Checking For Appledoc Executable at ${APPLEDOC}"
if [[ ! `ls "${APPLEDOC}"` ]]
then
exit -1
fi
#The Templates Directory
TEMPLATE_DIR="$DOC_DIR"/Templates
#The Output Directory
OUTPUT_DIR="$DOC_DIR"/Output
#Company ID
COMPANY_SMALL=`echo $COMPANY | tr A-Z a-z`
COMPANY_ID="com.${COMPANY_SMALL}"
echo "Running appledoc to Generate Documentation From Header Files"
"${APPLEDOC}" --templates "${TEMPLATE_DIR}" --project-name ${PROJECT} --project-company ${COMPANY} --company-id ${COMPANY_ID} --output "${OUTPUT_DIR}" --keep-intermediate-files --keep-undocumented-objects --keep-undocumented-members --search-undocumented-doc --merge-categories --logformat xcode "$DOC_DIR"/Headers
#Delete Copied Headers
rm "$DOC_DIR"/Headers/*
#The address of the Web Server root on a mac
WEB_SERVER_ROOT=/Library/WebServer/Documents
PROJECT_SMALL=`echo $PROJECT | tr A-Z a-z`
WEBDOC_DIR_NAME="${PROJECT_SMALL}doc"
if [ ! -d "$WEB_SERVER_ROOT/$WEBDOC_DIR" ]; then
echo "Creating Directory ${WEB_SERVER_ROOT}/${WEBDOC_DIR_NAME}"
mkdir $WEB_SERVER_ROOT/$WEBDOC_DIR_NAME
else
echo "Cleaning Previous Documentation from ${WEB_SERVER_ROOT}/${WEBDOC_DIR_NAME}"
rm -rf $WEB_SERVER_ROOT/$WEBDOC_DIR_NAME/*
fi
echo "Copying Generated HTML to ${WEB_SERVER_ROOT}/${WEBDOC_DIR_NAME}"
cp -R "$DOC_DIR"/output/html/* $WEB_SERVER_ROOT/$WEBDOC_DIR_NAME
if [ $? -eq 0 ] ; then
echo "Files Copied Successfully.Now go to http://127.0.0.1/${WEBDOC_DIR_NAME} to view the documentation"
exit 0;
else
echo "ERROR: failed to copy files to webserver directory"
exit -1;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment