test
Some checks are pending
continuous-integration/drone/push Build is running

This commit is contained in:
2023-08-19 23:15:21 +02:00
parent 430766a198
commit 41539354c1
2 changed files with 58 additions and 8 deletions

View File

@ -11,6 +11,11 @@ relative_path_prefix = "portainer-stacks/"
with open("mkdocs.yml", "r") as f:
mkdocs_content = f.read()
# Parse command-line arguments
parser = argparse.ArgumentParser(description="Generate navigation entries for mkdocs.yml")
parser.add_argument("--replace", action="store_true", help="Replace mkdocs.yml with new content")
args = parser.parse_args()
# Generate navigation entries
nav_entries = []
for filename in os.listdir(markdown_dir):
@ -28,17 +33,15 @@ filtered_nav_entries = [entry for entry in nav_entries if not any(name in entry
# Sort the navigation entries alphabetically (case-insensitive)
sorted_nav_entries = sorted(filtered_nav_entries, key=lambda entry: entry.lower())
# Combine all the sorted navigation entries into a single string
new_section_content = "\n".join(sorted_nav_entries)
# Parse command-line arguments
parser = argparse.ArgumentParser(description="Generate navigation entries for mkdocs.yml")
parser.add_argument("--replace", action="store_true", help="Replace mkdocs.yml with new content")
args = parser.parse_args()
# If --replace option is provided, replace the existing "Portainer Stacks" section
if args.replace:
# Combine all the sorted navigation entries into a single string
new_section_content = "\n".join(sorted_nav_entries)
# Replace the existing "Portainer Stacks" section
updated_mkdocs_content = mkdocs_content.replace(" - Portainer Stacks:\n", f" - Portainer Stacks:\n{new_section_content}\n")
# Write the updated content back to mkdocs.yml
with open("mkdocs.yml", "w") as f:
f.write(updated_mkdocs_content)
else: