2016-10-29 22:45:55 +02:00
|
|
|
#!/bin/bash
|
2016-12-15 03:22:26 +02:00
|
|
|
# version: 1.0.0
|
2016-10-29 22:45:55 +02:00
|
|
|
# Iterates over all patched fonts directories
|
|
|
|
# converts all non markdown readmes to markdown (e.g., txt, rst) using pandoc
|
|
|
|
# adds information on additional-variations and complete font variations
|
|
|
|
|
|
|
|
infofilename="font-info.md"
|
|
|
|
unpatched_parent_dir="src/unpatched-fonts"
|
|
|
|
patched_parent_dir="patched-fonts"
|
2017-05-14 00:02:53 +02:00
|
|
|
LINE_PREFIX="# [Nerd Fonts] "
|
2016-10-29 22:45:55 +02:00
|
|
|
|
|
|
|
cd ../../src/unpatched-fonts/ || {
|
2017-05-14 00:02:53 +02:00
|
|
|
echo >&2 "$LINE_PREFIX Could not find source fonts directory"
|
2016-10-29 22:45:55 +02:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2016-11-01 04:00:05 +02:00
|
|
|
#find ./ProFont -type d | # uncomment to test 1 font (with txt)
|
|
|
|
#find ./DejaVuSansMono -type d | # uncomment to test 1 font (with rst)
|
|
|
|
#find ./Hasklig -type d | # uncomment to test 1 font
|
|
|
|
#find ./Hack -type d | # uncomment to test 1 font (with md)
|
|
|
|
#find ./Gohu -type d | # uncomment to test 1 font (no readme files)
|
2016-10-29 22:45:55 +02:00
|
|
|
find . -type d | # uncomment to do ALL fonts
|
|
|
|
while read -r filename
|
|
|
|
do
|
|
|
|
|
|
|
|
dirname=$(dirname "$filename")
|
|
|
|
searchdir=$filename
|
|
|
|
|
|
|
|
# limit looking for the readme files in the parent dir not the child dirs:
|
|
|
|
if [[ $dirname != "." ]];
|
|
|
|
then
|
|
|
|
searchdir=$dirname
|
|
|
|
fi
|
|
|
|
|
|
|
|
RST=( $(find "$searchdir" -type f -iname 'readme.rst') )
|
|
|
|
TXT=( $(find "$searchdir" -type f -iname 'readme.txt') )
|
2016-11-01 04:00:05 +02:00
|
|
|
MD=( $(find "$searchdir" -type f -iname 'readme.md') )
|
2016-10-29 22:45:55 +02:00
|
|
|
outputdir=$PWD/../../patched-fonts/$filename/
|
|
|
|
|
2017-05-14 00:02:53 +02:00
|
|
|
echo "$LINE_PREFIX Generating readme for: $filename"
|
2016-10-29 22:45:55 +02:00
|
|
|
|
|
|
|
[[ -d "$outputdir" ]] || mkdir -p "$outputdir"
|
|
|
|
|
|
|
|
|
|
|
|
if [ "${RST[0]}" ];
|
|
|
|
then
|
|
|
|
for i in "${RST[@]}"
|
|
|
|
do
|
2017-05-14 00:02:53 +02:00
|
|
|
echo "#$LINE_PREFIX Found RST"
|
2016-10-29 22:45:55 +02:00
|
|
|
|
|
|
|
from="$PWD/$i"
|
2016-11-01 04:00:05 +02:00
|
|
|
to_dir="${PWD/$unpatched_parent_dir/$patched_parent_dir}/$filename"
|
2016-10-29 22:45:55 +02:00
|
|
|
to="${to_dir}/$infofilename"
|
|
|
|
|
|
|
|
[[ -d "$to_dir" ]] || mkdir -p "$to_dir"
|
|
|
|
# clear output file (needed for multiple runs or updates):
|
|
|
|
> "$to" 2> /dev/null
|
|
|
|
|
|
|
|
pandoc "$from" --from=rst --to=markdown --output="$to"
|
|
|
|
|
|
|
|
cat "$PWD/../../src/readme-per-directory-addendum.md" >> "$to"
|
|
|
|
done
|
|
|
|
elif [ "${TXT[0]}" ];
|
|
|
|
then
|
|
|
|
for i in "${TXT[@]}"
|
|
|
|
do
|
2017-05-14 00:02:53 +02:00
|
|
|
echo "#$LINE_PREFIX Found TXT"
|
2016-10-29 22:45:55 +02:00
|
|
|
|
|
|
|
from="$PWD/$i"
|
2016-11-01 04:00:05 +02:00
|
|
|
to_dir="${PWD/$unpatched_parent_dir/$patched_parent_dir}/$filename"
|
|
|
|
to="${to_dir}/$infofilename"
|
|
|
|
|
|
|
|
[[ -d "$to_dir" ]] || mkdir -p "$to_dir"
|
|
|
|
# clear output file (needed for multiple runs or updates):
|
|
|
|
> "$to" 2> /dev/null
|
|
|
|
|
|
|
|
cp "$from" "$to"
|
|
|
|
|
|
|
|
cat "$PWD/../../src/readme-per-directory-addendum.md" >> "$to"
|
|
|
|
done
|
|
|
|
elif [ "${MD[0]}" ];
|
|
|
|
then
|
|
|
|
for i in "${MD[@]}"
|
|
|
|
do
|
2017-05-14 00:02:53 +02:00
|
|
|
echo "#$LINE_PREFIX Found MD"
|
2016-11-01 04:00:05 +02:00
|
|
|
|
|
|
|
from="$PWD/$i"
|
|
|
|
to_dir="${PWD/$unpatched_parent_dir/$patched_parent_dir}/$filename"
|
2016-10-29 22:45:55 +02:00
|
|
|
to="${to_dir}/$infofilename"
|
|
|
|
|
|
|
|
[[ -d "$to_dir" ]] || mkdir -p "$to_dir"
|
|
|
|
# clear output file (needed for multiple runs or updates):
|
|
|
|
> "$to" 2> /dev/null
|
|
|
|
|
|
|
|
cp "$from" "$to"
|
|
|
|
|
|
|
|
cat "$PWD/../../src/readme-per-directory-addendum.md" >> "$to"
|
|
|
|
done
|
|
|
|
else
|
2017-05-14 00:02:53 +02:00
|
|
|
echo "$LINE_PREFIX Did not find RST nor TXT"
|
2016-10-29 22:45:55 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
done
|