aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2021-01-10 07:48:34 -0500
committerGitHub <noreply@github.com>2021-01-10 14:48:34 +0200
commitc18a9715b83ef94a56c064edee511162998001cc (patch)
tree886b73902c9c9767b987b88d74b1429013ab7930 /tools
parent832bcac0a793d63f4bf093c12580b4a605155476 (diff)
downloadmeson-c18a9715b83ef94a56c064edee511162998001cc.zip
meson-c18a9715b83ef94a56c064edee511162998001cc.tar.gz
meson-c18a9715b83ef94a56c064edee511162998001cc.tar.bz2
Hotdoc: use template for Commands.md instead of generating the entire file (#8154)
* doc: fix hotdoc misuse for dynamically generated content hotdoc has a native include feature for including files inline. Use this to generate one file for each dynamically generated code block, and include that file in Commands.md; see: https://hotdoc.github.io/syntax-extensions.html#smart-file-inclusion-syntax This permits us to move back to using the in-tree version of the hotdoc *.md sources, thus fixing the incorrect inclusion of "builddir/" in the "Edit on github" links which resulted from using copies as the source. Fixes #8061 * doc: call the dummy file a "stamp" as it is a better known term
Diffstat (limited to 'tools')
-rwxr-xr-xtools/regenerate_docs.py20
1 files changed, 6 insertions, 14 deletions
diff --git a/tools/regenerate_docs.py b/tools/regenerate_docs.py
index 74a8b0c..b9b994a 100755
--- a/tools/regenerate_docs.py
+++ b/tools/regenerate_docs.py
@@ -20,7 +20,6 @@ Regenerate markdown docs by using `meson.py` from the root dir
'''
import argparse
-import jinja2
import os
import re
import subprocess
@@ -108,20 +107,13 @@ def get_commands_data(root_dir: Path) -> T.Dict[str, T.Any]:
return cmd_data
-def regenerate_commands(root_dir: Path, output_dir: Path) -> None:
- with open(root_dir/'docs'/'markdown_dynamic'/'Commands.md') as f:
- template = f.read()
-
+def generate_hotdoc_includes(root_dir: Path, output_dir: Path) -> None:
cmd_data = get_commands_data(root_dir)
- t = jinja2.Template(template, undefined=jinja2.StrictUndefined, keep_trailing_newline=True)
- content = t.render(cmd_help=cmd_data)
-
- output_file = output_dir/'Commands.md'
- with open(output_file, 'w') as f:
- f.write(content)
-
- print(f'`{output_file}` was regenerated')
+ for cmd, parsed in cmd_data.items():
+ for typ in parsed.keys():
+ with open(output_dir / (cmd+'_'+typ+'.inc'), 'w') as f:
+ f.write(parsed[typ])
def regenerate_docs(output_dir: PathLike,
dummy_output_file: T.Optional[PathLike]) -> None:
@@ -133,7 +125,7 @@ def regenerate_docs(output_dir: PathLike,
root_dir = Path(__file__).resolve().parent.parent
- regenerate_commands(root_dir, output_dir)
+ generate_hotdoc_includes(root_dir, output_dir)
if dummy_output_file:
with open(output_dir/dummy_output_file, 'w') as f: