Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/tools/maint/update_docs.py
4150 views
1
#!/usr/bin/env python3
2
# Copyright 2021 The Emscripten Authors. All rights reserved.
3
# Emscripten is available under two separate licenses, the MIT license and the
4
# University of Illinois/NCSA Open Source License. Both these licenses can be
5
# found in the LICENSE file.
6
7
"""Builds the emscripten website from source and creates a new commit & branch
8
in the emscripten-site repository containing the changes."""
9
10
import os
11
import sys
12
import subprocess
13
14
script_dir = os.path.dirname(os.path.abspath(__file__))
15
root_dir = os.path.dirname(os.path.dirname(script_dir))
16
site_dir = os.path.join(root_dir, 'site')
17
18
19
def main(args):
20
if args:
21
site_out = args[0]
22
else:
23
site_out = os.path.join(os.path.dirname(root_dir), 'emscripten-site')
24
assert os.path.exists(site_out)
25
26
output = subprocess.check_output(['git', 'status', '--short'], cwd=site_out)
27
28
print(f'Updating docs in: {site_out}')
29
30
# Ensure the -site checkout is up-to-date and clean.
31
output = subprocess.check_output(['git', 'status', '--short'], cwd=site_out)
32
output = output.decode('utf-8').strip()
33
if output:
34
print('Site tree is not clean')
35
return 1
36
37
subprocess.check_call(['git', 'fetch', 'origin'], cwd=site_out)
38
subprocess.check_call(['git', 'checkout', 'origin/gh-pages'], cwd=site_out)
39
40
# Build and install the docs
41
subprocess.check_call(['make', 'install', f'EMSCRIPTEN_SITE={site_out}'], cwd=site_dir)
42
43
# Create a new branch and commit the changes.
44
subprocess.check_call(['git', 'checkout', '-b', 'update'], cwd=site_out)
45
subprocess.check_call(['git', 'add', '.'], cwd=site_out)
46
subprocess.check_call(['git', 'commit', '-mupdate'], cwd=site_out)
47
48
49
if __name__ == '__main__':
50
sys.exit(main(sys.argv[1:]))
51
52