Skip to content

Update create_overview_doc/createdoc.sh #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 43 additions & 7 deletions documentation/create_overview_doc/createdoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -512,15 +512,51 @@ function generate_mdd_overview() {
function create_find_command() {
local lang_file="$1"
local folder_to_document="$2"

# Check if language file exists
if [ ! -f "$lang_file" ]; then
echo "Error: Language file $lang_file not found." >&2
return 1
fi

# Check if file has content
if [ ! -s "$lang_file" ]; then
echo "Error: Language file $lang_file is empty." >&2
return 1
fi

# Start with base find command for the folder
local find_command="find \"$folder_to_document\" -type f"

# Read each line from CSV and append it to the find command
while IFS= read -r ext; do
find_command="$find_command -o -name \"*.$ext\""

# Flag to track if we've added extensions
local has_extensions=false
local extensions_part=""

# Read each line from CSV and build the extensions part of the command
while IFS= read -r ext || [ -n "$ext" ]; do
# Remove any carriage returns that might be present
ext=$(echo "$ext" | tr -d '\r')

# Skip empty lines
[ -z "$ext" ] && continue

if [ "$has_extensions" = false ]; then
extensions_part=" -name \"*.$ext\""
has_extensions=true
else
extensions_part="$extensions_part -o -name \"*.$ext\""
fi
done < "$lang_file"

# Correct the find command by adding parentheses and removing the first '-o'
find_command="${find_command/-o /\\( } \)"

# Check if we found any extensions
if [ "$has_extensions" = false ]; then
echo "Error: No valid extensions found in $lang_file" >&2
return 1
fi

# Add parentheses around the extensions part
find_command="$find_command \\( $extensions_part \\)"

echo "$find_command"
}

Expand Down