Skip to content

Commit 0869c2b

Browse files
authored
Merge pull request #4107 from Blargian/date_times_autogen
Functions: generate date and time functions
2 parents 243f020 + ef917a1 commit 0869c2b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

scripts/settings/autogenerate-settings.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ if [ -f "$FUNCTION_SQL_FILE" ]; then
259259
"Comparison"
260260
"Conditional"
261261
"Distance"
262+
"Dates and Times"
262263
)
263264

264265
for CATEGORY in "${FUNCTION_CATEGORIES[@]}"; do
@@ -271,15 +272,17 @@ if [ -f "$FUNCTION_SQL_FILE" ]; then
271272
}
272273

273274
# Rename the temporary output file to the correct name
274-
CATEGORY_LOWER=$(echo "$CATEGORY" | tr '[:upper:]' '[:lower:]')
275+
# Category can be "Dates and Times" for example, resulting in `dates and times-functions.md` so we change spaces to underscores
276+
CATEGORY_LOWER=$(echo "$CATEGORY" | tr '[:upper:]' '[:lower:]' | tr ' ' '_')
275277
if [ -f "temp-functions.md" ]; then
278+
echo "${CATEGORY_LOWER}-functions.md"
276279
mv "temp-functions.md" "${CATEGORY_LOWER}-functions.md" || {
277280
echo "[$SCRIPT_NAME] Error: Failed to rename temp-functions.md to ${CATEGORY_LOWER}-functions.md"
278281
exit 1
279282
}
280283
echo "[$SCRIPT_NAME] Generated ${CATEGORY_LOWER}-functions.md"
281284
else
282-
echo "[$SCRIPT_NAME] Warning: temp-functions.md not found after processing $CATEGORY functions"
285+
echo "[$SCRIPT_NAME] Warning: temp-functions.md not found for $CATEGORY"
283286
fi
284287
done
285288
else
@@ -360,7 +363,9 @@ insert_src_files=(
360363
"comparison-functions.md"
361364
"conditional-functions.md"
362365
"distance-functions.md"
366+
"dates_and_times-functions.md"
363367
)
368+
364369
insert_dest_files=(
365370
"docs/about-us/beta-and-experimental-features.md"
366371
"docs/sql-reference/functions/arithmetic-functions.md"
@@ -370,8 +375,10 @@ insert_dest_files=(
370375
"docs/sql-reference/functions/comparison-functions.md"
371376
"docs/sql-reference/functions/conditional-functions.md"
372377
"docs/sql-reference/functions/distance-functions.md"
378+
"docs/sql-reference/functions/date-time-functions.md"
373379
)
374-
echo "[$SCRIPT_NAME] Inserting generated markdown content between <!-- AUTOGENERATED_START --> <!-- AUTOGENERATED_END --> tags"
380+
381+
echo "[$SCRIPT_NAME] Inserting generated markdown content between AUTOGENERATED_START and AUTOGENERATED_END tags"
375382
for i in "${!insert_src_files[@]}"; do
376383
src_file="${insert_src_files[i]}"
377384

@@ -405,7 +412,7 @@ for i in "${!insert_src_files[@]}"; do
405412
# Replace the original file with the modified content
406413
mv "$tmp_file" "$dest_full_path"
407414
else
408-
echo "[$SCRIPT_NAME] Error: Expected to find <!--AUTOGENERATED_START--> and <!--AUTOGENERATED_END--> tags in $dest_full_path, but did not"
415+
echo "[$SCRIPT_NAME] Error: Expected to find AUTOGENERATED_START and AUTOGENERATED_END tags in $dest_full_path, but did not"
409416
exit 1
410417
fi
411418

@@ -424,7 +431,7 @@ cd "$parent_of_tmp" || echo "[$SCRIPT_NAME] Warning: Failed to cd back to parent
424431
echo "[$SCRIPT_NAME] Removing contents of temporary directory: $tmp_dir"
425432
# Use full path for removal just in case cd failed
426433
rm -rf "$tmp_dir"/*
427-
rmdir "$tmp_dir" 2>/dev/null || echo "[$SCRIPT_NAME] Info: Did not remove $tmp_dir (might contain hidden files or already gone)."
434+
rmdir "$tmp_dir" 2>/dev/null || echo "[$SCRIPT_NAME] Unable to remove $tmp_dir"
428435

429436
echo "[$SCRIPT_NAME] Auto-generation of settings markdown pages completed successfully."
430437
exit 0

0 commit comments

Comments
 (0)