1
1
mirror of https://github.com/wez/wezterm.git synced 2024-08-17 10:10:23 +03:00

docs: simplify templating of install pages

This commit is contained in:
Wez Furlong 2023-03-21 09:31:49 -07:00
parent 0b83c97427
commit 19c9bc84f2
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387
10 changed files with 15 additions and 20 deletions

2
.gitignore vendored
View File

@ -15,8 +15,8 @@ dhat-heap.json
/termwiz/codegen/target
/termwiz/codegen/Cargo.lock
/gh_pages/
/docs/releases.json
/docs/SUMMARY.md
/docs/install/*.md
/docs/cli/cli/index.md
/docs/recipes/index.md
/docs/colorschemes/**/index.md

View File

@ -8,7 +8,7 @@ done
tracked_markdown=$(mktemp)
trap "rm ${tracked_markdown}" "EXIT"
git ls-tree -r HEAD --name-only docs | egrep '\.(markdown|md)$' > $tracked_markdown
find docs -type f | egrep '\.(markdown|md)$' > $tracked_markdown
gelatyx --language lua --file-list $tracked_markdown --language-config ci/stylua.toml
gelatyx --language lua --file-list $tracked_markdown --language-config ci/stylua.toml --check || exit 1

View File

@ -305,7 +305,7 @@ function load_scheme_player(ident) {{
idx.write(
f"""
```lua
config.color_scheme = "{title}"
config.color_scheme = '{title}'
```
"""

View File

@ -50,9 +50,9 @@ def build_subst(subst, stable, categorized):
continue
url, name, dir = info
kind = f"{kind}_{stable}"
subst["{{ %s }}" % kind] = url
subst["{{ %s_asset }}" % kind] = name
subst["{{ %s_dir }}" % kind] = dir
subst[kind] = url
subst[f"{kind}_asset"] = name
subst[f"{kind}_dir"] = dir
def load_release_info():
@ -83,21 +83,9 @@ def load_release_info():
subst = {}
build_subst(subst, "stable", latest)
build_subst(subst, "nightly", nightly)
# print(pretty(subst))
for name in [
"install/windows",
"install/macos",
"install/linux",
"install/source",
"install/freebsd",
]:
with open(f"docs/{name}.markdown", "r") as input:
with open(f"docs/{name}.md", "w") as output:
for line in input:
for search, replace in subst.items():
line = line.replace(search, replace)
output.write(line)
with open(f"docs/releases.json", "w") as output:
json.dump(subst, output)
def main():

View File

@ -1,5 +1,12 @@
import json
# https://mkdocs-macros-plugin.readthedocs.io/en/latest/macros/
def define_env(env):
with open("docs/releases.json") as f:
for (k, v) in json.load(f).items():
env.variables[k] = v
@env.macro
def since(vers, outline=False, inline=False):
if vers == "nightly":