Skip to content

Commit

Permalink
Merge pull request ClickHouse#870 from ClickHouse/automate-doc-prep
Browse files Browse the repository at this point in the history
Prep script for running the docs locally
  • Loading branch information
DanRoscigno authored Mar 3, 2023
2 parents eb5e118 + b455ff5 commit 5d670e8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
40 changes: 21 additions & 19 deletions contrib-writing-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,30 @@ The documentation is built with Docusaurus, which requires Node.js. We recommend
```bash
brew install npm
brew install yarn
git clone https://github.com/ClickHouse/ClickHouse-docs
cd ClickHouse-docs //local docs repo

mkdir docs
cd docs

git clone https://github.com/ClickHouse/ClickHouse
git clone https://github.com/ClickHouse/ClickHouse-docs
# Below you can choose only ***ONE*** of the two prep commands

# yarn prep-from-master
# This command will clone master ClickHouse/Clickhouse branch to a temp folder and
# from there it will copy over the relevant docs folders to this folder

yarn prep-from-master

# OR

# yarn prep-from-local
# This command will use a locally available folder containing ClickHouse/Clickhouse
# and from there it will copy over the relevant docs folders to this folder

# running this without using the local full path as an argument will lead to error

yarn prep-from-local /full/path/to/your/local/Clickhouse/Clickhouse


# Docusaurus expects all of the markdown files to be located in the directory tree clickhouse-docs/docs/.
# This is not the way our repos are set up, so some copying of files is needed to build the docs:
# Note: Symlinks will not work.
cp -r ClickHouse/docs/en/development ClickHouse-docs/docs/en/
cp -r ClickHouse/docs/en/engines ClickHouse-docs/docs/en/
cp -r ClickHouse/docs/en/getting-started ClickHouse-docs/docs/en/
cp -r ClickHouse/docs/en/interfaces ClickHouse-docs/docs/en/
cp -r ClickHouse/docs/en/operations ClickHouse-docs/docs/en/
cp -r ClickHouse/docs/en/sql-reference ClickHouse-docs/docs/en/
cp -r ClickHouse/docs/ru ClickHouse-docs/docs/
cp -r ClickHouse/docs/zh ClickHouse-docs/docs/

cd ClickHouse-docs

# This command installs the Docusaurus packages and prerequisites in a subdirectory of `clickhouse-docs` named `node_modules`
# Once you have run prep command (ONE of the two) the below command installs the Docusaurus packages and prerequisites in a subdirectory of `clickhouse-docs` named `node_modules`

yarn install

Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
"version": "0.0.0",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"deploy": "docusaurus deploy",
"docusaurus": "docusaurus",
"prep-from-local": "sh -c 'array_root=(docs/ru docs/zh);array_en=(docs/en/development docs/en/engines docs/en/getting-started docs/en/interfaces docs/en/operations docs/en/sql-reference);for folder in ${array_en[@]}; do cp -r $0/$folder docs/en;echo \"Copied $folder from ClickHouse local path [$0]\";done;for folder in ${array_root[@]}; do cp -r $0/$folder docs/;echo \"Copied $folder from ClickHouse local path [$0]\";done;echo \"Prep completed\";'",
"prep-from-master": "array_root=(docs/ru docs/zh);array_en=(docs/en/development docs/en/engines docs/en/getting-started docs/en/interfaces docs/en/operations docs/en/sql-reference);ch_temp=/tmp/ch_temp_$RANDOM && mkdir -p $ch_temp && git clone --depth 1 --branch master https://github.com/ClickHouse/ClickHouse $ch_temp; for folder in ${array_en[@]}; do cp -r $ch_temp/$folder docs/en;echo \"Copied $folder from ClickHouse source\";done;for folder in ${array_root[@]}; do cp -r $ch_temp/$folder docs/;echo \"Copied $folder from ClickHouse source\";done;rm -rf $ch_temp && echo \"Prep completed\";",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids"
"start": "docusaurus start",
"swizzle": "docusaurus swizzle",
"write-heading-ids": "docusaurus write-heading-ids",
"write-translations": "docusaurus write-translations"
},
"dependencies": {
"@docusaurus/core": "2.3.0",
Expand Down

0 comments on commit 5d670e8

Please sign in to comment.