docs: fix api ref link generation (#22438)

Co-authored-by: Bagatur <baskaryan@gmail.com>
pull/22507/head
Erick Friis 2 months ago committed by GitHub
parent efcb04f84b
commit c438b5b78e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

File diff suppressed because one or more lines are too long

@ -30,13 +30,18 @@ _DOCS_DIR = _CURRENT_PATH / "docs"
def find_files(path):
"""Find all MDX files in the given path"""
# Check if is file first
if ".ipynb_checkpoints" in str(path):
return
if os.path.isfile(path):
yield path
return
for root, _, files in os.walk(path):
for file in files:
if file.endswith(".mdx") or file.endswith(".md"):
yield os.path.join(root, file)
full = os.path.join(root, file)
if ".ipynb_checkpoints" in str(full):
continue
yield full
def get_full_module_name(module_path, class_name):
@ -79,7 +84,7 @@ def main():
.replace(".md", "/")
)
doc_url = f"https://python.langchain.com/docs/{relative_path}"
doc_url = f"https://python.langchain.com/v0.2/docs/{relative_path}"
for import_info in file_imports:
doc_title = import_info["title"]
class_name = import_info["imported"]
@ -97,7 +102,7 @@ def main():
def _get_doc_title(data: str, file_name: str) -> str:
try:
return re.findall(r"^#\s+(.*)", data, re.MULTILINE)[0]
return re.findall(r"^#\s*(.*)", data, re.MULTILINE)[0]
except IndexError:
pass
# Parse the rst-style titles

Loading…
Cancel
Save