Skip to content

Commit

Permalink
[Fix][Doc] Fix zh doc build error (#7882)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hisoka-X authored Oct 22, 2024
1 parent ff1b7d7 commit 4406fbc
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 77 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ jobs:
echo "deleted-poms=$true_or_false" >> $GITHUB_OUTPUT
echo "deleted-poms_files=$file_list" >> $GITHUB_OUTPUT
doc_files=`python tools/update_modules_check/check_file_updates.py ua $workspace apache/dev origin/$current_branch "docs/**"`
true_or_false=${doc_files%%$'\n'*}
file_list=${doc_files#*$'\n'}
echo "docs=$true_or_false" >> $GITHUB_OUTPUT
echo "docs_files=$file_list" >> $GITHUB_OUTPUT
engine_e2e_files=`python tools/update_modules_check/check_file_updates.py ua $workspace apache/dev origin/$current_branch "seatunnel-e2e/seatunnel-engine-e2e/**"`
true_or_false=${engine_e2e_files%%$'\n'*}
file_list=${engine_e2e_files#*$'\n'}
Expand Down Expand Up @@ -268,6 +274,38 @@ jobs:
- name: Check Dependencies Licenses
run: tools/dependencies/checkLicense.sh

document:
if: needs.changes.outputs.api == 'true' || needs.changes.outputs.docs == 'true'
needs: [ changes, sanity-check ]
name: Build website
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout PR
uses: actions/checkout@v3
with:
path: seatunnel-pr

- name: Checkout website repo
uses: actions/checkout@v3
with:
repository: apache/seatunnel-website
path: seatunnel-website

- name: Sync PR changes to website
run: |
bash seatunnel-pr/tools/documents/sync.sh seatunnel-pr seatunnel-website
- uses: actions/setup-node@v2
with:
node-version: 16.19.0

- name: Run docusaurus build
run: |
cd seatunnel-website
npm set strict-ssl false
npm install
npm run build
unit-test:
needs: [ changes, sanity-check ]
if: needs.changes.outputs.api == 'true' || (needs.changes.outputs.api == 'false' && needs.changes.outputs.ut-modules != '')
Expand Down
66 changes: 0 additions & 66 deletions .github/workflows/documents.yml

This file was deleted.

4 changes: 2 additions & 2 deletions docs/zh/seatunnel-engine/rest-api-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ network:
### 获取所有节点日志内容

<details>
<summary><code>GET</code> <code><b>/hazelcast/rest/maps/logs/:jobId</b></code> <code>(返回日志列表。)</code></summary></summary>
<summary><code>GET</code> <code><b>/hazelcast/rest/maps/logs/:jobId</b></code> <code>(返回日志列表。)</code></summary>

#### 请求参数

Expand Down Expand Up @@ -837,7 +837,7 @@ network:
### 获取单节点日志内容

<details>
<summary><code>GET</code> <code><b>/hazelcast/rest/maps/log</b></code> <code>(返回日志列表。)</code></summary></summary>
<summary><code>GET</code> <code><b>/hazelcast/rest/maps/log</b></code> <code>(返回日志列表。)</code></summary>

#### 响应

Expand Down
4 changes: 2 additions & 2 deletions docs/zh/seatunnel-engine/rest-api-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ seatunnel:
### 获取所有节点日志内容

<details>
<summary><code>GET</code> <code><b>/logs/:jobId</b></code> <code>(返回日志列表。)</code></summary></summary>
<summary><code>GET</code> <code><b>/logs/:jobId</b></code> <code>(返回日志列表。)</code></summary>

#### 请求参数

Expand Down Expand Up @@ -800,7 +800,7 @@ seatunnel:
### 获取单节点日志内容

<details>
<summary><code>GET</code> <code><b>/log</b></code> <code>(返回日志列表。)</code></summary></summary>
<summary><code>GET</code> <code><b>/log</b></code> <code>(返回日志列表。)</code></summary>

#### 响应

Expand Down
28 changes: 21 additions & 7 deletions tools/documents/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ PR_IMG_DIR="${PR_DIR}/docs/images"
PR_IMG_ICON_DIR="${PR_DIR}/docs/images/icons"
PR_DOC_DIR="${PR_DIR}/docs/en"
PR_SIDEBAR_PATH="${PR_DIR}/docs/sidebars.js"
PR_ZH_DOC_DIR="${PR_DIR}/docs/zh"

WEBSITE_DIR=$2
WEBSITE_IMG_DIR="${WEBSITE_DIR}/static/image_en"
WEBSITE_ZH_IMG_DIR="${WEBSITE_DIR}/static/image_zh"
WEBSITE_DOC_DIR="${WEBSITE_DIR}/docs"
WEBSITE_ICON_DIR="${WEBSITE_DIR}/docs/images/icons"
WEBSITE_ZH_DOC_DIR="${WEBSITE_DIR}/i18n/zh-CN/docusaurus-plugin-content-docs/current"

DOCUSAURUS_DOC_SIDEBARS_FILE="${WEBSITE_DIR}/sidebars.js"

Expand Down Expand Up @@ -85,18 +88,19 @@ function rm_exists_files() {
##############################################################
function replace_images_path(){
replace_dir=$1
target=$2
for file_path in "${replace_dir}"/*; do
if test -f "${file_path}"; then
if [ "${file_path##*.}"x = "md"x ] || [ "${file_path##*.}"x = "mdx"x ]; then
echo " ---> Replace images path to /doc/image_en in ${file_path}"
echo " ---> Replace images path to /doc/${target} in ${file_path}"
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -E -i '' "s/(\.\.\/)*images/\/image_en/g" "${file_path}"
sed -E -i '' "s/(\.\.\/)*images/\/${target}/g" "${file_path}"
else
sed -E -i "s/(\.\.\/)*images/\/image_en/g" "${file_path}"
sed -E -i "s/(\.\.\/)*images/\/${target}/g" "${file_path}"
fi
fi
else
replace_images_path "${file_path}"
replace_images_path "${file_path}" "${target}"
fi
done
}
Expand All @@ -107,8 +111,9 @@ function replace_images_path(){
function prepare_docs() {
echo "===>>>: Start documents sync."

echo "===>>>: Rebuild directory docs, static/image_en."
echo "===>>>: Rebuild directory docs, static/image_en(zh)."
rebuild_dirs "${WEBSITE_DOC_DIR}" "${WEBSITE_IMG_DIR}"
rebuild_dirs "${WEBSITE_DOC_DIR}" "${WEBSITE_ZH_IMG_DIR}"

echo "===>>>: Remove exists file sidebars.js."
rm_exists_files "${DOCUSAURUS_DOC_SIDEBARS_FILE}"
Expand All @@ -119,15 +124,24 @@ function prepare_docs() {
echo "===>>>: Rsync images to ${WEBSITE_IMG_DIR}"
rsync -av --exclude='/icons' "${PR_IMG_DIR}"/ "${WEBSITE_IMG_DIR}"

echo "===>>>: Rsync images to ${WEBSITE_ZH_IMG_DIR}"
rsync -av --exclude='/icons' "${PR_IMG_DIR}"/ "${WEBSITE_ZH_IMG_DIR}"

mkdir -p ${WEBSITE_ICON_DIR}
echo "===>>>: Rsync icons to ${WEBSITE_ICON_DIR}"
rsync -av "${PR_IMG_ICON_DIR}"/ "${WEBSITE_ICON_DIR}"

echo "===>>>: Rsync documents to ${WEBSITE_DOC_DIR}"
echo "===>>>: Rsync en documents to ${WEBSITE_DOC_DIR}"
rsync -av "${PR_DOC_DIR}"/ "${WEBSITE_DOC_DIR}"

echo "===>>>: Rsync zh documents to ${WEBSITE_ZH_DOC_DIR}"
rsync -av "${PR_ZH_DOC_DIR}"/ "${WEBSITE_ZH_DOC_DIR}"

echo "===>>>: Replace images path in ${WEBSITE_DOC_DIR}"
replace_images_path "${WEBSITE_DOC_DIR}"
replace_images_path "${WEBSITE_DOC_DIR}" "image_en"

echo "===>>>: Replace images path in ${WEBSITE_ZH_DOC_DIR}"
replace_images_path "${WEBSITE_ZH_DOC_DIR}" "image_zh"

echo "===>>>: End documents sync"
}
Expand Down

0 comments on commit 4406fbc

Please sign in to comment.