2024-03-11 17:50:39 +00:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
DOCS_DIR = Path(os.path.abspath(__file__)).parents[1]
|
|
|
|
|
|
|
|
|
|
|
|
def update_links(doc_path, docs_link):
|
|
|
|
with open(DOCS_DIR / doc_path, "r") as f:
|
|
|
|
content = f.read()
|
|
|
|
|
|
|
|
# replace relative links
|
2024-05-17 22:59:27 +00:00
|
|
|
content = re.sub(r"\]\(\.\/", f"]({docs_link}", content)
|
2024-03-11 17:50:39 +00:00
|
|
|
|
2024-05-24 19:44:46 +00:00
|
|
|
frontmatter = """---
|
|
|
|
custom_edit_url:
|
|
|
|
---
|
|
|
|
"""
|
|
|
|
|
2024-03-11 17:50:39 +00:00
|
|
|
with open(DOCS_DIR / doc_path, "w") as f:
|
2024-05-24 19:44:46 +00:00
|
|
|
f.write(frontmatter + content)
|
2024-03-11 17:50:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
update_links(sys.argv[1], sys.argv[2])
|