Browse files

added options to control publishing, editing the commit

  • Loading branch information...
1 parent 4162f78 commit 60f057bf83ca3a248025a2df21242474021dfe36 @samdeane committed Sep 3, 2012
Showing with 57 additions and 29 deletions.
  1. +57 −29
@@ -5,7 +5,7 @@
# Run this script from the root of your project.
# It makes a temporary directory and generates appledoc documentation for your
-# project in that directory.
+# project in that directory.
# It then makes a local clone of your documentation branch (called gh-pages, by default)
# copies the generated appledoc html into a folder in the branch (called Documentation by default)
# commits the new documentation and pushes it back to the project repo.
@@ -17,7 +17,7 @@
# - the name of the root folder is the name of the project
# - your appledoc templates are in ~/.appledoc (can be a symlink)
# - you have a GlobalSettings.plist file in your appledoc templates folder
-# - you've set values in GlobalSettings.plist for --project-company, --company-id
+# - you've set values in GlobalSettings.plist for --project-company, --company-id
# The script looks at the remotes configured in the repo to try to work out what your github
# user name is, so that it can generate the correct urls for a docset feed.
@@ -29,11 +29,14 @@ originaldirectory=`git rev-parse --show-toplevel`
codebranch=`$git rev-parse --abbrev-ref HEAD`
projectname=`basename "$PWD"`
initialdefaultcommitmessage="Initial documentation"
updatedefaultcommitmessage="Update documentation"
# find real templates location (.appledoc might be a link)
pushd $HOME > /dev/null
@@ -58,8 +61,8 @@ githubuser=${BASH_REMATCH[2]}
# if we're on the documentation branch, something's gone wrong
if [[ "$codebranch" == "gh-pages" ]]
- echo "You seem to be on the gh-pages branch. Checkout a code branch instead."
- exit 1
+echo "You seem to be on the gh-pages branch. Checkout a code branch instead."
+exit 1
echo "Generating documentation for $projectname"
@@ -68,38 +71,43 @@ echo "Generating documentation for $projectname"
rm -rf "$tempdir"
mkdir -p -v "$tempdir"
+# include settings file if it's present
+if [ -e ./.appledoc.plist ]; then
+echo "Found appledoc settings file"
# generate docset and html, install docset in xcode, create atom feed and downloadable package
appledoc \
- --templates "$templates" \
- --keep-intermediate-files \
- --create-html \
- --create-docset \
- --install-docset \
- --publish-docset \
- --docsetutil-path "$docsetutil" \
- --docset-atom-filename "docset.atom" \
- --docset-feed-url "http://$$projectname/$docdirectory/%DOCSETATOMFILENAME" \
- --docset-package-url "http://$$projectname/$docdirectory/%DOCSETPACKAGEFILENAME" \
- --docset-fallback-url "http://$$docdirectory/" \
- --project-name $projectname \
- -o "$tempdir" "$@" ./
+--templates "$templates" \
+--keep-intermediate-files \
+--create-html \
+--create-docset \
+--install-docset \
+--publish-docset \
+--docsetutil-path "$docsetutil" \
+--docset-atom-filename "docset.atom" \
+--docset-feed-url "http://$$projectname/$docdirectory/%DOCSETATOMFILENAME" \
+--docset-package-url "http://$$projectname/$docdirectory/%DOCSETPACKAGEFILENAME" \
+--docset-fallback-url "http://$$docdirectory/" \
+--project-name $projectname \
+-o "$tempdir" "$@" $settings ./
# clone doc branch of current repo into temporary location
$git clone "$originaldirectory" "$tempdir/branch"
if $git show-ref --tags --quiet --verify -- "refs/heads/$docbranch"
- cd "$tempdir/branch"
- echo "Checking out $docbranch branch"
- $git checkout $docbranch
+pushd "$tempdir/branch" > /dev/null
+echo "Checking out $docbranch branch"
+$git checkout $docbranch
- cd "$tempdir/branch"
- echo "Creating $docbranch branch"
- defaultcommitmessage=$initialdefaultcommitmessage
- $git symbolic-ref HEAD "refs/heads/$docbranch"
- rm .git/index
- $git clean -fdx
+pushd "$tempdir/branch" > /dev/null
+echo "Creating $docbranch branch"
+$git symbolic-ref HEAD "refs/heads/$docbranch"
+rm .git/index
+$git clean -fdx
# make sure stale docs are removed - re-adding will cause an update
@@ -110,16 +118,36 @@ mkdir "$docdirectory"
mv -v ../html/* "$docdirectory"
mv -v ../publish/* "$docdirectory"
-# add directory and commit with default message, allowing editing
+# add directory and commit with default message
$git add -f -v "$docdirectory"
+if $editcommit; then
$git commit -e -m "$defaultcommitmessage"
+$git commit -m "$defaultcommitmessage"
# push changes back to our repo
$git push origin $docbranch
# remove temporary directory
rm -rf "$tempdir"
-echo "Feed URL is at http://$$projectname/$docdirectory/docset.atom"
+popd > /dev/null
+# if publishing is on, push the documentation pages, otherwise echo out the command that would push them
+if $publish ; then
+git push $githubrepo $docbranch:$docbranch
echo "To push the documentation changes, do:"
echo "git push $githubrepo $docbranch:$docbranch"
+# echo info on the location of the feed
+echo "Feed URL is at http://$$projectname/$docdirectory/docset.atom"
+echo "Documentation changes may take a while to filter through..."
+# open the top of the documentation pages in the browser
+if $open ; then
+open "http://$$projectname/$docdirectory"

0 comments on commit 60f057b

Please sign in to comment.