Created
March 27, 2013 21:40
-
-
Save PaulCapestany/5258274 to your computer and use it in GitHub Desktop.
This is an Xcode build script that turns code comments into Xcode issue warnings, creates a todo.txt for easy navigation/viewing from within the Xcode project, and also generates/updates all of the above into properly formatted markdown (including links to the lines of code for direct viewing within Github) for the README.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# turn !!!s into build warnings and generate/update README | |
# -------------------------------------------------------- | |
HIGHPRIORITY="!!!:" | |
LOWERPRIORITY="TODO:|\?\?\?:" | |
# this allows us to make sure each Github link works, regardless of branch switches | |
CURRENTBRANCH=`cat .git/HEAD | sed 's|ref: refs/heads/||'` | |
VERSIONSTRING=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}") | |
# put notes (and temporary files to be deleted) here | |
mkdir -p $PROJECT_NAME/tmp | |
# this is one huge one-line script adopted from http://www.benzado.com/blog/post/329/make-xcode-nag-you-about-unfinished-todos | |
# tee duplicates the sdout stream to a .txt without "redirecting" after the pipe | |
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -print0 | \ | |
xargs -0 egrep --with-filename --line-number --only-matching "($HIGHPRIORITY).*\$" | \ | |
perl -p -e "s/($HIGHPRIORITY)/ warning: \$1/" | \ | |
tee $PROJECT_NAME/tmp/originaloutput.txt | |
# don't show low priority items as build warnings, but redirect them for parsing | |
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -print0 | \ | |
xargs -0 egrep --with-filename --line-number --only-matching "($LOWERPRIORITY).*\$" | \ | |
perl -p -e "s/($LOWERPRIORITY)/ warning: \$1/" >> $PROJECT_NAME/tmp/originaloutput.txt | |
# parse TODO list for readability (watch out for Workspace/project/projectname ↓) | |
sed "s|$PROJECT_DIR/$PROJECT_NAME/||" $PROJECT_NAME/tmp/originaloutput.txt | awk -F": " '{ print "~~ * " $3 $4 $5 $6 $7 $8 " <<< " $1 " >>>" }' > $PROJECT_NAME/tmp/filenames.txt | |
# format LOC and file into markdown/links for Github | |
cat $PROJECT_NAME/tmp/filenames.txt | awk -F"<<< " '{ print $1 "~6969~" $2 }' | sed 's/ >>>//' > $PROJECT_NAME/tmp/tempLOC.txt | |
cat $PROJECT_NAME/tmp/tempLOC.txt | sed 's/\(.*[a-z]\)\(:\)\([0-9].*\)/\1~6969~\3/' > $PROJECT_NAME/tmp/anotherLOC.txt | |
cat $PROJECT_NAME/tmp/anotherLOC.txt | awk -F"~6969~" '{ print $1 "<a href=\"https://github.com/PaulCapestany/'"$PROJECT_NAME"'/blob/REPLACETHISTEXTWITHBRANCH/'"$PROJECT_NAME"'/" $2 "#L" $3 "\">`" $2 ":" $3 "`</a>" }' | sed 's/REPLACETHISTEXTWITHBRANCH/'"$CURRENTBRANCH"'/' > $PROJECT_NAME/tmp/yetAnotherLOC.txt | |
# "sort" simple textfile todos | |
echo -e "\n### Top Priority" > $PROJECT_NAME/tmp/sorted.txt | |
grep "!!!" $PROJECT_NAME/tmp/filenames.txt >> $PROJECT_NAME/tmp/sorted.txt | |
echo -e "\n### Upcoming" >> $PROJECT_NAME/tmp/sorted.txt | |
grep "TODO" $PROJECT_NAME/tmp/filenames.txt >> $PROJECT_NAME/tmp/sorted.txt | |
echo -e "\n### Open questions" >> $PROJECT_NAME/tmp/sorted.txt | |
grep "???" $PROJECT_NAME/tmp/filenames.txt >> $PROJECT_NAME/tmp/sorted.txt | |
sed 's/!!!//' $PROJECT_NAME/tmp/sorted.txt | sed 's/TODO//' | sed 's/???//' | sed "s/~~/\\`echo -e '\r'`/g" | tee $PROJECT_NAME/tmp/todo.txt | |
# "sort" markdown todos | |
echo -e "\n### Top Priority" > $PROJECT_NAME/tmp/sortedForMarkdown.txt | |
grep "!!!" $PROJECT_NAME/tmp/yetAnotherLOC.txt >> $PROJECT_NAME/tmp/sortedForMarkdown.txt | |
echo -e "\n### Upcoming" >> $PROJECT_NAME/tmp/sortedForMarkdown.txt | |
grep "TODO" $PROJECT_NAME/tmp/yetAnotherLOC.txt >> $PROJECT_NAME/tmp/sortedForMarkdown.txt | |
echo -e "\n### Open questions" >> $PROJECT_NAME/tmp/sortedForMarkdown.txt | |
grep "???" $PROJECT_NAME/tmp/yetAnotherLOC.txt >> $PROJECT_NAME/tmp/sortedForMarkdown.txt | |
cat $PROJECT_NAME/tmp/sortedForMarkdown.txt | sed 's/!!!//' | sed 's/TODO//' | sed 's/???//' | sed "s/~~/\\`echo -e '\r'`/g" > $PROJECT_NAME/tmp/sortedForMarkdownFinal.txt | |
# delete old todos | |
sed '/## TODO/,/<!---->/ s/.*/~~/' README.md | sed '/~~/ d' > $PROJECT_NAME/tmp/tempREADME.txt | |
# append new todos with build/version number | |
echo -e "## TODO" >> $PROJECT_NAME/tmp/tempREADME.txt | |
cat $PROJECT_NAME/tmp/sortedForMarkdownFinal.txt >> $PROJECT_NAME/tmp/tempREADME.txt | |
echo -e "\n\n_Build version REPLACEVERSION_" | sed 's/REPLACEVERSION/'"$VERSIONSTRING"'/' >> $PROJECT_NAME/tmp/tempREADME.txt | |
echo -e "\n<!---->" >> $PROJECT_NAME/tmp/tempREADME.txt | |
# replace old README | |
cat $PROJECT_NAME/tmp/tempREADME.txt > README.md | |
#cat $PROJECT_NAME/tmp/tempREADME.txt | sed 's/<<< /:/' | sed 's/ >>>//' | awk -F"<<< " '{ print "~~ * " $3 $4 $5 $6 $7 $8 " <<< " $1 " >>>" }' > README.md | |
# swap "touch" with "rm" depending on live vs. debugging these scripts (don't wanna find files in these, or have them show up in git history) | |
rm $PROJECT_NAME/tmp/anotherLOC.txt | |
rm $PROJECT_NAME/tmp/sortedForMarkdown.txt | |
rm $PROJECT_NAME/tmp/filenames.txt | |
rm $PROJECT_NAME/tmp/sortedForMarkdownFinal.txt | |
rm $PROJECT_NAME/tmp/yetAnotherLOC.txt | |
rm $PROJECT_NAME/tmp/originaloutput.txt | |
rm $PROJECT_NAME/tmp/tempLOC.txt | |
rm $PROJECT_NAME/tmp/sorted.txt | |
rm $PROJECT_NAME/tmp/tempREADME.txt | |
# | |
touch $PROJECT_NAME/tmp/todo.txt | |
touch README.md | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment