docs: simplify templating of install pages

This commit is contained in:
Wez Furlong committed 2023-03-21 09:31:49 -07:00
1 parent 0b83c97427
commit 19c9bc84f2
10 files changed
+15 -20

No files matched your search

+1 -1
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
+1 -1
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
+1 -1
View File
@@ -305,7 +305,7 @@ function load_scheme_player(ident) {{
idx.write(
f"""
```lua
config.color_scheme = "{title}"
config.color_scheme = '{title}'
```
"""
+5 -17
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():
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+7
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":