mirror of
https://github.com/THU-MIG/yolov10.git
synced 2025-05-23 13:34:23 +08:00
Update build_docs.py for page titles (#6574)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
bdb718602e
commit
a1ccdb00ed
@ -83,6 +83,21 @@ def update_html_links():
|
||||
print(f'Total number of links updated: {total_updated_links}')
|
||||
|
||||
|
||||
def update_page_title(file_path: Path, new_title: str):
|
||||
"""Update the title of an HTML file."""
|
||||
|
||||
# Read the content of the file
|
||||
with open(file_path, encoding='utf-8') as file:
|
||||
content = file.read()
|
||||
|
||||
# Replace the existing title with the new title
|
||||
updated_content = re.sub(r'<title>.*?</title>', f'<title>{new_title}</title>', content)
|
||||
|
||||
# Write the updated content back to the file
|
||||
with open(file_path, 'w', encoding='utf-8') as file:
|
||||
file.write(updated_content)
|
||||
|
||||
|
||||
def main():
|
||||
# Build the docs
|
||||
build_docs()
|
||||
@ -93,6 +108,9 @@ def main():
|
||||
# Show command to serve built website
|
||||
print('Serve site at http://localhost:8000 with "python -m http.server --directory site"')
|
||||
|
||||
# Update titles
|
||||
update_page_title(SITE / '404.html', new_title='Ultralytics Docs - Not Found')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user