Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
62ac369
break up scripts and refactor, new-build working
Blargian Jan 29, 2025
c40b1ad
rename to autogen_needed_files
Blargian Jan 29, 2025
39bf454
fix autogenerate-settings.sh
Blargian Jan 29, 2025
b2409ce
update package.json
Blargian Jan 29, 2025
c75bea9
update .gitignore
Blargian Jan 29, 2025
3be9d07
update developer dependencies
Blargian Jan 29, 2025
6df6307
Vercel rsync not found: use subprocess.run instead of os.system
Blargian Jan 29, 2025
c48b69e
commit yarn.lock file
Blargian Jan 29, 2025
686e0bd
modify subprocess to use yarn
Blargian Jan 29, 2025
f3bc4c3
try find the systems rsync
Blargian Jan 29, 2025
53ea96f
correct parameters
Blargian Jan 29, 2025
e789336
add fallback to cp and made python script a bash script
Blargian Jan 30, 2025
ec36c76
.sh not .py
Blargian Jan 30, 2025
a047609
replace jq with awk for better compatibility
Blargian Jan 30, 2025
1aaa16b
add error handling for if files do not copy correctly
Blargian Jan 30, 2025
b9afd61
add more robust error handling for copying files, move clean up out o…
Blargian Jan 30, 2025
b4a0923
copy recursively
Blargian Jan 30, 2025
124e4fb
update autogenerate-settings.sh
Blargian Jan 30, 2025
ffe731d
improve autogenerate-settings.sh
Blargian Jan 30, 2025
9d56ac3
improve autogenerate-settings.sh more
Blargian Jan 30, 2025
7538a8c
actually fix autogenerate-settings.sh
Blargian Jan 30, 2025
ec00082
move queries to a single file
Blargian Jan 30, 2025
1889a08
fix query - autogeneration is finicky on the formatting
Blargian Jan 30, 2025
ec44371
remove queries files because it breaks formatting for some reason
Blargian Jan 30, 2025
15ffaec
change build to new build, keep new-build, add prep-from-local for do…
Blargian Jan 30, 2025
1716ffc
Update prep-from-local in package.json
Blargian Jan 30, 2025
8495215
change to prep-from-local command
Blargian Jan 30, 2025
111345a
fix infinite build loop
Blargian Jan 30, 2025
bda8038
remove rm at end of script
Blargian Jan 30, 2025
2582ee2
cleanup tmp file - build tested locally OK
Blargian Jan 30, 2025
b478799
move cleanup to own script
Blargian Jan 30, 2025
2cd1a13
move cleanup to own script
Blargian Jan 30, 2025
c687355
never forget shebang
Blargian Jan 30, 2025
1522927
add missing yarn command before cleanup-after-build
Blargian Jan 31, 2025
8cb31d0
fix review issues
Blargian Jan 31, 2025
a5a10a3
exit autogenerate settings script if curl is not installed
Blargian Jan 31, 2025
927a5c2
improve autogenerate-settings.sh
Blargian Feb 1, 2025
b24f8aa
Merge branch 'main' into separate-out-new-build
Blargian Feb 1, 2025
b466b9f
reword error message
Blargian Feb 1, 2025
2b3cef6
further improve autogenrate-settings.sh, it should fail if settings a…
Blargian Feb 1, 2025
80ac888
give file correct permissions
Blargian Feb 1, 2025
a547a3b
enable command tracing to debug issue
Blargian Feb 1, 2025
5c07df2
add debuggign statements
Blargian Feb 1, 2025
a3660e6
check which files exist in directory right after changing file permis…
Blargian Feb 1, 2025
f0cc3f4
modify query to use bash variable
Blargian Feb 1, 2025
de5b67b
move generated scripts after the fact
Blargian Feb 1, 2025
30cca89
Create the files first for docs check run failing
Blargian Feb 1, 2025
7584d4b
use clickhouse-local
Blargian Feb 1, 2025
1284e7d
add test line to see if issue is with finding the binary
Blargian Feb 1, 2025
6ac2530
try the old way
Blargian Feb 1, 2025
bce0d68
try change shebang
Blargian Feb 1, 2025
bd65b8e
fix shebang
Blargian Feb 1, 2025
95dca10
add file command for debugging
Blargian Feb 1, 2025
8cbaf55
add required libc files if running on alpine linux
Blargian Feb 2, 2025
6da66a8
elevate priviledges for mv and cp commands
Blargian Feb 2, 2025
c2fd1f5
remove cleanup-after-build script which seems to interfere with build…
Blargian Feb 4, 2025
abd5752
change yarn build back to just docusaurus build otherwise it docs che…
Blargian Feb 4, 2025
d80eda9
point build to new-build, move docusaurus build last
Blargian Feb 4, 2025
cf52892
Fix autogenerate settings issue
Blargian Feb 4, 2025
6fda746
move new-build line to build. We will set vercel to use build and the…
Blargian Feb 4, 2025
4455699
Merge branch 'main' into separate-out-new-build
Blargian Feb 5, 2025
0f0b0f5
fix yarn.lock
Blargian Feb 6, 2025
7b879cb
fix yarn.lock attempt 2
Blargian Feb 6, 2025
bae6d34
copy yarn.lock from main repo, add rsync and yarn isntall
Blargian Feb 6, 2025
881c7a8
remove unneeded package
Blargian Feb 6, 2025
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
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ active_links.txt
active_links.json

# Files used by scripts to autogenerate settings and do spellcheck
FormatFactorySettingsDeclaration.h
FormatFactorySettings.h
Settings.cpp
scripts/settings/tmp

# Files whose content gets autogenerated
docs/en/cloud/manage/api/invitations-api-reference.md
Expand Down
22 changes: 8 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,22 @@ You can run a copy of this website locally within a few steps. Some folks find t
# ✨ Done in 6.44s.
```

1. Use Yarn to grab the latest documentation changes from the `clickhouse/clickhouse` repository:
1. Use Yarn to grab the latest documentation changes from the `ClickHouse/ClickHouse` repository:

```shell
yarn prep-from-master
yarn copy-clickhouse-repo-docs

# yarn run v1.22.19
# Cloning into '/tmp/ch_temp_14714'...
# Cloning into 'ClickHouse'...
# ...
# Prep completed
# ✨ Done in 16.44s
# Copying docs from ClickHouse ...
# Successfully executed copy from master
# ✨ Done in 18.56s.
```

Alternatively, you can use a local copy of the `clickhouse/clickhouse` if you already have that repository cloned locally.
Alternatively, you can use a local copy of `ClickHouse/ClickHouse` if you already have that repository cloned locally with `-l`.

```shell
yarn prep-from-local "/Users/johnny/clickhouse/"

# yarn run v1.22.19
# $ bash -c 'array_root=($npm ...
# ...
# Prep completed
✨ Done in 0.47s.
yarn copy-clickhouse-repo-docs -l "/Users/johnny/clickhouse/"
```

1. Start the local web-server:
Expand Down
54 changes: 0 additions & 54 deletions copyClickhouseRepoDocs.sh

This file was deleted.

2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ const config = {
async postBuild({ siteConfig = {}, routesPaths = [], outDir }) {
// Print out to console all the rendered routes.
routesPaths.map((route) => {
console.log(route)
//console.log(route)
})
},
}
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
"private": true,
"config": {
"prep_array_en": "docs/en/development docs/en/engines docs/en/getting-started docs/en/interfaces docs/en/operations docs/en/sql-reference",
"prep_array_root": "docs/ru docs/zh"
"prep_array_root": "docs/ru docs/zh",
"autogen_needed_files": "src/Core/FormatFactorySettings.h src/Core/Settings.cpp CHANGELOG.md"
},
"scripts": {
"build": "docusaurus build",
"build": "yarn copy-clickhouse-repo-docs && yarn generate-changelog && yarn autogenerate-settings && yarn build-api-doc && yarn build-swagger && docusaurus build",
"clear": "docusaurus clear && bash ./placeholderReset.sh",
"deploy": "docusaurus deploy",
"docusaurus": "docusaurus",
"prep-from-local": "bash scripts/prep-from-local.sh",
"prep-from-master": "bash scripts/prep-from-master.sh",
"copy-clickhouse-repo-docs": "bash ./copyClickhouseRepoDocs.sh",
"copy-clickhouse-repo-docs": "bash scripts/copy-clickhouse-repo-docs.sh",
"serve": "docusaurus serve",
"build-api-doc": "node clickhouseapi.js",
"build-swagger": "npx @redocly/cli build-docs https://api.clickhouse.cloud/v1 --output build/en/cloud/manage/api/swagger.html",
"auto-generate-settings": "bash ./scripts/settings/autogenerate-settings.sh",
"auto-generate-table-of-contents": "bash ./scripts/autogenerate-table-of-contents.sh",
"new-build": "yarn copy-clickhouse-repo-docs && yarn auto-generate-settings && yarn auto-generate-table-of-contents && yarn build-api-doc && yarn build && yarn build-swagger",
"build-swagger": "npx @redocly/cli build-docs https://api.clickhouse.cloud/v1 --output build/en/cloud/manage/api/swagger.html",
"prep-from-local": "bash ./scripts/copy-clickhouse-repo-docs.sh -l $1",
"autogenerate-settings": "bash ./scripts/settings/autogenerate-settings.sh",
"generate-changelog": "bash ./scripts/generate-changelog.sh",
"new-build": "yarn copy-clickhouse-repo-docs && yarn generate-changelog && yarn autogenerate-settings && yarn build-api-doc && yarn build-swagger && docusaurus build",
"start": "docusaurus start",
"swizzle": "docusaurus swizzle",
"write-heading-ids": "docusaurus write-heading-ids",
Expand All @@ -32,7 +32,6 @@
"@docusaurus/theme-mermaid": "3.7.0",
"@docusaurus/theme-search-algolia": "^3.7.0",
"@mdx-js/react": "^3.1.0",
"@yaireo/tagify": "^4.33.2",
"@radix-ui/react-navigation-menu": "^1.2.4",
"axios": "^1.7.9",
"clsx": "^2.1.0",
Expand Down Expand Up @@ -62,6 +61,7 @@
"@playwright/test": "^1.49.1",
"@types/react": "^19.0.4",
"cheerio": "^1.0.0",
"rsync": "^0.6.1",
"typescript": "^5.7.3"
},
"browserslist": {
Expand Down
143 changes: 143 additions & 0 deletions scripts/copy-clickhouse-repo-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#!/bin/bash

function parse_args() {

while getopts "hl:" opt; do
case "$opt" in
h)
# Display the usage information and exit when -h is provided
echo "Usage: $0 [-l path_to_local_clickhouse_repo]"
echo ""
echo "Options:"
echo " -l Path to a local copy of the ClickHouse repository."
echo " -h Display this help message."
exit 0
;;
l)
local_path="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done

echo "$local_path"
}

# Validate local path exists and ends in ClickHouse
function validate_local() {

if [[ -d "$local_path" && "$local_path" == *"ClickHouse" ]]; then
return 0
else
echo "Please provide a valid path to your local ClickHouse repository."
exit 1
fi
}

# Copy files/folders using rsync (or fallback to cp)
copy_item() {
local source="$1"
local destination="$2"

if $has_rsync; then
rsync -a "$source" "$destination"
else
cp -r "$source" "$destination"
if [ $? -ne 0 ]; then
echo "Error copying $source to $destination"
error=1
fi
fi
}

# Define function to copy docs locally
function copy_docs_locally() {
local local_path=$1

# Validate local path only if it's provided
if [[ -n "$local_path" ]]; then
validate_local "$local_path"
fi

# Read package.json to get list of docs folders and files
package_json=$(cat "$(pwd)/package.json")

# Extract docs_folders_en
docs_folders_en=$(echo "$package_json" | awk -F'"' '/"prep_array_en":/{print $4}')

# Extract docs_folders_other
docs_folders_other=$(echo "$package_json" | awk -F'"' '/"prep_array_root":/{print $4}')

# Extract files_for_autogen_settings
files_for_autogen_settings=$(echo "$package_json" | awk -F'"' '/"autogen_needed_files":/{print $4}')

if [ "$docs_folders_en" = "" ] || [ "$docs_folders_other" = "" ] || [ "$files_for_autogen_settings" = "" ]
then
echo "An error occurred trying to extract directory and file names from package.json"
exit 1
fi

error=0
# Copy docs folders
for folder in $docs_folders_en; do
copy_item "$local_path/$folder" "docs/en"
done

for folder in $docs_folders_other; do
copy_item "$local_path/$folder" "docs/"
done

# check if tmp directory exists, if not make it
if [[ -d "scripts/tmp" ]]; then
echo "scripts/tmp already exists"
else
mkdir scripts/tmp
fi
# Copy files for autogen settings
for source_file in $files_for_autogen_settings; do
copy_item "$local_path/$source_file" "scripts/tmp"
done

if [ "$error" -eq 1 ]; then
echo "an error occurred copying the files"
exit 1
fi
}

main() {
parse_args "$@"

# Check if rsync is available
has_rsync=false
if command -v rsync &> /dev/null; then
echo "rsync found"
has_rsync=true
else
echo "rsync not found - falling back to use cp command. For faster dev builds we recommend installing rsync."
fi

# If no local path is provided, clone the ClickHouse repo

if [[ -z "$local_path" ]]; then

git clone --depth 1 --branch master https://github.com/ClickHouse/ClickHouse

# Copy docs from cloned repository
copy_docs_locally "$(pwd)/ClickHouse"

# Remove cloned repository
rm -rf ClickHouse

echo "Successfully executed copy from master"
else
# Copy docs from the provided local path
validate_local "$local_path"
copy_docs_locally "$local_path"
echo "Successfully executed local copy"
fi
}

main "$@"
21 changes: 21 additions & 0 deletions scripts/generate-changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

script_dir=$(dirname "$0") # Get the directory of the script
parent_dir=$(realpath "$script_dir") # Get the parent directory

echo "Running Changelog Generation Script"
cp "$parent_dir/../docs/en/_placeholders/changelog/_index.md" "$parent_dir/../docs/en/whats-new/changelog/index.md"
if grep -q "^# $(date +%Y) Changelog" "$parent_dir/tmp/CHANGELOG.md"; then
echo "Generating $(date +%Y) Changelog..."
sed "/^# $(date +%Y) Changelog/d" "$parent_dir/tmp/CHANGELOG.md" > temp.txt
echo "Changelog copied to temp.txt"
cat temp.txt >> "$parent_dir/../docs/en/whats-new/changelog/index.md"
echo "Changelog written to docs/en/whats-new/changelog/index.md"
rm -f temp.txt
echo "$(date +%Y) Changelog was updated."
else
current_year="$(date +%Y)"
previous_year="$(($current_year - 1))"
echo "No Changelog found for $current_year."
echo -e ":::note\nThere have been no new releases yet for $current_year. \n View changelog for the year [$previous_year](/docs/en/whats-new/changelog/$previous_year).\n:::" >> "$parent_dir/../docs/en/whats-new/changelog/index.md"
fi
44 changes: 0 additions & 44 deletions scripts/prep-from-local.sh

This file was deleted.

11 changes: 0 additions & 11 deletions scripts/prep-from-master.sh

This file was deleted.

Loading