-
Notifications
You must be signed in to change notification settings - Fork 14
/
build-docs.sh
85 lines (58 loc) · 2.31 KB
/
build-docs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# This script builds the Storybook, TSDoc, and Docusaurus docs for the project.
# Exit immediately if a command exits with a non-zero status.
set -e
# Cleaning up the docs-build folder
echo "Cleaning up the docs-build folder ..."
rm -rf docs-build
echo "Cleaning up the docs-build folder Done!"
# Build Docusaurus docs.
echo "Building Docusaurus docs ..."
# Going into Docusaurus folder
cd docusaurus
# Installing dependencies and Building Docusaurus
yarn install && yarn build
# Going back to the root folder
cd ..
echo "Building Docusaurus docs Done!"
# Copying Docusaurus build to docs-build folder
echo "Copying Docusaurus build to docs-build folder ..."
cp -r docusaurus/build docs-build/
echo "Copying Docusaurus build to docs-build folder Done!"
# Removing Docusaurus build folder
echo "Removing Docusaurus build folder ..."
rm -rf docusaurus/build
echo "Removing Docusaurus build folder Done!"
# Build Storybook.
echo "Building Storybook ..."
# Building Storybook
yarn build:storybook
echo "Building Storybook Done!"
# Copying storybook-build files to docs-build folder
echo "Copying storybook-build files to docs-build folder ..."
cp -r storybook docs-build/storybook/
echo "Copying storybook-build files to docs-build folder Done!"
# Removing storybook-build folder
echo "Removing storybook-build folder ..."
rm -rf storybook
echo "Removing storybook-build folder Done!"
# Build TSDoc.
echo "Building TSDoc ..."
# Building TSDoc
yarn build:typedoc
echo "Building TSDoc Done!"
# Find and replace the absolute path using sed
echo "Find and replace the absolute path using sed ..."
sed -re 's@<(\w+)(.*)href="([^http].*)"(.*)>@<\1\2href="/typedoc\/\3"\4>@g' -i ./typedoc/index.html
sed -re 's@"(assets/.+)"@"/typedoc/\1"@g' -i ./typedoc/index.html
sed -re 's@<(\w+)(.*)href="([^http].*)"(.*)>@<\1\2href="/typedoc\/\3"\4>@g' -i ./typedoc/modules.html
sed -re 's@"(assets/.+)"@"/typedoc/\1"@g' -i ./typedoc/modules.html
echo "Find and replace the absolute path using sed Done!"
# Copying typedoc files to docs-build folder
echo "Copying typedoc files to docs-build folder ..."
cp -r typedoc docs-build/typedoc/
echo "Copying typedoc files to docs-build folder Done!"
# Removing typedoc folder
echo "Removing typedoc folder ..."
rm -rf typedoc
echo "Removing typedoc folder Done!"
echo "Building and Copying all docs folders done."