test
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-08-19 23:13:42 +02:00
parent 5792ba3dd6
commit 8f541f71c7
5 changed files with 243 additions and 8 deletions

View File

@ -1,10 +1,15 @@
import os
import argparse
# Define the directory containing Portainer Stack Markdown files
markdown_dir = "./docs/proxmox"
markdown_dir = "./docs/portainer-stacks"
# Define the relative path prefix used in mkdocs.yml
relative_path_prefix = "proxmox/"
relative_path_prefix = "portainer-stacks/"
# Read the existing mkdocs.yml content
with open("mkdocs.yml", "r") as f:
mkdocs_content = f.read()
# Generate navigation entries
nav_entries = []
@ -23,6 +28,20 @@ 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())
# Print the sorted navigation entries with 4 spaces
for entry in sorted_nav_entries:
print(entry)
# 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:
updated_mkdocs_content = mkdocs_content.replace(" - Portainer Stacks:\n", f" - Portainer Stacks:\n{new_section_content}\n")
with open("mkdocs.yml", "w") as f:
f.write(updated_mkdocs_content)
else:
# Print the sorted navigation entries with 4 spaces
for entry in sorted_nav_entries:
print(entry)

View File

@ -1,3 +1,5 @@
#!/usr/bin/env python3
import os
import subprocess
import argparse
@ -13,6 +15,9 @@ if args.COMMIT_MSG:
else:
commit_msg = input("Enter commit message: ")
# Add changes to the staging area
subprocess.run(["python3", "./scripts/list_new_docker_files.py", "--replace"], check=True)
# Add changes to the staging area
subprocess.run(["git", "add", "."], check=True)

View File

@ -1,4 +1,5 @@
import os
import argparse
# Define the directory containing Portainer Stack Markdown files
markdown_dir = "./docs/portainer-stacks"
@ -6,6 +7,10 @@ markdown_dir = "./docs/portainer-stacks"
# Define the relative path prefix used in mkdocs.yml
relative_path_prefix = "portainer-stacks/"
# Read the existing mkdocs.yml content
with open("mkdocs.yml", "r") as f:
mkdocs_content = f.read()
# Generate navigation entries
nav_entries = []
for filename in os.listdir(markdown_dir):
@ -23,6 +28,20 @@ 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())
# Print the sorted navigation entries with 4 spaces
for entry in sorted_nav_entries:
print(entry)
# 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:
updated_mkdocs_content = mkdocs_content.replace(" - Portainer Stacks:\n", f" - Portainer Stacks:\n{new_section_content}\n")
with open("mkdocs.yml", "w") as f:
f.write(updated_mkdocs_content)
else:
# Print the sorted navigation entries with 4 spaces
for entry in sorted_nav_entries:
print(entry)