Skip to content

Instantly share code, notes, and snippets.

@nekdenis
Created August 18, 2016 13:21
Show Gist options
  • Save nekdenis/960f5d1ca46946f54a5450bea14d0518 to your computer and use it in GitHub Desktop.
Save nekdenis/960f5d1ca46946f54a5450bea14d0518 to your computer and use it in GitHub Desktop.
Generate text file with Android fragments' names and description
#!/bin/bash
function processFile {
# echo '***'
# echo "processing $1"
echo '—————————————————————————————————————————————' >> $outputFile
fragmentName=$(basename $1 .java)
echo "Screen name: "$fragmentName >> $outputFile
echo '' >> $outputFile
# find text between "/**" and "class"
echo | awk 'f{ if (/class/){printf "%s", buf; f=0; buf=""} else buf = buf $0 ORS}; /\/\*\*/{f=1}' $1 >> $outputFile
# remove last line because it contains "public class..."
sed -i '' -e '$ d' $outputFile
# echo '***'
# exit 1
}
outputFile='generatedDoc.txt'
# Directory of project
projectDir='YOUR_DIR'
# path to directory with UI components
uiDir='app/src/main/java/YOUR_PATH'
# full parth to UI folder
path=$projectDir$uiDir
echo "deleting $outputFile"
> $outputFile
echo "start processing files in $path"
echo ls $path
# iterate over folder recursively
for f in $(find $path -name '*Fragment.java'); do
echo $f;
processFile $f;
done
echo "all files processed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment