ultralytics 8.0.239 Ultralytics Actions and hub-sdk adoption (#7431)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Burhan <62214284+Burhan-Q@users.noreply.github.com> Co-authored-by: Kayzwer <68285002+Kayzwer@users.noreply.github.com>
This commit is contained in:
parent
e795277391
commit
fe27db2f6e
139 changed files with 6870 additions and 5125 deletions
|
|
@ -30,45 +30,47 @@ import subprocess
|
|||
from pathlib import Path
|
||||
|
||||
DOCS = Path(__file__).parent.resolve()
|
||||
SITE = DOCS.parent / 'site'
|
||||
SITE = DOCS.parent / "site"
|
||||
|
||||
|
||||
def build_docs():
|
||||
"""Build docs using mkdocs."""
|
||||
if SITE.exists():
|
||||
print(f'Removing existing {SITE}')
|
||||
print(f"Removing existing {SITE}")
|
||||
shutil.rmtree(SITE)
|
||||
|
||||
# Build the main documentation
|
||||
print(f'Building docs from {DOCS}')
|
||||
subprocess.run(f'mkdocs build -f {DOCS}/mkdocs.yml', check=True, shell=True)
|
||||
print(f"Building docs from {DOCS}")
|
||||
subprocess.run(f"mkdocs build -f {DOCS}/mkdocs.yml", check=True, shell=True)
|
||||
|
||||
# Build other localized documentations
|
||||
for file in DOCS.glob('mkdocs_*.yml'):
|
||||
print(f'Building MkDocs site with configuration file: {file}')
|
||||
subprocess.run(f'mkdocs build -f {file}', check=True, shell=True)
|
||||
print(f'Site built at {SITE}')
|
||||
for file in DOCS.glob("mkdocs_*.yml"):
|
||||
print(f"Building MkDocs site with configuration file: {file}")
|
||||
subprocess.run(f"mkdocs build -f {file}", check=True, shell=True)
|
||||
print(f"Site built at {SITE}")
|
||||
|
||||
|
||||
def update_html_links():
|
||||
"""Update href links in HTML files to remove '.md' and '/index.md', excluding links starting with 'https://'."""
|
||||
html_files = Path(SITE).rglob('*.html')
|
||||
html_files = Path(SITE).rglob("*.html")
|
||||
total_updated_links = 0
|
||||
|
||||
for html_file in html_files:
|
||||
with open(html_file, 'r+', encoding='utf-8') as file:
|
||||
with open(html_file, "r+", encoding="utf-8") as file:
|
||||
content = file.read()
|
||||
# Find all links to be updated, excluding those starting with 'https://'
|
||||
links_to_update = re.findall(r'href="(?!https://)([^"]+?)(/index)?\.md"', content)
|
||||
|
||||
# Update the content and count the number of links updated
|
||||
updated_content, number_of_links_updated = re.subn(r'href="(?!https://)([^"]+?)(/index)?\.md"',
|
||||
r'href="\1"', content)
|
||||
updated_content, number_of_links_updated = re.subn(
|
||||
r'href="(?!https://)([^"]+?)(/index)?\.md"', r'href="\1"', content
|
||||
)
|
||||
total_updated_links += number_of_links_updated
|
||||
|
||||
# Special handling for '/index' links
|
||||
updated_content, number_of_index_links_updated = re.subn(r'href="([^"]+)/index"', r'href="\1/"',
|
||||
updated_content)
|
||||
updated_content, number_of_index_links_updated = re.subn(
|
||||
r'href="([^"]+)/index"', r'href="\1/"', updated_content
|
||||
)
|
||||
total_updated_links += number_of_index_links_updated
|
||||
|
||||
# Write the updated content back to the file
|
||||
|
|
@ -78,23 +80,23 @@ def update_html_links():
|
|||
|
||||
# Print updated links for this file
|
||||
for link in links_to_update:
|
||||
print(f'Updated link in {html_file}: {link[0]}')
|
||||
print(f"Updated link in {html_file}: {link[0]}")
|
||||
|
||||
print(f'Total number of links updated: {total_updated_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:
|
||||
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)
|
||||
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:
|
||||
with open(file_path, "w", encoding="utf-8") as file:
|
||||
file.write(updated_content)
|
||||
|
||||
|
||||
|
|
@ -109,8 +111,8 @@ def main():
|
|||
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')
|
||||
update_page_title(SITE / "404.html", new_title="Ultralytics Docs - Not Found")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue