2020-03-18 13:02:32 +00:00
|
|
|
#!/usr/bin/env python3
|
2020-03-30 08:25:29 +00:00
|
|
|
|
2018-07-09 19:59:07 +00:00
|
|
|
import argparse
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import shutil
|
2018-10-12 15:43:16 +00:00
|
|
|
import subprocess
|
2018-07-09 19:59:07 +00:00
|
|
|
import sys
|
2018-10-16 10:47:17 +00:00
|
|
|
|
2020-03-13 19:35:03 +00:00
|
|
|
import livereload
|
2018-07-09 19:59:07 +00:00
|
|
|
|
2020-05-08 08:04:09 +00:00
|
|
|
import redirects
|
2020-03-30 11:39:26 +00:00
|
|
|
import website
|
2018-07-09 19:59:07 +00:00
|
|
|
|
2019-04-08 16:01:54 +00:00
|
|
|
|
2018-07-09 19:59:07 +00:00
|
|
|
def build(args):
|
2019-03-26 09:50:28 +00:00
|
|
|
if os.path.exists(args.output_dir):
|
|
|
|
shutil.rmtree(args.output_dir)
|
|
|
|
|
|
|
|
if not args.skip_website:
|
2020-03-30 11:39:26 +00:00
|
|
|
website.build_website(args)
|
2020-05-08 08:04:09 +00:00
|
|
|
redirects.build_static_redirects(args)
|
2020-01-29 20:27:36 +00:00
|
|
|
|
2019-04-08 16:01:54 +00:00
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
os.chdir(os.path.join(os.path.dirname(__file__), ".."))
|
2020-11-28 06:20:06 +00:00
|
|
|
|
|
|
|
# A root path to ClickHouse source code.
|
2022-03-22 16:39:58 +00:00
|
|
|
src_dir = ".."
|
2020-11-28 06:20:06 +00:00
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
website_dir = os.path.join(src_dir, "website")
|
2020-09-19 22:27:36 +00:00
|
|
|
|
2018-07-09 19:59:07 +00:00
|
|
|
arg_parser = argparse.ArgumentParser()
|
2022-03-22 16:39:58 +00:00
|
|
|
arg_parser.add_argument("--lang", default="en,ru,zh,ja")
|
|
|
|
arg_parser.add_argument("--theme-dir", default=website_dir)
|
|
|
|
arg_parser.add_argument("--website-dir", default=website_dir)
|
|
|
|
arg_parser.add_argument("--src-dir", default=src_dir)
|
|
|
|
arg_parser.add_argument("--output-dir", default="build")
|
|
|
|
arg_parser.add_argument("--nav-limit", type=int, default="0")
|
|
|
|
arg_parser.add_argument("--skip-multi-page", action="store_true")
|
|
|
|
arg_parser.add_argument("--skip-website", action="store_true")
|
|
|
|
arg_parser.add_argument("--htmlproofer", action="store_true")
|
|
|
|
arg_parser.add_argument("--livereload", type=int, default="0")
|
|
|
|
arg_parser.add_argument("--verbose", action="store_true")
|
2018-07-09 19:59:07 +00:00
|
|
|
|
|
|
|
args = arg_parser.parse_args()
|
2020-03-19 06:28:58 +00:00
|
|
|
|
|
|
|
logging.basicConfig(
|
2022-03-22 16:39:58 +00:00
|
|
|
level=logging.DEBUG if args.verbose else logging.INFO, stream=sys.stderr
|
2020-03-19 06:28:58 +00:00
|
|
|
)
|
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
logging.getLogger("MARKDOWN").setLevel(logging.INFO)
|
2020-03-19 06:28:58 +00:00
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
args.rev = (
|
|
|
|
subprocess.check_output("git rev-parse HEAD", shell=True)
|
|
|
|
.decode("utf-8")
|
|
|
|
.strip()
|
|
|
|
)
|
|
|
|
args.rev_short = (
|
|
|
|
subprocess.check_output("git rev-parse --short HEAD", shell=True)
|
|
|
|
.decode("utf-8")
|
|
|
|
.strip()
|
|
|
|
)
|
|
|
|
args.rev_url = f"https://github.com/ClickHouse/ClickHouse/commit/{args.rev}"
|
|
|
|
|
2018-07-09 19:59:07 +00:00
|
|
|
build(args)
|
2020-04-09 20:50:39 +00:00
|
|
|
|
2020-03-13 19:35:03 +00:00
|
|
|
if args.livereload:
|
2022-03-22 16:39:58 +00:00
|
|
|
new_args = [arg for arg in sys.argv if not arg.startswith("--livereload")]
|
|
|
|
new_args = sys.executable + " " + " ".join(new_args)
|
2020-03-13 19:35:03 +00:00
|
|
|
|
|
|
|
server = livereload.Server()
|
2022-03-22 16:39:58 +00:00
|
|
|
server.serve(root=args.output_dir, host="0.0.0.0", port=args.livereload)
|
2020-03-13 19:35:03 +00:00
|
|
|
sys.exit(0)
|