Skip to content

Commit

Permalink
Fix index links (#14567)
Browse files Browse the repository at this point in the history
* Fix links in README

* Localized READMEs

* Fix copy script

* Fix find doc script

* Update README_ko.md

Co-authored-by: Julien Chaumond <julien@huggingface.co>

Co-authored-by: Julien Chaumond <julien@huggingface.co>
  • Loading branch information
sgugger and julien-c authored Dec 1, 2021
1 parent 93cdd26 commit 370d1c9
Show file tree
Hide file tree
Showing 7 changed files with 487 additions and 480 deletions.
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

0 comments on commit 370d1c9

Please sign in to comment.