ultralytics 8.0.141 create new SettingsManager (#3790)
This commit is contained in:
parent
42afe772d5
commit
20f5efd40a
215 changed files with 917 additions and 749 deletions
|
|
@ -21,8 +21,8 @@ def extract_classes_and_functions(filepath):
|
|||
with open(filepath, 'r') as file:
|
||||
content = file.read()
|
||||
|
||||
class_pattern = r"(?:^|\n)class\s(\w+)(?:\(|:)"
|
||||
func_pattern = r"(?:^|\n)def\s(\w+)\("
|
||||
class_pattern = r'(?:^|\n)class\s(\w+)(?:\(|:)'
|
||||
func_pattern = r'(?:^|\n)def\s(\w+)\('
|
||||
|
||||
classes = re.findall(class_pattern, content)
|
||||
functions = re.findall(func_pattern, content)
|
||||
|
|
@ -34,18 +34,21 @@ def create_markdown(py_filepath, module_path, classes, functions):
|
|||
md_filepath = py_filepath.with_suffix('.md')
|
||||
|
||||
# Read existing content and keep header content between first two ---
|
||||
header_content = ""
|
||||
header_content = ''
|
||||
if md_filepath.exists():
|
||||
with open(md_filepath, 'r') as file:
|
||||
existing_content = file.read()
|
||||
header_parts = existing_content.split('---', 2)
|
||||
if 'description:' in header_parts or 'comments:' in header_parts and len(header_parts) >= 3:
|
||||
header_content = f"{header_parts[0]}---{header_parts[1]}---\n\n"
|
||||
header_parts = existing_content.split('---')
|
||||
for part in header_parts:
|
||||
if 'description:' in part or 'comments:' in part:
|
||||
header_content += f'---{part}---\n\n'
|
||||
|
||||
module_path = module_path.replace('.__init__', '')
|
||||
md_content = [f"## {class_name}\n---\n### ::: {module_path}.{class_name}\n<br><br>\n" for class_name in classes]
|
||||
md_content.extend(f"## {func_name}\n---\n### ::: {module_path}.{func_name}\n<br><br>\n" for func_name in functions)
|
||||
md_content = header_content + "\n".join(md_content)
|
||||
md_content = [f'## {class_name}\n---\n### ::: {module_path}.{class_name}\n<br><br>\n' for class_name in classes]
|
||||
md_content.extend(f'## {func_name}\n---\n### ::: {module_path}.{func_name}\n<br><br>\n' for func_name in functions)
|
||||
md_content = header_content + '\n'.join(md_content)
|
||||
if not md_content.endswith('\n'):
|
||||
md_content += '\n'
|
||||
|
||||
os.makedirs(os.path.dirname(md_filepath), exist_ok=True)
|
||||
with open(md_filepath, 'w') as file:
|
||||
|
|
@ -81,11 +84,11 @@ def create_nav_menu_yaml(nav_items):
|
|||
nav_tree_sorted = sort_nested_dict(nav_tree)
|
||||
|
||||
def _dict_to_yaml(d, level=0):
|
||||
yaml_str = ""
|
||||
indent = " " * level
|
||||
yaml_str = ''
|
||||
indent = ' ' * level
|
||||
for k, v in d.items():
|
||||
if isinstance(v, dict):
|
||||
yaml_str += f"{indent}- {k}:\n{_dict_to_yaml(v, level + 1)}"
|
||||
yaml_str += f'{indent}- {k}:\n{_dict_to_yaml(v, level + 1)}'
|
||||
else:
|
||||
yaml_str += f"{indent}- {k}: {str(v).replace('docs/', '')}\n"
|
||||
return yaml_str
|
||||
|
|
@ -99,7 +102,7 @@ def main():
|
|||
nav_items = []
|
||||
for root, _, files in os.walk(CODE_DIR):
|
||||
for file in files:
|
||||
if file.endswith(".py"):
|
||||
if file.endswith('.py'):
|
||||
py_filepath = Path(root) / file
|
||||
classes, functions = extract_classes_and_functions(py_filepath)
|
||||
|
||||
|
|
@ -113,5 +116,5 @@ def main():
|
|||
create_nav_menu_yaml(nav_items)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue