Skip to content

Commit

Permalink
Merge pull request #40 from DanRoscigno/mv-assets
Browse files Browse the repository at this point in the history
move assets to _assets
  • Loading branch information
DanRoscigno authored Oct 19, 2023
2 parents ae342ae + bb00663 commit 80def57
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
rm -rf ../versioned_docs/version-3.1
mkdir -p ../versioned_docs/version-3.1
cp -r docs/* ../versioned_docs/version-3.1
mv ../versioned_docs/version-3.1/assets ../versioned_docs/version-3.1/_assets
- name: process English 3.0
run: |
Expand All @@ -56,6 +57,7 @@ jobs:
rm -rf ../versioned_docs/version-3.0
mkdir -p ../versioned_docs/version-3.0
cp -r docs/* ../versioned_docs/version-3.0
mv ../versioned_docs/version-3.0/assets ../versioned_docs/version-3.0/_assets
- name: process English 2.5
run: |
Expand All @@ -64,6 +66,7 @@ jobs:
rm -rf ../versioned_docs/version-2.5
mkdir -p ../versioned_docs/version-2.5
cp -r docs/* ../versioned_docs/version-2.5
mv ../versioned_docs/version-2.5/assets ../versioned_docs/version-2.5/_assets
- name: process Chinese 3.1
run: |
Expand All @@ -72,6 +75,7 @@ jobs:
rm -rf ../i18n/zh/docusaurus-plugin-content-docs/version-3.1/
mkdir -p ../i18n/zh/docusaurus-plugin-content-docs/version-3.1
cp -r * ../i18n/zh/docusaurus-plugin-content-docs/version-3.1/
mv ../i18n/zh/docusaurus-plugin-content-docs/version-3.1/assets ../i18n/zh/docusaurus-plugin-content-docs/version-3.1/_assets
- name: process Chinese 3.0
run: |
Expand All @@ -80,6 +84,7 @@ jobs:
rm -rf ../i18n/zh/docusaurus-plugin-content-docs/version-3.0/
mkdir -p ../i18n/zh/docusaurus-plugin-content-docs/version-3.0
cp -r * ../i18n/zh/docusaurus-plugin-content-docs/version-3.0/
mv ../i18n/zh/docusaurus-plugin-content-docs/version-3.0/assets ../i18n/zh/docusaurus-plugin-content-docs/version-3.0/_assets
- name: process Chinese 2.5
run: |
Expand All @@ -88,6 +93,7 @@ jobs:
rm -rf ../i18n/zh/docusaurus-plugin-content-docs/version-2.5/
mkdir -p ../i18n/zh/docusaurus-plugin-content-docs/version-2.5
cp -r * ../i18n/zh/docusaurus-plugin-content-docs/version-2.5/
mv ../i18n/zh/docusaurus-plugin-content-docs/version-2.5/assets ../i18n/zh/docusaurus-plugin-content-docs/version-2.5/_assets
- name: cleanup before running yarn build
run: |
Expand All @@ -104,6 +110,11 @@ jobs:
_IGNORE/add_missing_english_files.sh
_IGNORE/add_chinese_sidebar.sh
_IGNORE/add_english_sidebar.sh
# "switching assets to _assets"
find i18n/zh/docusaurus-plugin-content-docs -type d -name _assets -prune -o \
-type f -name "*\.md*" -exec sed -i 's/\/assets\//\/_assets\//g' {} \;
find versioned_docs -type d -name _assets -prune -o \
-type f -name "*\.md*" -exec sed -i 's/\/assets\//\/_assets\//g' {} \;
- name: Install dependencies
run: yarn install --frozen-lockfile
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
rm -rf ../versioned_docs/version-3.1
mkdir -p ../versioned_docs/version-3.1
cp -r docs/* ../versioned_docs/version-3.1
mv ../versioned_docs/version-3.1/assets ../versioned_docs/version-3.1/_assets
- name: process English 3.0
run: |
Expand All @@ -51,6 +52,7 @@ jobs:
rm -rf ../versioned_docs/version-3.0
mkdir -p ../versioned_docs/version-3.0
cp -r docs/* ../versioned_docs/version-3.0
mv ../versioned_docs/version-3.0/assets ../versioned_docs/version-3.0/_assets
- name: process English 2.5
run: |
Expand All @@ -59,6 +61,7 @@ jobs:
rm -rf ../versioned_docs/version-2.5
mkdir -p ../versioned_docs/version-2.5
cp -r docs/* ../versioned_docs/version-2.5
mv ../versioned_docs/version-2.5/assets ../versioned_docs/version-2.5/_assets
- name: process Chinese 3.1
run: |
Expand All @@ -67,6 +70,7 @@ jobs:
rm -rf ../i18n/zh/docusaurus-plugin-content-docs/version-3.1/
mkdir -p ../i18n/zh/docusaurus-plugin-content-docs/version-3.1
cp -r * ../i18n/zh/docusaurus-plugin-content-docs/version-3.1/
mv ../i18n/zh/docusaurus-plugin-content-docs/version-3.1/assets ../i18n/zh/docusaurus-plugin-content-docs/version-3.1/_assets
- name: process Chinese 3.0
run: |
Expand All @@ -75,6 +79,7 @@ jobs:
rm -rf ../i18n/zh/docusaurus-plugin-content-docs/version-3.0/
mkdir -p ../i18n/zh/docusaurus-plugin-content-docs/version-3.0
cp -r * ../i18n/zh/docusaurus-plugin-content-docs/version-3.0/
mv ../i18n/zh/docusaurus-plugin-content-docs/version-3.0/assets ../i18n/zh/docusaurus-plugin-content-docs/version-3.0/_assets
- name: process Chinese 2.5
run: |
Expand All @@ -83,6 +88,7 @@ jobs:
rm -rf ../i18n/zh/docusaurus-plugin-content-docs/version-2.5/
mkdir -p ../i18n/zh/docusaurus-plugin-content-docs/version-2.5
cp -r * ../i18n/zh/docusaurus-plugin-content-docs/version-2.5/
mv ../i18n/zh/docusaurus-plugin-content-docs/version-2.5/assets ../i18n/zh/docusaurus-plugin-content-docs/version-2.5/_assets
- name: cleanup before running yarn build
run: |
Expand All @@ -99,6 +105,11 @@ jobs:
_IGNORE/add_missing_english_files.sh
_IGNORE/add_chinese_sidebar.sh
_IGNORE/add_english_sidebar.sh
# "switching assets to _assets"
find i18n/zh/docusaurus-plugin-content-docs -type d -name _assets -prune -o \
-type f -name "*\.md*" -exec sed -i 's/\/assets\//\/_assets\//g' {} \;
find versioned_docs -type d -name _assets -prune -o \
-type f -name "*\.md*" -exec sed -i 's/\/assets\//\/_assets\//g' {} \;
- name: Install dependencies
run: yarn install --frozen-lockfile
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ Before generating the HTML some modifications are made to the Markdown files:
- removing the TOC.md and README.md files
- replacing the StarRocks_intro pages with ones that use Docusaurus styling
- adding frontmatter to all of the Markdown to specify which sidebar (English or Chinese) is to be used
- the `docs/assets/` dir is renamed to `_assets`. This is done as Docusaurus automatically
ignores markdown files in dirs that start with an underscore. This is also why I have my `_IGNORE`
dirname. This is where I pop markdown files that I do not want included in the docs directly.

Once we go into production the three changes above can be removed as we will:

- remove the TOC.md files as they are not used, and leave the README out of the nav
- replace the current intro pages with the new ones that work with Docusaurus
- add the frontmatter to the Markdown files in thir repos
- rename the `assets` dirs to `_assets` so we don't have to do these changes in the build

## Building local

Expand Down
4 changes: 3 additions & 1 deletion _IGNORE/add_chinese_sidebar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ displayed_sidebar: "Chinese"
EOF

find i18n/zh/docusaurus-plugin-content-docs -type f -name "*\.md*" | while read file; do
find i18n/zh/docusaurus-plugin-content-docs -type d -name _assets -prune -o \
-type f -name "*\.md*" \
| while read file; do
cat - "$file" < "$header" > "$file.new" && mv "$file.new" "$file"
done

Expand Down
4 changes: 3 additions & 1 deletion _IGNORE/add_english_sidebar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ displayed_sidebar: "English"
EOF

find versioned_docs -type f -name "*\.md*" | while read file; do
find versioned_docs -type d -name _assets -prune -o \
-type f -name "*\.md*" \
| while read file; do
cat - "$file" < "$header" > "$file.new" && mv "$file.new" "$file"
done

Expand Down
12 changes: 12 additions & 0 deletions _IGNORE/testbuild
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ git checkout branch-3.1
rm -rf ${WORKINGDIR}/versioned_docs/version-3.1
mkdir -p ${WORKINGDIR}/versioned_docs/version-3.1
cp -r docs/* ${WORKINGDIR}/versioned_docs/version-3.1
mv ${WORKINGDIR}/versioned_docs/version-3.1/assets ${WORKINGDIR}/versioned_docs/version-3.1/_assets

git checkout branch-3.0
rm -rf ${WORKINGDIR}/versioned_docs/version-3.0
mkdir -p ${WORKINGDIR}/versioned_docs/version-3.0
cp -r docs/* ${WORKINGDIR}/versioned_docs/version-3.0
mv ${WORKINGDIR}/versioned_docs/version-3.0/assets ${WORKINGDIR}/versioned_docs/version-3.0/_assets

git checkout branch-2.5
rm -rf ${WORKINGDIR}/versioned_docs/version-2.5
mkdir -p ${WORKINGDIR}/versioned_docs/version-2.5
cp -r docs/* ${WORKINGDIR}/versioned_docs/version-2.5
mv ${WORKINGDIR}/versioned_docs/version-2.5/assets ${WORKINGDIR}/versioned_docs/version-2.5/_assets

cd ${WORKINGDIR}/temp-zh
gh repo clone StarRocks/docs.zh-cn
Expand All @@ -35,16 +38,19 @@ git checkout 3.1
rm -rf ${WORKINGDIR}/i18n/zh/docusaurus-plugin-content-docs/version-3.1/
mkdir -p ${WORKINGDIR}/i18n/zh/docusaurus-plugin-content-docs/version-3.1
cp -r * ${WORKINGDIR}/i18n/zh/docusaurus-plugin-content-docs/version-3.1/
mv ${WORKINGDIR}/i18n/zh/docusaurus-plugin-content-docs/version-3.1/assets ${WORKINGDIR}/i18n/zh/docusaurus-plugin-content-docs/version-3.1/_assets

git checkout 3.0
rm -rf ${WORKINGDIR}/i18n/zh/docusaurus-plugin-content-docs/version-3.0/
mkdir -p ${WORKINGDIR}/i18n/zh/docusaurus-plugin-content-docs/version-3.0
cp -r * ${WORKINGDIR}/i18n/zh/docusaurus-plugin-content-docs/version-3.0/
mv ${WORKINGDIR}/i18n/zh/docusaurus-plugin-content-docs/version-3.0/assets ${WORKINGDIR}/i18n/zh/docusaurus-plugin-content-docs/version-3.0/_assets

git checkout 2.5
rm -rf ${WORKINGDIR}/i18n/zh/docusaurus-plugin-content-docs/version-2.5/
mkdir -p ${WORKINGDIR}/i18n/zh/docusaurus-plugin-content-docs/version-2.5
cp -r * ${WORKINGDIR}/i18n/zh/docusaurus-plugin-content-docs/version-2.5/
mv ${WORKINGDIR}/i18n/zh/docusaurus-plugin-content-docs/version-2.5/assets ${WORKINGDIR}/i18n/zh/docusaurus-plugin-content-docs/version-2.5/_assets

echo "cleanup before running yarn build"
cd ${WORKINGDIR}
Expand All @@ -69,6 +75,12 @@ echo "\nadding frontmatter for sidebar language"
_IGNORE/add_chinese_sidebar.sh
_IGNORE/add_english_sidebar.sh

echo "switching assets to _assets"
find i18n/zh/docusaurus-plugin-content-docs -type d -name _assets -prune -o \
-type f -name "*\.md*" -exec sed -i '' 's/\/assets\//\/_assets\//g' {} \;
find versioned_docs -type d -name _assets -prune -o \
-type f -name "*\.md*" -exec sed -i '' 's/\/assets\//\/_assets\//g' {} \;

echo "verifying Markdown"
npx docusaurus-mdx-checker -c versioned_docs
npx docusaurus-mdx-checker -c docs
Expand Down

0 comments on commit 80def57

Please sign in to comment.