mirror of
https://github.com/hwchase17/langchain.git
synced 2026-04-02 18:32:56 +00:00
24 lines
616 B
Python
24 lines
616 B
Python
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):
|
|
for path in (DOCS_DIR / doc_path).glob("**/*"):
|
|
if path.is_file() and path.suffix in [".md", ".mdx", ".ipynb"]:
|
|
with open(path, "r") as f:
|
|
content = f.read()
|
|
|
|
# replace relative links
|
|
content = re.sub("\]\(\/docs\/(?!0\.2\.x)", f"]({docs_link}", content)
|
|
|
|
with open(path, "w") as f:
|
|
f.write(content)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
update_links(sys.argv[1], sys.argv[2])
|