Fix Docs pretty __init__.py URLs (#14550)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
parent
0d059bec0c
commit
b3b3a15086
16 changed files with 49 additions and 22 deletions
|
|
@ -5,23 +5,23 @@ projects with multilingual content. It streamlines the workflow for generating l
|
|||
and updating HTML links to ensure they are correctly formatted.
|
||||
|
||||
Key Features:
|
||||
- Automated building of MkDocs documentation: The script compiles both the main documentation and
|
||||
any localized versions specified in separate MkDocs configuration files.
|
||||
- Post-processing of generated HTML files: After the documentation is built, the script updates all
|
||||
HTML files to remove the '.md' extension from internal links. This ensures that links in the built
|
||||
HTML documentation correctly point to other HTML pages rather than Markdown files, which is crucial
|
||||
for proper navigation within the web-based documentation.
|
||||
- Automated building of MkDocs documentation: The script compiles both the main documentation and
|
||||
any localized versions specified in separate MkDocs configuration files.
|
||||
- Post-processing of generated HTML files: After the documentation is built, the script updates all
|
||||
HTML files to remove the '.md' extension from internal links. This ensures that links in the built
|
||||
HTML documentation correctly point to other HTML pages rather than Markdown files, which is crucial
|
||||
for proper navigation within the web-based documentation.
|
||||
|
||||
Usage:
|
||||
- Run the script from the root directory of your MkDocs project.
|
||||
- Ensure that MkDocs is installed and that all MkDocs configuration files (main and localized versions)
|
||||
are present in the project directory.
|
||||
- The script first builds the documentation using MkDocs, then scans the generated HTML files in the 'site'
|
||||
directory to update the internal links.
|
||||
- It's ideal for projects where the documentation is written in Markdown and needs to be served as a static website.
|
||||
- Run the script from the root directory of your MkDocs project.
|
||||
- Ensure that MkDocs is installed and that all MkDocs configuration files (main and localized versions)
|
||||
are present in the project directory.
|
||||
- The script first builds the documentation using MkDocs, then scans the generated HTML files in the 'site'
|
||||
directory to update the internal links.
|
||||
- It's ideal for projects where the documentation is written in Markdown and needs to be served as a static website.
|
||||
|
||||
Note:
|
||||
- This script is built to be run in an environment where Python and MkDocs are installed and properly configured.
|
||||
- This script is built to be run in an environment where Python and MkDocs are installed and properly configured.
|
||||
"""
|
||||
|
||||
import os
|
||||
|
|
|
|||
|
|
@ -56,10 +56,11 @@ def create_markdown(py_filepath: Path, module_path: str, classes: list, function
|
|||
module_path = module_path.replace(".", "/")
|
||||
url = f"https://github.com/{GITHUB_REPO}/blob/main/{module_path}.py"
|
||||
edit = f"https://github.com/{GITHUB_REPO}/edit/main/{module_path}.py"
|
||||
pretty = url.replace("__init__.py", "\\_\\_init\\_\\_.py") # properly display __init__.py filenames
|
||||
title_content = (
|
||||
f"# Reference for `{module_path}.py`\n\n"
|
||||
f"!!! Note\n\n"
|
||||
f" This file is available at [{url}]({url}). If you spot a problem please help fix it by [contributing]"
|
||||
f" This file is available at [{pretty}]({url}). If you spot a problem please help fix it by [contributing]"
|
||||
f"(https://docs.ultralytics.com/help/contributing/) a [Pull Request]({edit}) 🛠️. Thank you 🙏!\n\n"
|
||||
)
|
||||
md_content = ["<br><br>\n"] + [f"## ::: {module_name}.{class_name}\n\n<br><br>\n" for class_name in classes]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ keywords: Ultralytics, YOLO, configuration, cfg2dict, get_cfg, check_cfg, save_d
|
|||
|
||||
!!! Note
|
||||
|
||||
This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/__init__.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/__init__.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/cfg/__init__.py) 🛠️. Thank you 🙏!
|
||||
This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/\_\_init\_\_.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/__init__.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/cfg/__init__.py) 🛠️. Thank you 🙏!
|
||||
|
||||
<br><br>
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ keywords: Ultralytics HUB API, login, logout, reset model, export model, check d
|
|||
|
||||
!!! Note
|
||||
|
||||
This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/__init__.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/__init__.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/hub/__init__.py) 🛠️. Thank you 🙏!
|
||||
This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/\_\_init\_\_.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/__init__.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/hub/__init__.py) 🛠️. Thank you 🙏!
|
||||
|
||||
<br><br>
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ keywords: Ultralytics, utils, TQDM, Python, ML, Machine Learning utilities, YOLO
|
|||
|
||||
!!! Note
|
||||
|
||||
This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/__init__.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/__init__.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/utils/__init__.py) 🛠️. Thank you 🙏!
|
||||
This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/\_\_init\_\_.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/__init__.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/utils/__init__.py) 🛠️. Thank you 🙏!
|
||||
|
||||
<br><br>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue