Created
August 21, 2015 08:15
-
-
Save MechCoder/fdc77f62050f2f698484 to your computer and use it in GitHub Desktop.
Replace since by Since
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
echo "Enter file name" | |
read file_name | |
output=$(grep -n 'since' $file_name) | |
echo "$output" > tmp.txt | |
while read name | |
do | |
IFS=': ' read -ra line_and_since <<< "$name" | |
line_no="${line_and_since[0]}" | |
version_no="${line_and_since[-1]}" | |
next_line=$((line_no + 1)) | |
echo "${name}" | |
sed -i "${line_no}s/ @since [0-9].[0-9].[0-9]/\//" "$file_name" | |
sed -i "${next_line}s/*\//@Since(\"${version_no}\")/" "$file_name" | |
sed -i "${next_line}s/ @Since/@Since/" "$file_name" | |
done < tmp.txt | |
# This is to remove empty docstrings, however it fails in badly formatted docs. | |
# x=0 | |
# output=$(grep -n 'Since' $file_name) | |
# echo "$output" > tmp.txt | |
# while read name | |
# do | |
# IFS=': ' read -ra line_and_since <<< "$name" | |
# line_no="${line_and_since[0]}" | |
# version_no="${line_and_since[-1]}" | |
# prev_line=$((line_no - 2 - x)) | |
# line="`sed -n "${prev_line}p" "$file_name"`" | |
# if [[ `echo $line | grep '/\/*/*' ` ]] | |
# then | |
# # Remove empty docstrings like | |
# # /** | |
# # */ | |
# if [[ "${#line}" -eq 3 ]] | |
# then | |
# x=$((x - 2)) | |
# sed -i "${prev_line}d" "$file_name" | |
# sed -i "${prev_line}d" "$file_name" | |
# fi | |
# fi | |
# done < tmp.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment