diff --git a/scripts/settings/autogenerate-settings.sh b/scripts/settings/autogenerate-settings.sh index 59c15ab1d1f..160121eb46e 100755 --- a/scripts/settings/autogenerate-settings.sh +++ b/scripts/settings/autogenerate-settings.sh @@ -107,23 +107,26 @@ setup_custom_binary() { } # Function to insert content between AUTOGENERATED tags +# Usage: insert_content_between_tags [start_tag] [end_tag] insert_content_between_tags() { local src_file="$1" local dest_file="$2" - + local start_tag="${3:-}" + local end_tag="${4:-}" + # Create a temporary file local tmp_file=$(mktemp) trap 'rm -f "$tmp_file"' EXIT - - # 1. Copy everything up to and including - awk '// {print; exit}; {print}' "$dest_file" > "$tmp_file" - + + # 1. Copy everything up to and including the start tag + awk -v tag="$start_tag" 'index($0, tag) {print; exit}; {print}' "$dest_file" > "$tmp_file" + # 2. Add the content from the source file cat "$src_file" >> "$tmp_file" - - # 3. Add everything from to the end of the file - awk 'BEGIN {found=0}; // {found=1}; found {print}' "$dest_file" >> "$tmp_file" - + + # 3. Add everything from the end tag to the end of the file + awk -v tag="$end_tag" 'BEGIN {found=0}; index($0, tag) {found=1}; found {print}' "$dest_file" >> "$tmp_file" + # Replace the original file with the modified content mv "$tmp_file" "$dest_file" } @@ -226,12 +229,12 @@ fi if [ "$GENERATE_SETTINGS" = "true" ]; then echo "[$SCRIPT_NAME] Auto-generating settings markdown pages..." # Process other SQL files first (non-function and non-system-tables related) - sql_files_found=$(find "$SCRIPT_DIR" -maxdepth 1 -name '*.sql' ! -name 'generate-functions.sql' ! -name 'system-tables.sql' ! -name 'generate-aggregate-functions.sql' -print -quit) + sql_files_found=$(find "$SCRIPT_DIR" -maxdepth 1 -name '*.sql' ! -name 'generate-functions.sql' ! -name 'system-tables.sql' ! -name 'generate-aggregate-functions.sql' ! -name 'generate-events-list.sql' ! -name 'generate-metrics-list.sql' ! -name 'generate-asynchronous-metrics-list.sql' ! -name 'generate-histogram-metrics-list.sql' -print -quit) if [ -z "$sql_files_found" ]; then echo "[$SCRIPT_NAME] Warning: No settings *.sql files found in $SCRIPT_DIR to process." else for SQL_FILE in "$SCRIPT_DIR"/*.sql; do - if [ -f "$SQL_FILE" ] && [ "$(basename "$SQL_FILE")" != "generate-functions.sql" ] && [ "$(basename "$SQL_FILE")" != "system-tables.sql" ] && [ "$(basename "$SQL_FILE")" != "generate-aggregate-functions.sql" ]; then + if [ -f "$SQL_FILE" ] && [ "$(basename "$SQL_FILE")" != "generate-functions.sql" ] && [ "$(basename "$SQL_FILE")" != "system-tables.sql" ] && [ "$(basename "$SQL_FILE")" != "generate-aggregate-functions.sql" ] && [ "$(basename "$SQL_FILE")" != "generate-events-list.sql" ] && [ "$(basename "$SQL_FILE")" != "generate-metrics-list.sql" ] && [ "$(basename "$SQL_FILE")" != "generate-asynchronous-metrics-list.sql" ] && [ "$(basename "$SQL_FILE")" != "generate-histogram-metrics-list.sql" ]; then echo "[$SCRIPT_NAME] Processing SQL file: $SQL_FILE" # Run ClickHouse from CWD ($tmp_dir), passing absolute path to SQL file "$script_path" --queries-file "$SQL_FILE" || { @@ -578,6 +581,96 @@ done echo "[$SCRIPT_NAME] System tables documentation completed." echo "[$SCRIPT_NAME] Processed ${#SYSTEM_TABLES[@]} system tables." + +# Function: generate descriptions list from a SQL file and inject into a doc page +# Replaces any existing hardcoded "## ... descriptions" section with autogenerated content. +# Usage: generate_descriptions_list