Skip to content

Commit 2cc4892

Browse files
authored
Migrate sidebars.js to code repo and add describe (apache#95)
* Migrate sidebars.js to code repo and add describe This path migrate sidebars.js to our main repo and and describe about how our `tool/build_docs.sh` work. ref: apache/seatunnel#1586 * Add missing rsync for sidebar.js
1 parent dc3ad89 commit 2cc4892

File tree

6 files changed

+58
-108
lines changed

6 files changed

+58
-108
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ build/
2525
swap/
2626
docs/
2727
static/image_en/
28+
sidebars.js
2829

2930
dist
3031
dist-ssr

HOW_DOC_WORK.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# How Documentation Work
2+
3+
[Our website](https://seatunnel.apache.org) is generated based on this repository(**apache/incubator-seatunnel-website**),
4+
but the content of document is hold on [our codebase repository](https://github.com/apache/incubator-seatunnel/tree/dev/docs).
5+
So we have to fetch the document from the codebase repository before we build the document.
6+
7+
Indeed, you could fetch it by your hand, but we provide the more convenience way to do it, the `build-docs.sh` in directory
8+
`tools`. It will
9+
10+
* Create the directory named `swap` under your project directory, as well `docs` and `static/image_en`.
11+
* Fetch the latest code in codebase repository(apache/dolphinscheduler) to directory `swap`.
12+
* Sync the latest `incubator-seatunnel/docs/en` and `incubator-seatunnel/docs/en/image` to directory `docs` and `static/image_en`.
13+
14+
After that, you are finish the prepare work, and all resources you need to build our website it there, you could run your
15+
`npm` command to build the website.
16+
17+
## How It Works in GitHub Action
18+
19+
Our GitHub Action also use script `tools/build-docs.sh` to finish its prepare work. Consistent way to prepare and build
20+
the website is good for both development and production maintenance.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This website is compiled using node, using Docusaurus framework components
2323

2424
1. Download and install nodejs (version>12.5.0)
2525
2. Clone the code to the local `git clone [email protected]:apache/incubator-seatunnel-website.git`
26-
3. Run `./tools/build-docs.sh` to fetch and prepare docs form **apache/incubator-seatunnel**
26+
3. Run `./tools/build-docs.sh` to fetch and prepare docs form **apache/incubator-seatunnel**, for more information you could see [how our document work](HOW_DOC_WORK.md)
2727
4. Run `npm install` to install the required dependent libraries.
2828
5. Run `npm run start` in the root directory, you can visit http://localhost:3000 to view the English mode preview of the site
2929
6. Run `npm run start-zh` in the root directory, you can visit http://localhost:3000 to view the Chinese mode preview of the site

README_ZH.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ asf-staging 官网测试环境 通过https://seatunnel.staged.apache.org 访问
2323

2424
1. 下载并安装 nodejs(version>12.5.0)
2525
2. 克隆代码到本地 `git clone [email protected]:apache/incubator-seatunnel-website.git`
26-
3. 运行 `./tools/build-docs.sh`**apache/incubator-seatunnel** 中拉取、准备文档
26+
3. 运行 `./tools/build-docs.sh`**apache/incubator-seatunnel** 中拉取、准备文档。如果想要了解更多细节和操作请阅读[文档如何工作](HOW_DOC_WORK.md)
2727
4. 运行 `npm install` 来安装所需的依赖库。
2828
5. 在根目录运行`npm run start`,可以访问http://localhost:3000查看站点英文模式预览
2929
6. 在根目录运行`npm run start-zh`,可以访问http://localhost:3000查看站点的中文模式预览

sidebars.js

-103
This file was deleted.

tools/build-docs.sh

+35-3
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@ set -euo pipefail
44

55
SOURCE_PATH="$(cd "$(dirname "$(dirname "${BASH_SOURCE[0]}")" )" && pwd)"
66

7+
# Codebase Repository
78
PROJECT_NAME="seatunnel"
89
PROJECT_BRANCH_NAME="dev"
9-
# PROJECT_WEBSITE_NAME="${PROJECT_NAME}-website"
1010

11+
# Repository Website(current) Directory
1112
SWAP_DIR="${SOURCE_PATH}/swap"
1213
PROJECT_SITE_IMG_DIR="${SOURCE_PATH}/static/image_en"
1314
PROJECT_SITE_DOC_DIR="${SOURCE_PATH}/docs"
1415

16+
# Repository Codebase(current) Directory
1517
PROJECT_DIR="${SWAP_DIR}/${PROJECT_NAME}"
1618
PROJECT_IMG_DIR="${PROJECT_DIR}/docs/en/images"
1719
PROJECT_DOC_DIR="${PROJECT_DIR}/docs/en"
20+
PROJECT_SIDEBAR_PATH="${PROJECT_DIR}/docs/sidebars.js"
21+
22+
# Repository Codebase(current) File Path
23+
DOCUSAURUS_DOC_SIDEBARS_FILE="${SOURCE_PATH}/sidebars.js"
1824

1925

2026
# Choose the protocol for git communication to server, default is HTTP because it do not requests password or secret key,
@@ -29,11 +35,12 @@ fi
2935
##############################################################
3036
#
3137
# Rebuild specific directory, if directory exists, will remove
32-
# it before create it, otherwise create it directly.
38+
# it before create it, otherwise create it directly. It
39+
# supports one or more parameters.
3340
#
3441
# Arguments:
3542
#
36-
# path: One or more directories want to rebuild
43+
# <path...>: One or more directories want to rebuild
3744
#
3845
##############################################################
3946
function rebuild_dirs() {
@@ -46,6 +53,25 @@ function rebuild_dirs() {
4653
done
4754
}
4855

56+
##############################################################
57+
#
58+
# Remove specific exists file. It supports one or more
59+
# parameters.
60+
#
61+
# Arguments:
62+
#
63+
# <file...>: One or more files want to remove
64+
#
65+
##############################################################
66+
function rm_exists_files() {
67+
for file in "$@"; do
68+
echo " ---> Remove exists ${file}"
69+
if [ -f "${file}" ]; then
70+
rm -rf "${file}"
71+
fi
72+
done
73+
}
74+
4975
##############################################################
5076
#
5177
# Clone repository to target directory, it will only support
@@ -119,9 +145,15 @@ function prepare_docs() {
119145
echo "===>>>: Rebuild directory swap, docs, static/image_en."
120146
rebuild_dirs "${SWAP_DIR}" "${PROJECT_SITE_DOC_DIR}" "${PROJECT_SITE_IMG_DIR}"
121147

148+
echo "===>>>: Remove exists file sidebars.js."
149+
rm_exists_files "${DOCUSAURUS_DOC_SIDEBARS_FILE}"
150+
122151
echo "===>>>: Clone project main codebase repositories."
123152
clone_repo "${PROJECT_REPO}" "${PROJECT_BRANCH_NAME}" "${PROJECT_DIR}"
124153

154+
echo "===>>>: Rsync sidebars.js to ${DOCUSAURUS_DOC_SIDEBARS_FILE}"
155+
rsync -av "${PROJECT_SIDEBAR_PATH}" "${DOCUSAURUS_DOC_SIDEBARS_FILE}"
156+
125157
echo "===>>>: Rsync images to ${PROJECT_SITE_IMG_DIR}"
126158
rsync -av "${PROJECT_IMG_DIR}"/ "${PROJECT_SITE_IMG_DIR}"
127159

0 commit comments

Comments
 (0)