From 30d84583de042e2693a9f9c4a21704cdd7dee3dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Andreas=20Nilsen?= Date: Thu, 15 Aug 2024 13:02:21 +0200 Subject: [PATCH] generate readme based on template --- ReadmeTemplete.md | 20 ++++++++++++++++++++ generate-readme.ps1 | 18 +++++++----------- 2 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 ReadmeTemplete.md diff --git a/ReadmeTemplete.md b/ReadmeTemplete.md new file mode 100644 index 0000000..c3d5450 --- /dev/null +++ b/ReadmeTemplete.md @@ -0,0 +1,20 @@ +# Monkey Magic + +TamperMonkey scripts for å gjøre websider bedre. (Fuglane, Innsida osv.) + +# Scripts +{scriptlist} + +# Contribute +1. Clone the repository +2. Pull the latest changes. (Important since the README.md is generated) +```bash +git pull +``` +3. Add your script to the repository +```bash + git add myscript.user.js + git commit -m "Added my script" + git push + ``` +4. A Github Action will be automatically triggered and generate a new README.md file. \ No newline at end of file diff --git a/generate-readme.ps1 b/generate-readme.ps1 index a1e98d0..e5225b4 100644 --- a/generate-readme.ps1 +++ b/generate-readme.ps1 @@ -1,10 +1,3 @@ -"# Monkey Magic" -"" -"TamperMonkey scripts for å gjøre websider bedre. (Fuglane, Innsida osv.)" -"" -"# Scripts" -"" - # Define the directory containing the user scripts $UserScripts = "." @@ -16,6 +9,9 @@ $regEx = [regex]'\/\/\s+@(\w+)\s+(.+)' # Initialize an array to hold the table rows $tableRows = @() +$tableRows = "| Filename | Name | Description |" +$tableRows += "|----------|------|-------------|" + # Loop through each file foreach ($file in $userJsFiles) { # Read the file content @@ -52,7 +48,7 @@ foreach ($file in $userJsFiles) { $tableRows += "| [$($file.Name)](https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/$($file.Name)) | $name | $description |" } -# Output the markdown table -Write-Output "| Filename | Name | Description |" -Write-Output "|----------|------|-------------|" -$tableRows | ForEach-Object { Write-Output $_ } \ No newline at end of file +#$tableRows | ForEach-Object { Write-Output $_ } + +$template = Get-Content .\ReadmeTemplete.md +$template -replace '{scriptlist}', $tableRows \ No newline at end of file