Просмотр исходного кода

Add shader file support to remove-comments.sh script

Co-authored-by: djeada <[email protected]>
copilot-swe-agent[bot] 4 дней назад
Родитель
Сommit
d0828aef09
2 измененных файлов с 23 добавлено и 4 удалено
  1. 19 1
      scripts/README.md
  2. 4 3
      scripts/remove-comments.sh

+ 19 - 1
scripts/README.md

@@ -202,11 +202,29 @@ Helper script for debugging audio issues.
 
 
 ### `remove-comments.sh` - Code Cleanup
 ### `remove-comments.sh` - Code Cleanup
 
 
-Removes comments from source files (use with caution).
+Removes comments from C/C++ source files and shader files (use with caution).
+
+**Features:**
+- ✓ Supports C/C++ files (`.c`, `.cpp`, `.h`, `.hpp`, etc.)
+- ✓ Supports shader files (`.vert`, `.frag`, `.glsl`)
+- ✓ Supports QML files (`.qml`)
+- ✓ Preserves string literals and raw strings
+- ✓ Dry-run mode available
+- ✓ Optional backup creation
 
 
 **Usage:**
 **Usage:**
 ```bash
 ```bash
+# Remove comments from all supported files in current directory
 ./scripts/remove-comments.sh
 ./scripts/remove-comments.sh
+
+# Dry-run to see what would be modified
+./scripts/remove-comments.sh --dry-run
+
+# Remove comments from shader files only
+./scripts/remove-comments.sh assets/shaders/
+
+# Create backups before modifying
+./scripts/remove-comments.sh --backup
 ```
 ```
 
 
 ---
 ---

+ 4 - 3
scripts/remove-comments.sh

@@ -5,7 +5,7 @@
 set -Eeuo pipefail
 set -Eeuo pipefail
 trap 'echo "error: line $LINENO: $BASH_COMMAND" >&2' ERR
 trap 'echo "error: line $LINENO: $BASH_COMMAND" >&2' ERR
 
 
-EXTS_DEFAULT="c,cc,cpp,cxx,h,hh,hpp,hxx,ipp,inl,tpp,qml"
+EXTS_DEFAULT="c,cc,cpp,cxx,h,hh,hpp,hxx,ipp,inl,tpp,qml,vert,frag,glsl"
 ROOTS=(".")
 ROOTS=(".")
 DRY_RUN=0
 DRY_RUN=0
 BACKUP=0          # OFF by default
 BACKUP=0          # OFF by default
@@ -14,13 +14,13 @@ EXTS="$EXTS_DEFAULT"
 
 
 usage() {
 usage() {
   cat <<'USAGE'
   cat <<'USAGE'
-remove-comments.sh - strip comments from C/C++ files.
+remove-comments.sh - strip comments from C/C++ and shader files.
 
 
 Usage:
 Usage:
   scripts/remove-comments.sh [options] [PATH ...]
   scripts/remove-comments.sh [options] [PATH ...]
 
 
 Options:
 Options:
-  -x, --ext       Comma-separated extensions to scan (default: c,cc,cpp,cxx,h,hh,hpp,hxx,ipp,inl,tpp,qml)
+  -x, --ext       Comma-separated extensions to scan (default: c,cc,cpp,cxx,h,hh,hpp,hxx,ipp,inl,tpp,qml,vert,frag,glsl)
   -n, --dry-run   Show files that would be modified; don't write changes
   -n, --dry-run   Show files that would be modified; don't write changes
   --backup        Create FILE.bak before writing (default: OFF)
   --backup        Create FILE.bak before writing (default: OFF)
   -q, --quiet     Less output
   -q, --quiet     Less output
@@ -29,6 +29,7 @@ Examples:
   scripts/remove-comments.sh
   scripts/remove-comments.sh
   scripts/remove-comments.sh --backup src/ include/
   scripts/remove-comments.sh --backup src/ include/
   scripts/remove-comments.sh -x c,cpp,hpp
   scripts/remove-comments.sh -x c,cpp,hpp
+  scripts/remove-comments.sh assets/shaders/
 USAGE
 USAGE
 }
 }