Skip to content

Commit 2ceeb32

Browse files
committed
Use markdown-based docs for rocky10/almalinux10 x86_64 warewulf4 variants
Update docs.spec to build documentation from markdown sources for the two variants that support the markdown approach (rocky10/x86_64/warewulf4/slurm and almalinux10/x86_64/warewulf4/slurm). Other variants continue using LaTeX. Changes: - Add BuildRequires for markdown toolchain (pandoc, python3-jinja2, python3-pyyaml, mdtoc, texlive-xetex, etc.) - Split build/install sections to handle markdown and LaTeX separately - Add jinja2-render.py script as replacement for jinja2-cli (not available on RHEL 10) - Update Makefile.common to use jinja2-render.py instead of jinja2 Generated with Claude Code (https://claude.ai/code) Signed-off-by: Adrian Reber <areber@redhat.com>
1 parent a16b50b commit 2ceeb32

File tree

3 files changed

+142
-5
lines changed

3 files changed

+142
-5
lines changed

components/admin/docs/SPECS/docs.spec

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
%include %{_sourcedir}/OHPC_macros
1212

1313
%define recipe_base docs/recipes/install
14+
%define recipe_base_md docs/recipes/install/poc-markdown
1415
%define recipe_dest %{buildroot}/%{OHPC_PUB}/doc/recipes
1516

1617
Name: docs%{PROJ_DELIM}
@@ -25,6 +26,19 @@ Source0: docs-ohpc.tar
2526
BuildRequires: git
2627
BuildRequires: make
2728
BuildRequires: python3
29+
30+
# Requirements for markdown-based documentation (pandoc + jinja2)
31+
BuildRequires: pandoc
32+
BuildRequires: python3-jinja2
33+
BuildRequires: python3-pyyaml
34+
BuildRequires: mdtoc%{PROJ_DELIM}
35+
BuildRequires: texlive-xetex
36+
BuildRequires: texlive-adjustbox
37+
BuildRequires: texlive-collectbox
38+
BuildRequires: texlive-unicode-math
39+
BuildRequires: texlive-lm-math
40+
41+
# Requirements for LaTeX-based documentation (and shared with markdown/pandoc)
2842
BuildRequires: texlive-latex
2943
BuildRequires: texlive-caption
3044
BuildRequires: texlive-colortbl
@@ -75,14 +89,28 @@ from the OpenHPC software stack.
7589
%define parser_perl ../../../../parse_doc.pl
7690
%define parser_python ../../../../parse_doc.py
7791

92+
# Build markdown-based documentation
93+
for recipe_path in \
94+
"almalinux10/x86_64/warewulf4/slurm" \
95+
"rocky10/x86_64/warewulf4/slurm" \
96+
; do
97+
pushd "%{recipe_base_md}/${recipe_path}"
98+
99+
# Build markdown, PDF, and recipe.sh
100+
make
101+
make pdf
102+
make recipe
103+
104+
popd
105+
done
106+
107+
# Build LaTeX-based documentation
78108
for recipe_path in \
79109
"almalinux10/x86_64/confluent/slurm" \
80110
"almalinux10/x86_64/openchami/slurm" \
81-
"almalinux10/x86_64/warewulf4/slurm" \
82111
"almalinux10/aarch64/warewulf4/slurm" \
83112
"openeuler24.03/x86_64/warewulf4/slurm" \
84113
"openeuler24.03/aarch64/warewulf4/slurm" \
85-
"rocky10/x86_64/warewulf4/slurm" \
86114
"rocky10/aarch64/warewulf4/slurm" \
87115
"rocky10/x86_64/openchami/slurm" \
88116
; do
@@ -131,14 +159,22 @@ done
131159
install -m 0644 -p docs/ChangeLog %{buildroot}/%{OHPC_PUB}/doc/ChangeLog
132160
install -m 0644 -p docs/Release_Notes.txt %{buildroot}/%{OHPC_PUB}/doc/Release_Notes.txt
133161

162+
# Install markdown-based documentation
163+
for recipe_path in \
164+
"almalinux10/x86_64/warewulf4/slurm" \
165+
"rocky10/x86_64/warewulf4/slurm" \
166+
; do
167+
install -m 0644 -p -D "%{recipe_base_md}/${recipe_path}/steps.pdf" "%{recipe_dest}/${recipe_path}/Install_guide.pdf"
168+
install -m 0755 -p -D "%{recipe_base_md}/${recipe_path}/recipe.sh" "%{recipe_dest}/${recipe_path}/recipe.sh"
169+
done
170+
171+
# Install LaTeX-based documentation
134172
for recipe_path in \
135173
"almalinux10/x86_64/confluent/slurm" \
136174
"almalinux10/x86_64/openchami/slurm" \
137-
"almalinux10/x86_64/warewulf4/slurm" \
138175
"almalinux10/aarch64/warewulf4/slurm" \
139176
"openeuler24.03/x86_64/warewulf4/slurm" \
140177
"openeuler24.03/aarch64/warewulf4/slurm" \
141-
"rocky10/x86_64/warewulf4/slurm" \
142178
"rocky10/aarch64/warewulf4/slurm" \
143179
"rocky10/x86_64/openchami/slurm" \
144180
; do

docs/recipes/install/poc-markdown/common/Makefile.common

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ COMMON_TEMPLATES := ../../../../common
2020
HEADER_TEX := .header-includes.tex
2121

2222
# jinja2 command with search path for includes
23-
JINJA2 := jinja2
23+
JINJA2 := $(COMMON_TEMPLATES)/jinja2-render.py
2424
JINJA2_FLAGS := --strict --format=yaml
2525

2626
# Build the final markdown document
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Simple Jinja2 template renderer - replacement for jinja2-cli.
4+
5+
Usage: jinja2-render.py [--strict] [--format=yaml] TEMPLATE [DATA_FILE] [-o OUTPUT]
6+
7+
This script provides a minimal replacement for the jinja2-cli tool,
8+
supporting the subset of features used by OpenHPC documentation builds.
9+
"""
10+
11+
import argparse
12+
import os
13+
import sys
14+
from pathlib import Path
15+
16+
import yaml
17+
from jinja2 import Environment, FileSystemLoader, StrictUndefined, Undefined
18+
19+
20+
def main():
21+
parser = argparse.ArgumentParser(
22+
description="Render Jinja2 templates with YAML data",
23+
formatter_class=argparse.RawDescriptionHelpFormatter,
24+
)
25+
parser.add_argument(
26+
"template",
27+
help="Jinja2 template file to render",
28+
)
29+
parser.add_argument(
30+
"data_file",
31+
nargs="?",
32+
help="YAML data file with template variables",
33+
)
34+
parser.add_argument(
35+
"-o", "--output",
36+
dest="output",
37+
help="Output file (default: stdout)",
38+
)
39+
parser.add_argument(
40+
"--strict",
41+
action="store_true",
42+
help="Fail on undefined variables",
43+
)
44+
parser.add_argument(
45+
"--format",
46+
dest="data_format",
47+
default="yaml",
48+
choices=["yaml"],
49+
help="Data file format (default: yaml)",
50+
)
51+
52+
args = parser.parse_args()
53+
54+
# Resolve template path
55+
template_path = Path(args.template).resolve()
56+
if not template_path.exists():
57+
print(f"Error: Template file not found: {args.template}", file=sys.stderr)
58+
sys.exit(1)
59+
60+
# Set up Jinja2 environment with template directory as search path
61+
template_dir = template_path.parent
62+
env = Environment(
63+
loader=FileSystemLoader(str(template_dir)),
64+
undefined=StrictUndefined if args.strict else Undefined,
65+
# Keep trailing newlines (like jinja2-cli default)
66+
keep_trailing_newline=True,
67+
)
68+
69+
# Load template
70+
template = env.get_template(template_path.name)
71+
72+
# Load data from YAML file
73+
data = {}
74+
if args.data_file:
75+
data_path = Path(args.data_file)
76+
if not data_path.exists():
77+
print(f"Error: Data file not found: {args.data_file}", file=sys.stderr)
78+
sys.exit(1)
79+
80+
with open(data_path, "r", encoding="utf-8") as f:
81+
data = yaml.safe_load(f) or {}
82+
83+
# Render template
84+
try:
85+
output = template.render(**data)
86+
except Exception as e:
87+
print(f"Error rendering template: {e}", file=sys.stderr)
88+
sys.exit(1)
89+
90+
# Write output
91+
if args.output:
92+
output_path = Path(args.output)
93+
output_path.parent.mkdir(parents=True, exist_ok=True)
94+
with open(output_path, "w", encoding="utf-8") as f:
95+
f.write(output)
96+
else:
97+
sys.stdout.write(output)
98+
99+
100+
if __name__ == "__main__":
101+
main()

0 commit comments

Comments
 (0)