Skip to content

Commit 1155314

Browse files
authored
site: use virtualenv and add make lint (#14428)
1 parent 74e2ea7 commit 1155314

File tree

10 files changed

+49
-11
lines changed

10 files changed

+49
-11
lines changed

.github/workflows/docs-ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ on:
2727

2828
jobs:
2929
build-docs:
30-
runs-on: ubuntu-latest
30+
runs-on: ${{ matrix.os }}
31+
strategy:
32+
matrix:
33+
os: [ubuntu-latest, macos-latest]
3134
steps:
3235
- uses: actions/checkout@v4
3336
- uses: actions/setup-python@v5

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ site/site/
2929
site/docs/docs/
3030
site/docs/.asf.yaml
3131
site/docs/javadoc/
32+
site/.venv/
3233

3334
# benchmark output
3435
spark/v3.4/spark/benchmark/*

site/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ build: # Clean and build the docs site locally.
2929
deploy: # Clean, build, and deploy the Iceberg docs site.
3030
dev/deploy.sh $(remote_name)
3131

32+
.PHONY: lint
33+
lint: # Check linting on the docs.
34+
dev/lint.sh
35+
36+
.PHONY: lint-fix
37+
lint-fix: # Run linting with auto-fix on the docs.
38+
dev/lint.sh --fix
39+
3240
.PHONY: clean
3341
clean: # Clean the local docs site.
3442
dev/clean.sh

site/README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ The docs are built, run, and released using [make](https://www.gnu.org/software/
7676
> help: Show help for each of the Makefile recipes.
7777
> [serve](dev/serve.sh): Clean, build, and run the site locally.
7878
> [lint](dev/lint.sh): Scan markdown files for style issues.
79+
> [lint-fix](dev/lint.sh): Run linting with auto-fix on the markdown files.
7980
8081
To scaffold the versioned docs and build the project, run the `build` recipe.
8182

@@ -103,9 +104,18 @@ This step will generate the staged source code which blends into the original so
103104
└─.asf.yaml
104105
```
105106

106-
It will also scan all markdown files and fail the build on any style issues. To fix style issues, run the `lint` script with fix mode.
107+
#### Linting
108+
109+
To check for markdown style issues without building the entire site, use the `lint` make command:
110+
111+
```sh
112+
make lint
113+
```
114+
115+
To automatically fix markdown style issues, use the `lint-fix` make command:
116+
107117
```sh
108-
./dev/lint.sh --fix
118+
make lint-fix
109119
```
110120

111121
<!-- markdown-link-check-disable-next-line -->

site/dev/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
# limitations under the License.
1717
#
1818

19+
source dev/common.sh
1920
set -e
2021

2122
./dev/setup_env.sh
2223

2324
./dev/lint.sh
2425

25-
mkdocs build
26+
"${VENV_DIR}/bin/python3" -m mkdocs build

site/dev/common.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
set -e
2020

2121
export REMOTE="iceberg_docs"
22+
export VENV_DIR=".venv"
2223

2324
# Ensures the presence of a specified remote repository for documentation.
2425
# If the remote doesn't exist, it adds it using the provided URL.
@@ -34,12 +35,20 @@ create_or_update_docs_remote () {
3435
git fetch "${REMOTE}"
3536
}
3637

38+
# Creates the virtual environment if it doesn't exist.
39+
create_venv () {
40+
if [ ! -d "${VENV_DIR}" ]; then
41+
echo " --> creating virtual environment at ${VENV_DIR}"
42+
python3 -m venv "${VENV_DIR}"
43+
fi
44+
}
45+
3746
# Installs or upgrades dependencies specified in the 'requirements.txt' file using pip.
3847
install_deps () {
3948
echo " --> install deps"
4049

41-
# Use pip to install or upgrade dependencies from the 'requirements.txt' file quietly
42-
pip3 -q install -r requirements.txt --upgrade
50+
# Use pip from venv to install or upgrade dependencies from the 'requirements.txt' file quietly
51+
"${VENV_DIR}/bin/pip3" -q install -r requirements.txt --upgrade
4352
}
4453

4554
# Checks if a provided argument is not empty. If empty, displays an error message and exits with a status code 1.
@@ -186,16 +195,16 @@ pull_versioned_docs () {
186195

187196
check_markdown_files () {
188197
echo " --> check markdown file styles"
189-
if ! python3 -m pymarkdown --config markdownlint.yml scan docs/docs/nightly/docs/*.md docs/*.md README.md
198+
if ! "${VENV_DIR}/bin/python3" -m pymarkdown --config markdownlint.yml scan docs/docs/nightly/docs/*.md docs/*.md README.md
190199
then
191-
echo "Markdown style issues found. Please run './dev/lint.sh --fix' to fix them."
200+
echo "Markdown style issues found. Please run 'make lint-fix' to fix them."
192201
exit 1
193202
fi
194203
}
195204

196205
fix_markdown_files () {
197206
echo " --> fix markdown file styles"
198-
python3 -m pymarkdown --config markdownlint.yml fix docs/docs/nightly/docs/*.md docs/*.md README.md
207+
"${VENV_DIR}/bin/python3" -m pymarkdown --config markdownlint.yml fix docs/docs/nightly/docs/*.md docs/*.md README.md
199208
}
200209

201210
# Cleans up artifacts and temporary files generated during documentation management.

site/dev/deploy.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# limitations under the License.
1717
#
1818

19+
source dev/common.sh
1920
set -e
2021

2122
remote_name="${1:-origin}"
@@ -24,4 +25,4 @@ remote_name="${1:-origin}"
2425

2526
echo " --> Deploy to asf-site branch of remote repository: ${remote_name}"
2627

27-
mkdocs gh-deploy --no-history --remote-branch=asf-site --remote-name ${remote_name}
28+
"${VENV_DIR}/bin/python3" -m mkdocs gh-deploy --no-history --remote-branch=asf-site --remote-name ${remote_name}

site/dev/lint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ source dev/common.sh
2020

2121
set -e
2222

23+
./dev/setup_env.sh
24+
2325
if [[ "$1" == "--fix" ]]; then
2426
fix_markdown_files
2527
else

site/dev/serve.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
# limitations under the License.
1717
#
1818

19+
source dev/common.sh
1920
set -e
2021

2122
./dev/setup_env.sh
2223

2324
./dev/lint.sh
2425

25-
mkdocs serve --dirty --watch .
26+
"${VENV_DIR}/bin/python3" -m mkdocs serve --dirty --watch .

site/dev/setup_env.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ set -e
2222

2323
clean
2424

25+
create_venv
26+
2527
install_deps
2628

2729
pull_versioned_docs

0 commit comments

Comments
 (0)