Docs spelling and grammar fixes (#13307)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: RainRat <rainrat78@yahoo.ca>
This commit is contained in:
Glenn Jocher 2024-06-02 14:07:14 +02:00 committed by GitHub
parent bddea17bf3
commit 064e2fd282
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 179 additions and 172 deletions

View file

@ -116,13 +116,21 @@ def update_subdir_edit_links(subdir="", docs_url=""):
file.write(str(soup))
def add_frontmatter(md_filepath: Path):
def update_page(md_filepath: Path):
"""Creates or updates a Markdown file, ensuring frontmatter is present."""
if md_filepath.exists():
existing_content = md_filepath.read_text()
if not existing_content.strip().startswith("---\n"):
content = md_filepath.read_text()
# Replace apostrophes
content = content.replace("", "'").replace("", "'")
# Add frontmatter if missing
if not content.strip().startswith("---\n"):
header = "---\ncomments: true\ndescription: TODO ADD DESCRIPTION\nkeywords: TODO ADD KEYWORDS\n---\n\n"
md_filepath.write_text(header + existing_content)
content = header + content
# Save page
md_filepath.write_text(content)
return
@ -132,7 +140,7 @@ def main():
# Add frontmatter
for file in tqdm((DOCS / "en").rglob("*.md"), desc="Adding frontmatter"):
add_frontmatter(file)
update_page(file)
# Update titles
update_page_title(SITE / "404.html", new_title="Ultralytics Docs - Not Found")