Update script

This commit is contained in:
Stefan Thoss
2025-09-04 11:54:55 -07:00
parent 7f1f8a17d5
commit d73e35068e
2 changed files with 61 additions and 38 deletions
+37 -14
View File
@@ -4,23 +4,46 @@ HEADER_FILE="readme-header.md"
README_FILE="README.md"
# Create or truncate the README file
> $README_FILE
> "$README_FILE"
# Add the header to the README file
cat $HEADER_FILE >> $README_FILE
cat "$HEADER_FILE" >> "$README_FILE"
# Loop through each directory in the current working directory
for dir in */; do
# Extract and print the directory name without the trailing slash
echo -e "\n## ${dir%/}\n" >> $README_FILE
# Get a list of Git‑tracked directories (unique, sorted)
git_dirs=$(git ls-files | cut -d'/' -f1 | sort -u)
# Loop through all PNG files in the directory and embed them in the README file
for png in "$dir"*.png; do
[ -f "$png" ] || break # Break if no more PNG files are found
echo "![${png##*/}](${png})" >> $README_FILE
done
# Loop through each tracked directory
for dir in $git_dirs; do
# Ensure it's a directory
[ -d "$dir" ] || continue
# Print a list of .scad files in the directory
echo -e "\nModel files:\n" >> $README_FILE
find "$dir" -type f -name '*.scad' | sed "s|$dir||g" | awk '{ print "* " $0 }' >> $README_FILE
# Add the section header
echo -e "\n## ${dir}\n" >> "$README_FILE"
# Embed PNG images
png_files=$(find "$dir" -maxdepth 1 -type f -name '*.png')
if [ -n "$png_files" ]; then
for png in $png_files; do
echo "![${png##*/}](${png})" >> "$README_FILE"
done
fi
# Add links to Markdown files
md_files=$(find "$dir" -maxdepth 1 -type f -name '*.md')
if [ -n "$md_files" ]; then
echo -e "\nDocumentation:\n" >> "$README_FILE"
for md in $md_files; do
echo "* [${md##*/}](${md})" >> "$README_FILE"
done
fi
# List .scad files
echo -e "\nModel files:\n" >> "$README_FILE"
scad_files=$(find "$dir" -type f -name '*.scad')
if [ -n "$scad_files" ]; then
for scad in $scad_files; do
# Strip leading directory component
echo "* ${scad#$dir/}" >> "$README_FILE"
done
fi
done