You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
swarms/scripts/auto_tests_docs/mkdocs_handler.py

32 lines
1.1 KiB

5 months ago
import os
def generate_file_list(directory, output_file):
"""
Generate a list of files in a directory in the specified format and write it to a file.
Args:
directory (str): The directory to list the files from.
output_file (str): The file to write the output to.
"""
with open(output_file, "w") as f:
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith(".md"):
# Remove the directory from the file path and replace slashes with dots
file_path = (
os.path.join(root, file)
.replace(directory + "/", "")
.replace("/", ".")
)
# Remove the file extension
file_name, _ = os.path.splitext(file)
# Write the file name and path to the output file
4 months ago
f.write(
f'- {file_name}: "swarms/utils/{file_path}"\n'
)
5 months ago
# Use the function to generate the file list
generate_file_list("docs/swarms/structs", "file_list.txt")