Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix index links #14567

Merged
merged 5 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 99 additions & 99 deletions README.md

Large diffs are not rendered by default.

194 changes: 97 additions & 97 deletions README_ko.md

Large diffs are not rendered by default.

196 changes: 97 additions & 99 deletions README_zh-hans.md

Large diffs are not rendered by default.

196 changes: 97 additions & 99 deletions README_zh-hant.md

Large diffs are not rendered by default.

168 changes: 84 additions & 84 deletions docs/source/index.mdx

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions utils/check_copies.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ def _rep(match):
return num_models_equal, "\n".join(map(lambda x: x[1], sorted_index)) + "\n"


def convert_readme_to_index(model_list):
model_list = model_list.replace("https://huggingface.co/docs/transformers/master/", "")
return model_list.replace("https://huggingface.co/docs/transformers/", "")


def _find_text_in_file(filename, start_prompt, end_prompt):
"""
Find the text in `filename` between a line beginning with `start_prompt` and before `end_prompt`, removing empty
Expand Down Expand Up @@ -380,10 +385,11 @@ def check_model_list_copy(overwrite=False, max_per_line=119):

converted_md_lists.append((filename, num_models_equal, converted_md_list, _start_prompt, _end_prompt))

if md_list != index_list:
converted_md_list = convert_readme_to_index(md_list)
if converted_md_list != index_list:
if overwrite:
with open(os.path.join(PATH_TO_DOCS, "index.mdx"), "w", encoding="utf-8", newline="\n") as f:
f.writelines(lines[:start_index] + [md_list] + lines[end_index:])
f.writelines(lines[:start_index] + [converted_md_list] + lines[end_index:])
else:
raise ValueError(
"The model list in the README changed and the list in `index.mdx` has not been updated. Run "
Expand Down
5 changes: 5 additions & 0 deletions utils/check_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ def find_all_documented_objects():
content = f.read()
raw_doc_objs = re.findall(r"(?:autoclass|autofunction):: transformers.(\S+)\s+", content)
documented_obj += [obj.split(".")[-1] for obj in raw_doc_objs]
for doc_file in Path(PATH_TO_DOC).glob("**/*.mdx"):
with open(doc_file, "r", encoding="utf-8", newline="\n") as f:
content = f.read()
raw_doc_objs = re.findall("\[\[autodoc\]\]\s+(\S+)\s+", content)
documented_obj += [obj.split(".")[-1] for obj in raw_doc_objs]
return documented_obj


Expand Down