Skip to content

Commit

Permalink
add code to render onsite links when compiling for docsite
Browse files Browse the repository at this point in the history
Signed-off-by: Birgit Brecknell <b@brck.nl>
  • Loading branch information
bbrcknl committed Jul 29, 2024
1 parent 23794cc commit 8975d2b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion template.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
except ImportError:
from yaml import Loader, Dumper

from io import StringIO

def build_render_list(args):
'''
Expand Down Expand Up @@ -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))
Expand All @@ -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)))

Expand Down

0 comments on commit 8975d2b

Please sign in to comment.