docs, infra: cerebras docs, update docs template linting with better error (#25782)

This commit is contained in:
Erick Friis
2024-08-27 10:19:59 -07:00
committed by GitHub
parent 48b579f6b5
commit 2aa35d80a0
3 changed files with 468 additions and 12 deletions

View File

@@ -66,19 +66,22 @@ def check_header_order(path: Path) -> None:
with open(path, "r") as f:
doc = f.read()
regex = r".*".join(headers)
if not re.search(regex, doc, re.DOTALL):
issueline = (
(
" Please see https://github.com/langchain-ai/langchain/issues/"
f"{issue_number} for instructions on how to correctly format a "
f"{doc_dir} integration page."
)
if isinstance(issue_number, int)
else ""
)
notfound = []
for header in headers:
index = doc.find(header)
if index == -1:
notfound.append(header)
doc = doc[index + len(header) :]
if notfound:
notfound_headers = "\n- ".join(notfound)
raise ValueError(
f"Document {path} does not match the expected header order.{issueline}"
f"Document {path} is missing headers:"
"\n- "
f"{notfound_headers}"
"\n\n"
"Please see https://github.com/langchain-ai/langchain/issues/"
f"{issue_number} for instructions on how to correctly format a "
f"{doc_dir} integration page."
)