File: update_docs.py

package info (click to toggle)
emscripten 3.1.69%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 121,860 kB
  • sloc: ansic: 636,110; cpp: 425,974; javascript: 78,401; python: 58,404; sh: 49,154; pascal: 5,237; makefile: 3,366; asm: 2,415; lisp: 1,869
file content (50 lines) | stat: -rwxr-xr-x 1,717 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env python3
# Copyright 2021 The Emscripten Authors.  All rights reserved.
# Emscripten is available under two separate licenses, the MIT license and the
# University of Illinois/NCSA Open Source License.  Both these licenses can be
# found in the LICENSE file.

"""Builds the emscripten website from source and creates a new commit & branch
in the emscripten-site repository containing the changes."""

import os
import sys
import subprocess

script_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.dirname(os.path.dirname(script_dir))
site_dir = os.path.join(root_dir, 'site')


def main(args):
  if args:
    site_out = args[0]
  else:
    site_out = os.path.join(os.path.dirname(root_dir), 'emscripten-site')
  assert os.path.exists(site_out)

  output = subprocess.check_output(['git', 'status', '--short'], cwd=site_out)

  print(f'Updating docs in: {site_out}')

  # Ensure the -site checkout is up-to-date and clean.
  output = subprocess.check_output(['git', 'status', '--short'], cwd=site_out)
  output = output.decode('utf-8').strip()
  if output:
    print('Site tree is not clean')
    return 1

  subprocess.check_call(['git', 'fetch', 'origin'], cwd=site_out)
  subprocess.check_call(['git', 'checkout', 'origin/gh-pages'], cwd=site_out)

  # Build and install the docs
  subprocess.check_call(['make', 'install', f'EMSCRIPTEN_SITE={site_out}'], cwd=site_dir)

  # Create a new branch and commit the changes.
  subprocess.check_call(['git', 'checkout', '-b', 'update'], cwd=site_out)
  subprocess.check_call(['git', 'add', '.'], cwd=site_out)
  subprocess.check_call(['git', 'commit', '-mupdate'], cwd=site_out)


if __name__ == '__main__':
  sys.exit(main(sys.argv[1:]))