build_website.sh 1.36 KB
Newer Older
1
#!/bin/bash
2
# Copyright (c) Meta Platforms, Inc. and affiliates.
Patrick Labatut's avatar
Patrick Labatut committed
3
4
5
6
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
7
8
9

# run this script from the project root using `./scripts/build_docs.sh`

10
11
set -e

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
usage() {
  echo "Usage: $0 [-b]"
  echo ""
  echo "Build PyTorch3D documentation."
  echo ""
  echo "  -b   Build static version of documentation (otherwise start server)"
  echo ""
  exit 1
}

BUILD_STATIC=false

while getopts 'hb' flag; do
  case "${flag}" in
    h)
      usage
      ;;
    b)
      BUILD_STATIC=true
      ;;
    *)
      usage
      ;;
  esac
done


echo "-----------------------------------"
40
echo "Building PyTorch3D Docusaurus site"
41
echo "-----------------------------------"
42
cd website
43
44
45
46
47
48
49
50
51
52
53
yarn
cd ..

echo "-----------------------------------"
echo "Generating tutorials"
echo "-----------------------------------"
cwd=$(pwd)
mkdir -p "website/_tutorials"
mkdir -p "website/static/files"
python scripts/parse_tutorials.py --repo_dir "${cwd}"

54
cd website
55
56
57
58
59
60
61
62
63
64
65

if [[ $BUILD_STATIC == true ]]; then
  echo "-----------------------------------"
  echo "Building static site"
  echo "-----------------------------------"
  yarn build
else
  echo "-----------------------------------"
  echo "Starting local server"
  echo "-----------------------------------"
  yarn start
Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
66
fi