Fix readme links and add CI check (#16392)
* Fix doc links in README * Fix name * Fix links in READMEs and doc index * Error if there is something wrong so the CI knows
This commit is contained in:
@@ -364,6 +364,22 @@ def _find_text_in_file(filename, start_prompt, end_prompt):
|
||||
|
||||
def check_model_list_copy(overwrite=False, max_per_line=119):
|
||||
"""Check the model lists in the README and index.rst are consistent and maybe `overwrite`."""
|
||||
# Fix potential doc links in the README
|
||||
with open(os.path.join(REPO_PATH, "README.md"), "r", encoding="utf-8", newline="\n") as f:
|
||||
readme = f.read()
|
||||
new_readme = readme.replace("https://huggingface.co/transformers", "https://huggingface.co/docs/transformers")
|
||||
new_readme = readme.replace(
|
||||
"https://huggingface.co/docs/main/transformers", "https://huggingface.co/docs/transformers/main"
|
||||
)
|
||||
if new_readme != readme:
|
||||
if overwrite:
|
||||
with open(os.path.join(REPO_PATH, "README.md"), "w", encoding="utf-8", newline="\n") as f:
|
||||
f.write(new_readme)
|
||||
else:
|
||||
raise ValueError(
|
||||
"The main README contains wrong links to the documentation of Transformers. Run `make fix-copies` to "
|
||||
"automatically fix them."
|
||||
)
|
||||
|
||||
# If the introduction or the conclusion of the list change, the prompts may need to be updated.
|
||||
index_list, start_index, end_index, lines = _find_text_in_file(
|
||||
|
||||
Reference in New Issue
Block a user