diff --git a/scripts/pull_osbuild_modules.py b/scripts/pull_osbuild_modules.py index 3da23cee89..1168fdc0a3 100755 --- a/scripts/pull_osbuild_modules.py +++ b/scripts/pull_osbuild_modules.py @@ -8,6 +8,11 @@ TEMPLATE = """ # {title} + **{summary}** @@ -81,6 +86,7 @@ def main(): ), schema_1=json.dumps(datas.get("schema", {}), indent=2), schema_2=json.dumps(datas.get("schema_2", {}), indent=2), + originating_url=f"https://github.com/osbuild/osbuild/tree/main/{tiep}/{schema.name}", ) (dest / f"{title}.md").write_text(text) diff --git a/scripts/pull_readmes.py b/scripts/pull_readmes.py index 915ad40302..9ae64e54a0 100644 --- a/scripts/pull_readmes.py +++ b/scripts/pull_readmes.py @@ -5,6 +5,13 @@ import os import requests +TEMPLATE = """ + +""" def resolve_dirs(baseurl, relative_link): """ @@ -100,14 +107,22 @@ def main(): source, targetpath = line.strip().split(':') if source and targetpath: + originating_url = f"{github_baseurl}/{source}" + upstream_reference = originating_url.replace("/main/","/blob/main/") print(f"Downloading {github_rawurl}/{source} to {targetpath}...") download_file(f'{github_rawurl}/{source}', targetpath) print("Download completed.") - - parsed_md = parse_markdown_and_replace_links(targetpath, f'{github_baseurl}/{source}') + + parsed_md = parse_markdown_and_replace_links(targetpath, originating_url) with open(targetpath, 'w', encoding='utf-8') as output_file: - output_file.write(parsed_md) + template_inserted = False + # we need to insert the warning-template _after_ the first heading to have the title correct + for parsed_line in parsed_md.split("\n"): + output_file.write(parsed_line + "\n") + if not template_inserted and parsed_line.startswith("# "): + output_file.write(TEMPLATE.format(upstream_reference=upstream_reference)) + template_inserted = True print(f"Parsing and link replacement completed. Output saved to '{targetpath}'")