From cd3fe1fe12e4b8421334b750b4d2d0d6843ee41d Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Sun, 10 Oct 2021 09:24:31 +0200 Subject: [PATCH] Update export-scripts2manuals.ps1 --- Docs/export-scripts2manuals.md | 33 ++++++++++++++++++++++++++++++ Docs/export-scripts2serenade.md | 29 ++++++++++++++++++++++++++ Docs/list-network-shares.md | 2 +- Docs/list-voices.md | 4 ++-- Docs/mute-audio.md | 2 +- Docs/play-beep.md | 4 ++-- Docs/play-happy-birthday.md | 3 ++- Docs/play-imperial-march.md | 3 ++- Docs/speak-joke.md | 5 +++-- Docs/speak-quote.md | 5 +++-- Docs/wakeup.md | 7 +++++-- Scripts/convert-ps2md.ps1 | 2 +- Scripts/export-scripts2manuals.ps1 | 33 +++++++++++++++--------------- 13 files changed, 101 insertions(+), 31 deletions(-) create mode 100644 Docs/export-scripts2manuals.md create mode 100644 Docs/export-scripts2serenade.md diff --git a/Docs/export-scripts2manuals.md b/Docs/export-scripts2manuals.md new file mode 100644 index 00000000..7f701071 --- /dev/null +++ b/Docs/export-scripts2manuals.md @@ -0,0 +1,33 @@ +## export-scripts2manuals.ps1 - Generates manuals from the scripts + +This script exports the comment based help of all scripts to the manuals. + +## Parameters +```powershell +export-scripts2manuals.ps1 [[-FilePattern] ] [] + +-FilePattern + + Required? false + Position? 1 + Default value "$PSScriptRoot/*.ps1" + Accept pipeline input? false + Accept wildcard characters? false + +[] + This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, + WarningVariable, OutBuffer, PipelineVariable, and OutVariable. +``` + +## Example +```powershell +PS>./export-scripts2manuals.ps1 +``` + +## Notes +Author: Markus Fleschutz · License: CC0 + +## Related Links +https://github.com/fleschutz/PowerShell + +*Generated by convert-ps2md.ps1 using the comment-based help of export-scripts2manuals.ps1* diff --git a/Docs/export-scripts2serenade.md b/Docs/export-scripts2serenade.md new file mode 100644 index 00000000..336f7222 --- /dev/null +++ b/Docs/export-scripts2serenade.md @@ -0,0 +1,29 @@ +## export-scripts2serenade.ps1 - ← enter overview of script here + +← enter brief description of script here + +## Parameters +```powershell +export-scripts2serenade.ps1 [] + +[] + This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, + WarningVariable, OutBuffer, PipelineVariable, and OutVariable. +``` + +## Inputs +← enter inputs here (if any, otherwise state None) + +## Example +```powershell +PS>.\template.ps1 ← enter example here (repeat this attribute for more than one example) +``` + +## Notes +Author: ← enter full name here +License: ← enter license here + +## Related Links +← enter URL here + +*Generated by convert-ps2md.ps1 using the comment-based help of export-scripts2serenade.ps1* diff --git a/Docs/list-network-shares.md b/Docs/list-network-shares.md index 2057b52f..2a5b814c 100644 --- a/Docs/list-network-shares.md +++ b/Docs/list-network-shares.md @@ -1,4 +1,4 @@ -## list-network-shares.ps1 - Lists the network shares of the local computer +## list-network-shares.ps1 - Lists all network shares of the local computer list-network-shares.ps1 diff --git a/Docs/list-voices.md b/Docs/list-voices.md index 837fbd74..5bef59cc 100644 --- a/Docs/list-voices.md +++ b/Docs/list-voices.md @@ -1,6 +1,6 @@ -## list-voices.ps1 - Lists the installed text-to-speech (TTS) voices +## list-voices.ps1 - Lists the installed text-to-speech voices -list-voices.ps1 +This script lists the installed text-to-speech voices. It requires PowerShell 2.0 or higher. ## Parameters ```powershell diff --git a/Docs/mute-audio.md b/Docs/mute-audio.md index a20d1810..0e2fff48 100644 --- a/Docs/mute-audio.md +++ b/Docs/mute-audio.md @@ -1,6 +1,6 @@ ## mute-audio.ps1 - Mutes the audio output -mute-audio.ps1 +This script mutes the default audio device immediately. ## Parameters ```powershell diff --git a/Docs/play-beep.md b/Docs/play-beep.md index 3f49072d..86b46682 100644 --- a/Docs/play-beep.md +++ b/Docs/play-beep.md @@ -1,6 +1,6 @@ -## play-beep.ps1 - Plays a short beep sound +## play-beep.ps1 - Plays a beep sound -play-beep.ps1 +This script plays a short beep sound. ## Parameters ```powershell diff --git a/Docs/play-happy-birthday.md b/Docs/play-happy-birthday.md index 3cbb837b..e8df520c 100644 --- a/Docs/play-happy-birthday.md +++ b/Docs/play-happy-birthday.md @@ -1,6 +1,6 @@ ## play-happy-birthday.ps1 - Plays the Happy Birthday song -play-happy-birthday.ps1 +This script plays the well-known Happy Birthday song. ## Parameters ```powershell @@ -14,6 +14,7 @@ play-happy-birthday.ps1 [] ## Example ```powershell PS>./play-happy-birthday +(listen and enjoy) ``` ## Notes diff --git a/Docs/play-imperial-march.md b/Docs/play-imperial-march.md index b8114007..bbb8d9e3 100644 --- a/Docs/play-imperial-march.md +++ b/Docs/play-imperial-march.md @@ -1,6 +1,6 @@ ## play-imperial-march.ps1 - Plays the Imperial March (Star Wars) -play-imperial-march.ps1 +This script plays the Imperial March used in the Star Wars film series. ## Parameters ```powershell @@ -14,6 +14,7 @@ play-imperial-march.ps1 [] ## Example ```powershell PS>./play-imperial-march +(listen and enjoy) ``` ## Notes diff --git a/Docs/speak-joke.md b/Docs/speak-joke.md index f40a2bb7..b3a43a6a 100644 --- a/Docs/speak-joke.md +++ b/Docs/speak-joke.md @@ -1,6 +1,6 @@ -## speak-joke.ps1 - Speaks a random Chuck Norris joke by text-to-speech (TTS) +## speak-joke.ps1 - Speaks a random Chuck Norris joke by text-to-speech -speak-joke.ps1 +This script selects a random joke in Data/jokes.csv and uses text-to-speech (TTS) for output. ## Parameters ```powershell @@ -14,6 +14,7 @@ speak-joke.ps1 [] ## Example ```powershell PS>./speak-joke +(listen and have fun) ``` ## Notes diff --git a/Docs/speak-quote.md b/Docs/speak-quote.md index e3a5b2c2..067264ea 100644 --- a/Docs/speak-quote.md +++ b/Docs/speak-quote.md @@ -1,6 +1,6 @@ -## speak-quote.ps1 - Speaks a random quote by text-to-speech (TTS) +## speak-quote.ps1 - Speaks a random quote by text-to-speech -speak-quote.ps1 +This script selects a random quote in Data/quotes.csv and uses text-to-speech (TTS) for output. ## Parameters ```powershell @@ -14,6 +14,7 @@ speak-quote.ps1 [] ## Example ```powershell PS>./speak-quote +(listen and learn) ``` ## Notes diff --git a/Docs/wakeup.md b/Docs/wakeup.md index db1cf53a..d307598e 100644 --- a/Docs/wakeup.md +++ b/Docs/wakeup.md @@ -1,13 +1,13 @@ ## wakeup.ps1 - Sends a magic packet to a computer to wake him up -Sends a magic packet to a computer to wake him up (requires Wake-On-LAN) -wakeup.ps1 [] [] +Sends a magic UDP packet twice to a computer to wake him up (requires Wake-On-LAN). ## Parameters ```powershell wakeup.ps1 [[-MACaddress] ] [[-IPaddress] ] [[-Port] ] [] -MACaddress + Specifies the host's MAC address (e.g. 11:22:33:44:55:66) Required? false Position? 1 @@ -16,6 +16,7 @@ wakeup.ps1 [[-MACaddress] ] [[-IPaddress] ] [[-Port] ] [< Accept wildcard characters? false -IPaddress + Specifies the host's IP address or subnet address (e.g. 255.255.255.255) Required? false Position? 2 @@ -24,6 +25,7 @@ wakeup.ps1 [[-MACaddress] ] [[-IPaddress] ] [[-Port] ] [< Accept wildcard characters? false -Port + Specifies the UDP port (9 by default) Required? false Position? 3 @@ -39,6 +41,7 @@ wakeup.ps1 [[-MACaddress] ] [[-IPaddress] ] [[-Port] ] [< ## Example ```powershell PS>./wakeup 11:22:33:44:55:66 192.168.100.100 +(PC wakes up) ``` ## Notes diff --git a/Scripts/convert-ps2md.ps1 b/Scripts/convert-ps2md.ps1 index 53e87098..0034de46 100644 --- a/Scripts/convert-ps2md.ps1 +++ b/Scripts/convert-ps2md.ps1 @@ -70,7 +70,7 @@ try { "## Parameters" "``````powershell" $Syntax = (($full.syntax | Out-String) -replace "`r`n", "`r`n").Trim() - $Syntax = (($Syntax | Out-String) -replace "/home/markus/Repos/PowerShell/Scripts/", "") + $Syntax = (($Syntax | Out-String) -replace "/home/mf/PowerShell/Scripts/", "") if ($Syntax -ne "") { "$Syntax" } diff --git a/Scripts/export-scripts2manuals.ps1 b/Scripts/export-scripts2manuals.ps1 index 79679253..4585a434 100755 --- a/Scripts/export-scripts2manuals.ps1 +++ b/Scripts/export-scripts2manuals.ps1 @@ -1,31 +1,32 @@ <# .SYNOPSIS - ← enter overview of script here + Generates manuals from the scripts .DESCRIPTION - ← enter brief description of script here -.INPUTS - ← enter inputs here (if any, otherwise state None) -.OUTPUTS - ← enter outputs here (if any, otherwise state None) + This script exports the comment based help of all scripts to the manuals. .EXAMPLE - PS> .\template.ps1 ← enter example here (repeat this attribute for more than one example) + PS> ./export-scripts2manuals.ps1 .NOTES - Author: ← enter full name here - License: ← enter license here + Author: Markus Fleschutz · License: CC0 .LINK - ← enter URL here + https://github.com/fleschutz/PowerShell #> -#requires -version 4 +#requires -version 2 -param() # ← enter script parameters here - -# ← enter functions here +param([string]$FilePattern = "$PSScriptRoot/*.ps1") try { -# ← enter instructions here + $StopWatch = [system.diagnostics.stopwatch]::startNew() - "✔️ Done." + $Scripts = Get-ChildItem "$FilePattern" + "Found $($Scripts.Count) scripts, starting export..." + + foreach ($Script in $Scripts) { + & "$PSScriptRoot/convert-ps2md" "$Script" > "$PSScriptRoot/../Docs/$($Script.BaseName).md" + } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "✔️ exported $($Scripts.Count) scripts to manuals in $Elapsed sec" exit 0 } catch { write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"