forked from godotengine/godot-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add _tools folder for utility scripts
Add script to list unused images in the repository.
- Loading branch information
Showing
5 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
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
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
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
check_git_history=false | ||
|
||
rm -f tmp-unused-images | ||
rm -f tmp-unused-images-history | ||
|
||
# List images which might be unused. | ||
# Exceptions are ignored, and for .svg files we also look for potential .png | ||
# files with the same base name, as they might be sources. | ||
|
||
exceptions="docs_logo.png tween_cheatsheet.png" | ||
|
||
files=$(find -name "_build" -prune -o \( -name "*.png" -o -name "*.jpg" -o -name "*.svg" -o -name "*.gif" \) -print | sort) | ||
|
||
for path in $files; do | ||
file=$(basename $path) | ||
if echo "$exceptions" | grep -q "$file"; then | ||
continue | ||
fi | ||
ext=${file##*.} | ||
base=${file%.*} | ||
found=$(rg -l ":: .*[ /]$file") | ||
if [ -z "$found" -a "$ext" == "svg" ]; then | ||
# May be source file. | ||
found=$(rg -l ":: .*[ /]$base.png") | ||
fi | ||
if [ -z "$found" ]; then | ||
echo "$path" >> tmp-unused-images | ||
fi | ||
done | ||
|
||
|
||
if [ "$check_git_history" = true ]; then | ||
for file in $(cat tmp-unused-images); do | ||
echo "File: $file" | ||
git log --diff-filter=A --follow $file | ||
echo | ||
done > tmp-unused-images-history | ||
fi |