Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: add comment that the files are generated #101

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions scripts/pull_osbuild_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

TEMPLATE = """
# {title}
<!--
[//]: # ( DO NOT MODIFY THIS FILE! )
[//]: # ( This content is generated by `scripts/pull_osbuild_modules.py` )
[//]: # ( Rather change the source of this: {originating_url} )
-->

**{summary}**

Expand Down Expand Up @@ -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)
Expand Down
21 changes: 18 additions & 3 deletions scripts/pull_readmes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
import os
import requests

TEMPLATE = """
<!--
[//]: # ( DO NOT MODIFY THIS FILE! )
[//]: # ( This content is generated by `scripts/pull_readmes.py` )
[//]: # ( Rather change the source of this: {upstream_reference} )
-->
"""

def resolve_dirs(baseurl, relative_link):
"""
Expand Down Expand Up @@ -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}'")

Expand Down