mirror of
https://github.com/godotengine/godot-docs.git
synced 2025-12-31 17:49:03 +03:00
Add _tools folder for utility scripts
Add script to list unused images in the repository.
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -36,3 +36,7 @@ ehthumbs_vista.db
|
||||
$RECYCLE.BIN/
|
||||
logo.h
|
||||
*.autosave
|
||||
|
||||
# Output of list-unused-images.sh tool
|
||||
tmp-unused-images
|
||||
tmp-unused-images-history
|
||||
|
||||
@@ -24,10 +24,10 @@ install:
|
||||
- pip install codespell
|
||||
|
||||
script:
|
||||
- bash ./format.sh
|
||||
- bash _tools/format.sh
|
||||
|
||||
# Check for possible typos
|
||||
- codespell -I codespell-ignore.txt {about,community,development,getting_started,tutorials}/**/*.rst
|
||||
- codespell -I _tools/codespell-ignore.txt {about,community,development,getting_started,tutorials}/**/*.rst
|
||||
|
||||
# TODO: Add `-W` to turn warnings into errors.
|
||||
# This can only be done once all warnings have been fixed.
|
||||
|
||||
40
_tools/list-unused-images.sh
Normal file
40
_tools/list-unused-images.sh
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user