ClickHouse/docs/tools/website.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
1.7 KiB
Python
Raw Normal View History

2022-05-09 00:11:58 +00:00
import hashlib
import json
import logging
import os
import shutil
2022-05-09 00:11:58 +00:00
import subprocess
import util
2020-03-30 08:25:29 +00:00
2020-02-18 14:19:44 +00:00
def build_website(args):
logging.info("Building website")
env = util.init_jinja2_env(args)
2020-02-18 14:19:44 +00:00
shutil.copytree(
args.website_dir,
args.output_dir,
ignore=shutil.ignore_patterns(
"*.md",
"*.sh",
"*.css",
"*.json",
"js/*.js",
"build",
"docs",
"public",
"node_modules",
"src",
"templates",
"locale",
".gitkeep",
),
)
# This file can be requested to check for available ClickHouse releases.
shutil.copy2(
os.path.join(args.src_dir, "utils", "list-versions", "version_date.tsv"),
os.path.join(args.output_dir, "data", "version_date.tsv"),
)
2021-10-12 20:09:26 +00:00
# This file can be requested to install ClickHouse.
shutil.copy2(
os.path.join(args.src_dir, "docs", "_includes", "install", "universal.sh"),
os.path.join(args.output_dir, "data", "install.sh"),
)
2021-10-12 20:09:26 +00:00
2020-02-18 14:19:44 +00:00
for root, _, filenames in os.walk(args.output_dir):
for filename in filenames:
if filename == "main.html":
continue
2020-02-18 14:19:44 +00:00
path = os.path.join(root, filename)
if not filename.endswith(".html"):
2020-02-18 14:19:44 +00:00
continue
logging.info("Processing %s", path)
with open(path, "rb") as f:
content = f.read().decode("utf-8")
2020-02-18 14:19:44 +00:00
template = env.from_string(content)
content = template.render(args.__dict__)
with open(path, "wb") as f:
f.write(content.encode("utf-8"))