From 8975d2b795a7edaef9f2bb8a90ef9fea5617ee9a Mon Sep 17 00:00:00 2001 From: Birgit Brecknell Date: Mon, 29 Jul 2024 12:33:50 +1000 Subject: [PATCH] add code to render onsite links when compiling for docsite Signed-off-by: Birgit Brecknell --- template.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/template.py b/template.py index b6337517..198bb8e7 100755 --- a/template.py +++ b/template.py @@ -19,6 +19,7 @@ except ImportError: from yaml import Loader, Dumper +from io import StringIO def build_render_list(args): ''' @@ -64,6 +65,7 @@ def render_file(args, env, state, file): is for dependency tracking ''' filename = os.path.join(args.out_dir, file) + # Create required directories if not os.path.exists(os.path.dirname(filename)): os.makedirs(os.path.dirname(filename)) @@ -78,7 +80,21 @@ def render_file(args, env, state, file): # process template file input = in_stream.read() - template = env.from_string(input) + + if(args.__getattribute__("docsite")): + s = StringIO(input) + lines = input.split('\n') + + i = 0 + for line in s: + lines[i] = line.replace("https://docs.sel4.systems/tutorials/","/tutorials/") + i = i + 1 + + new_text = '\n'.join(lines) + template = env.from_string(new_text) + + else: + template = env.from_string(input()) out_stream.write(template.render(context.get_context(args, state)))