Skip to content

Commit 38f278b

Browse files
committed
generate date and time functions
1 parent f373522 commit 38f278b

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

scripts/settings/autogenerate-settings.sh

Lines changed: 13 additions & 7 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,16 @@ 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_LOWER=$(echo "$CATEGORY" | tr '[:upper:]' '[:lower:]' | tr ' ' '_')
275276
if [ -f "temp-functions.md" ]; then
277+
echo "${CATEGORY_LOWER}-functions.md"
276278
mv "temp-functions.md" "${CATEGORY_LOWER}-functions.md" || {
277279
echo "[$SCRIPT_NAME] Error: Failed to rename temp-functions.md to ${CATEGORY_LOWER}-functions.md"
278280
exit 1
279281
}
280282
echo "[$SCRIPT_NAME] Generated ${CATEGORY_LOWER}-functions.md"
281283
else
282-
echo "[$SCRIPT_NAME] Warning: temp-functions.md not found after processing $CATEGORY functions"
284+
echo "[$SCRIPT_NAME] Warning: temp-functions.md not found for $CATEGORY"
283285
fi
284286
done
285287
else
@@ -360,7 +362,9 @@ insert_src_files=(
360362
"comparison-functions.md"
361363
"conditional-functions.md"
362364
"distance-functions.md"
365+
"dates_and_times-functions.md"
363366
)
367+
364368
insert_dest_files=(
365369
"docs/about-us/beta-and-experimental-features.md"
366370
"docs/sql-reference/functions/arithmetic-functions.md"
@@ -370,8 +374,10 @@ insert_dest_files=(
370374
"docs/sql-reference/functions/comparison-functions.md"
371375
"docs/sql-reference/functions/conditional-functions.md"
372376
"docs/sql-reference/functions/distance-functions.md"
377+
"docs/sql-reference/functions/date-time-functions.md"
373378
)
374-
echo "[$SCRIPT_NAME] Inserting generated markdown content between <!-- AUTOGENERATED_START --> <!-- AUTOGENERATED_END --> tags"
379+
380+
echo "[$SCRIPT_NAME] Inserting generated markdown content between AUTOGENERATED_START and AUTOGENERATED_END tags"
375381
for i in "${!insert_src_files[@]}"; do
376382
src_file="${insert_src_files[i]}"
377383

@@ -394,18 +400,18 @@ for i in "${!insert_src_files[@]}"; do
394400
trap 'rm -f "$tmp_file"' EXIT
395401

396402
# 1. Copy everything up to and including <!--AUTOGENERATED_START-->
397-
awk '/<!--AUTOGENERATED_START-->/ {print; exit}; {print}' "$dest_full_path" > "$tmp_file"
403+
sed -n '1,/<!--AUTOGENERATED_START-->/p' "$dest_full_path" > "$tmp_file"
398404

399405
# 2. Add the content from the source file
400406
cat "$src_rel_path" >> "$tmp_file"
401407

402408
# 3. Add everything from <!--AUTOGENERATED_END--> to the end of the file
403-
awk 'BEGIN {found=0}; /<!--AUTOGENERATED_END-->/ {found=1}; found {print}' "$dest_full_path" >> "$tmp_file"
409+
sed -n '/<!--AUTOGENERATED_END-->/,$p' "$dest_full_path" >> "$tmp_file"
404410

405411
# Replace the original file with the modified content
406412
mv "$tmp_file" "$dest_full_path"
407413
else
408-
echo "[$SCRIPT_NAME] Error: Expected to find <!--AUTOGENERATED_START--> and <!--AUTOGENERATED_END--> tags in $dest_full_path, but did not"
414+
echo "[$SCRIPT_NAME] Error: Expected to find AUTOGENERATED_START and AUTOGENERATED_END tags in $dest_full_path, but did not"
409415
exit 1
410416
fi
411417

@@ -424,7 +430,7 @@ cd "$parent_of_tmp" || echo "[$SCRIPT_NAME] Warning: Failed to cd back to parent
424430
echo "[$SCRIPT_NAME] Removing contents of temporary directory: $tmp_dir"
425431
# Use full path for removal just in case cd failed
426432
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)."
433+
rmdir "$tmp_dir" 2>/dev/null || echo "[$SCRIPT_NAME] Unable to remove $tmp_dir"
428434

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

0 commit comments

Comments
 (0)