Skip to content

Commit 884a181

Browse files
munabedanbitsondatadev
authored andcommitted
Refactored Bash script functions to improve readability, consistency, and error handling.
Changes include: - Added docs to common.sh - Improved comments for better understanding. - Updated get_latest_version function to only get numeric folders for better directory parsing and version retrieval. - Modified update_version: adjusted sed commands for functionallity across MacOS and GNU/Linux platforms. - Added explicit output markers to differentiate function-specific outputs for clarity. - Modified pull_versioned_docs function to use local variable for get_latest_version output. Established structured folders for customized styling and overrides within the MkDocs Material project. Changes include: - Set up MkDocs for project homepage - Set up configuration file (mkdocs.yml) for new palette - Set up theme and basic styling - Prepare homepage override template - Create clone of current site: https://iceberg.apache.org/ - Update site wide styling.
1 parent 1442615 commit 884a181

File tree

16 files changed

+6292
-151
lines changed

16 files changed

+6292
-151
lines changed

.github/workflows/site-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ on:
2121
push:
2222
branches:
2323
- main
24+
- asf-deploy
2425
paths:
2526
- site/**
2627
workflow_dispatch:

site/dev/common.sh

Lines changed: 149 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,105 +20,226 @@ set -e
2020

2121
REMOTE="iceberg_docs"
2222

23+
24+
25+
# Function: create_or_update_docs_remote
26+
# Purpose: Ensures the presence of a specified remote repository for documentation.
27+
# If the remote doesn't exist, it adds it using the provided URL.
28+
# Then, it fetches updates from the remote repository.
2329
create_or_update_docs_remote () {
24-
# check if remote exists before adding it
30+
echo " --> create or update docs remote"
31+
32+
# Check if the remote exists before attempting to add it
2533
git config "remote.${REMOTE}.url" >/dev/null ||
2634
git remote add "${REMOTE}" https://github.com/apache/iceberg.git
2735

36+
# Fetch updates from the remote repository
2837
git fetch "${REMOTE}"
2938
}
3039

40+
41+
# Function: pull_remote
42+
# Purpose: Pulls updates from a specified branch of a remote repository.
43+
# Arguments:
44+
# $1: Branch name to pull updates from
3145
pull_remote () {
46+
echo " --> pull remote"
47+
3248
local BRANCH="$1"
33-
assert_not_empty "${BRANCH}"
3449

35-
git pull "${REMOTE}" "${BRANCH}"
50+
# Ensure the branch argument is not empty
51+
assert_not_empty "${BRANCH}"
52+
53+
# Perform a pull from the specified branch of the remote repository
54+
git pull "${REMOTE}" "${BRANCH}"
3655
}
3756

57+
# Function: push_remote
58+
# Purpose: Pushes changes from a local branch to a specified branch of a remote repository.
59+
# Arguments:
60+
# $1: Branch name to push changes to
3861
push_remote () {
62+
echo " --> push remote"
63+
3964
local BRANCH="$1"
40-
assert_not_empty "${BRANCH}"
4165

42-
git push "${REMOTE}" "${BRANCH}"
66+
# Ensure the branch argument is not empty
67+
assert_not_empty "${BRANCH}"
68+
69+
# Push changes to the specified branch of the remote repository
70+
git push "${REMOTE}" "${BRANCH}"
4371
}
4472

73+
# Function: install_deps
74+
# Purpose: Installs or upgrades dependencies specified in the 'requirements.txt' file using pip.
4575
install_deps () {
76+
echo " --> install deps"
77+
78+
# Use pip to install or upgrade dependencies from the 'requirements.txt' file quietly
4679
pip -q install -r requirements.txt --upgrade
4780
}
4881

82+
# Function: assert_not_empty
83+
# Purpose: Checks if a provided argument is not empty. If empty, displays an error message and exits with a status code 1.
84+
# Arguments:
85+
# $1: Argument to check for emptiness
4986
assert_not_empty () {
50-
if [ -z "$1" ]
51-
then
52-
echo "No argument supplied"
53-
exit 1
54-
fi
87+
88+
if [ -z "$1" ]; then
89+
echo "No argument supplied"
90+
91+
# Exit with an error code if no argument is provided
92+
exit 1
93+
fi
5594
}
5695

96+
# Function: get_latest_version
97+
# Purpose: Finds and retrieves the latest version of the documentation based on the directory structure.
98+
# Assumes the documentation versions are numeric folders within 'docs/docs/'.
5799
get_latest_version () {
58-
basename $(ls -d docs/docs/*/ | sort -V | tail -1)
100+
# Find the latest numeric folder within 'docs/docs/' structure
101+
local latest=$(ls -d docs/docs/[0-9]* | sort -V | tail -1)
102+
103+
# Extract the version number from the latest directory path
104+
local latest_version=$(basename "${latest}")
105+
106+
# Output the latest version number
107+
echo "${latest_version}"
59108
}
60109

110+
# Function: create_nightly
111+
# Purpose: Creates a symbolic link for a 'nightly' version of the documentation.
61112
create_nightly () {
113+
echo " --> create nightly"
114+
115+
# Remove any existing 'nightly' symbolic link to prevent conflicts
62116
rm -f docs/docs/nightly/
117+
118+
# Create a symbolic link pointing to the 'nightly' documentation
63119
ln -s ../nightly docs/docs/nightly
64120
}
65121

122+
# Function: create_latest
123+
# Purpose: Creates a 'latest' version of the documentation based on a specified ICEBERG_VERSION.
124+
# Arguments:
125+
# $1: ICEBERG_VERSION - The version number of the documentation to be treated as the latest.
66126
create_latest () {
127+
echo " --> create latest"
128+
67129
local ICEBERG_VERSION="$1"
68-
assert_not_empty "${ICEBERG_VERSION}"
69130

131+
# Ensure ICEBERG_VERSION is not empty
132+
assert_not_empty "${ICEBERG_VERSION}"
133+
134+
# Output the provided ICEBERG_VERSION for verification
135+
echo "${ICEBERG_VERSION}"
136+
137+
# Remove any existing 'latest' directory and recreate it
70138
rm -rf docs/docs/latest/
71139
mkdir docs/docs/latest/
72140

141+
# Create symbolic links and copy configuration files for the 'latest' documentation
73142
ln -s "../${ICEBERG_VERSION}/docs" docs/docs/latest/docs
74143
cp "docs/docs/${ICEBERG_VERSION}/mkdocs.yml" docs/docs/latest/
75144

76145
cd docs/docs/
77-
update_version "latest"
146+
147+
# Update version information within the 'latest' documentation
148+
update_version "latest"
78149
cd -
79150
}
80151

152+
# Function: update_version
153+
# Purpose: Updates version information within the mkdocs.yml file for a specified ICEBERG_VERSION.
154+
# Arguments:
155+
# $1: ICEBERG_VERSION - The version number used for updating the mkdocs.yml file.
81156
update_version () {
157+
echo " --> update version"
158+
82159
local ICEBERG_VERSION="$1"
83-
assert_not_empty "${ICEBERG_VERSION}"
84160

85-
sed -i '' -E "s/(^site\_name:[[:space:]]+docs\/).*$/\1${ICEBERG_VERSION}/" ${ICEBERG_VERSION}/mkdocs.yml
86-
sed -i '' -E "s/(^[[:space:]]*-[[:space:]]+Javadoc:.*\/javadoc\/).*$/\1${ICEBERG_VERSION}/" ${ICEBERG_VERSION}/mkdocs.yml
161+
# Ensure ICEBERG_VERSION is not empty
162+
assert_not_empty "${ICEBERG_VERSION}"
163+
164+
165+
166+
# Update version information within the mkdocs.yml file using sed commands
167+
if [ "$(uname)" == "Darwin" ]
168+
then
169+
sed -i '' -E "s/(^site\_name:[[:space:]]+docs\/).*$/\1${ICEBERG_VERSION}/" ${ICEBERG_VERSION}/mkdocs.yml
170+
sed -i '' -E "s/(^[[:space:]]*-[[:space:]]+Javadoc:.*\/javadoc\/).*$/\1${ICEBERG_VERSION}/" ${ICEBERG_VERSION}/mkdocs.yml
171+
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]
172+
then
173+
sed -i'' -E "s/(^site_name:[[:space:]]+docs\/)[^[:space:]]+/\1${ICEBERG_VERSION}/" "${ICEBERG_VERSION}/mkdocs.yml"
174+
sed -i'' -E "s/(^[[:space:]]*-[[:space:]]+Javadoc:.*\/javadoc\/).*$/\1${ICEBERG_VERSION}/" "${ICEBERG_VERSION}/mkdocs.yml"
175+
fi
87176

88-
#sed -i '' -E "s/ \- latest: '\!include docs\/docs\/latest\/mkdocs\.yml'/a \- ${ICEBERG_VERSION}: '\!include docs\/docs\/${ICEBERG_VERSION}\/mkdocs\.yml/" ../../mkdocs.yml
89177
}
90-
# https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-search/#search-exclusion
178+
179+
180+
181+
# Function: search_exclude_versioned_docs
182+
# Purpose: Excludes versioned documentation from search indexing by modifying .md files.
183+
# Arguments:
184+
# $1: ICEBERG_VERSION - The version number of the documentation to exclude from search indexing.
91185
search_exclude_versioned_docs () {
186+
echo " --> search exclude version docs"
92187
local ICEBERG_VERSION="$1"
93-
assert_not_empty "${ICEBERG_VERSION}"
188+
189+
# Ensure ICEBERG_VERSION is not empty
190+
assert_not_empty "${ICEBERG_VERSION}"
94191

95192
cd "${ICEBERG_VERSION}/docs/"
96-
193+
194+
# Modify .md files to exclude versioned documentation from search indexing
97195
python3 -c "import os
98196
for f in filter(lambda x: x.endswith('.md'), os.listdir()): lines = open(f).readlines(); open(f, 'w').writelines(lines[:2] + ['search:\n', ' exclude: true\n'] + lines[2:]);"
99-
197+
100198
cd -
101199
}
102200

201+
# Function: pull_versioned_docs
202+
# Purpose: Sets up local worktrees for the documentation and performs operations related to different versions.
103203
pull_versioned_docs () {
104-
create_or_update_docs_remote
204+
echo " --> pull version docs"
205+
206+
# Ensure the remote repository for documentation exists and is up-to-date
207+
create_or_update_docs_remote
208+
209+
# Add local worktrees for documentation and javadoc from the remote repository
105210
git worktree add docs/docs "${REMOTE}/docs"
106211
git worktree add docs/javadoc "${REMOTE}/javadoc"
107212

108-
create_latest $(get_latest_version)
109-
create_nightly
213+
# Retrieve the latest version of documentation for processing
214+
local latest_version=$(get_latest_version)
215+
216+
# Output the latest version for debugging purposes
217+
echo "Latest version is: ${latest_version}"
218+
219+
# Create the 'latest' version of documentation
220+
create_latest "${latest_version}"
221+
222+
# Create the 'nightly' version of documentation
223+
create_nightly
110224
}
111225

226+
# Function: clean
227+
# Purpose: Cleans up artifacts and temporary files generated during documentation management.
112228
clean () {
113-
set +e # avoid exit if any step in clean fails
229+
echo " --> clean"
114230

115-
rm -rf docs/docs/latest &> /dev/null
116-
rm -f docs/docs/nightly &> /dev/null
231+
# Temporarily disable script exit on errors to ensure cleanup continues
232+
set +e
117233

234+
# Remove 'latest' and 'nightly' directories and related Git worktrees
235+
rm -rf docs/docs/latest &> /dev/null
236+
rm -f docs/docs/nightly &> /dev/null
118237
git worktree remove docs/docs &> /dev/null
119238
git worktree remove docs/javadoc &> /dev/null
120239

240+
# Remove any additional temporary artifacts (e.g., 'site/' directory)
121241
rm -rf site/ &> /dev/null
122242

123-
set -e
243+
set -e # Re-enable script exit on errors
124244
}
245+
10.2 KB
Loading
2.53 MB
Loading

site/docs/assets/javascript/extra.js

Whitespace-only changes.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
.btn {
2+
font-size: 14px;
3+
padding: 6px 12px;
4+
margin-bottom: 0;
5+
6+
display: inline-block;
7+
text-decoration: none;
8+
text-align: center;
9+
white-space: nowrap;
10+
vertical-align: middle;
11+
-ms-touch-action: manipulation;
12+
touch-action: manipulation;
13+
cursor: pointer;
14+
-webkit-user-select: none;
15+
-moz-user-select: none;
16+
-ms-user-select: none;
17+
user-select: none;
18+
background-image: none;
19+
border: 1px solid transparent;
20+
}
21+
.btn:focus,
22+
.btn:active:focus {
23+
outline: thin dotted;
24+
outline: 5px auto -webkit-focus-ring-color;
25+
outline-offset: -2px;
26+
}
27+
.btn:hover,
28+
.btn:focus {
29+
color: #333;
30+
text-decoration: none;
31+
}
32+
.btn:active {
33+
background-image: none;
34+
outline: 0;
35+
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
36+
box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
37+
}
38+
39+
.btn-lg, .btn-group-lg .btn {
40+
padding: 10px 16px;
41+
font-size: 18px;
42+
line-height: 1.33;
43+
border-radius: 6px;
44+
}
45+
46+
/* default
47+
---------------------------- */
48+
.btn-default {
49+
color: #333;
50+
background-color: #fff;
51+
border-color: #ccc;
52+
}
53+
.btn-default:focus {
54+
color: #333;
55+
background-color: #e6e6e6;
56+
border-color: #8c8c8c;
57+
}
58+
.btn-default:hover {
59+
color: #333;
60+
background-color: #e6e6e6;
61+
border-color: #adadad;
62+
}
63+
.btn-default:active {
64+
color: #333;
65+
background-color: #e6e6e6;
66+
border-color: #adadad;
67+
}
68+

0 commit comments

Comments
 (0)