2021-10-09 09:34:26 +02:00
|
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
2021-10-10 09:46:38 +02:00
|
|
|
|
Exports all scripts as manuals
|
2021-10-09 09:34:26 +02:00
|
|
|
|
.DESCRIPTION
|
2022-01-29 12:47:46 +01:00
|
|
|
|
This PowerShell script exports the comment based help of all PowerShell scripts as manuals.
|
2021-10-09 09:34:26 +02:00
|
|
|
|
.EXAMPLE
|
2021-10-10 10:57:45 +02:00
|
|
|
|
PS> ./export-to-manuals.ps1
|
2023-05-26 12:20:18 +02:00
|
|
|
|
⏳ (1/2) Reading PowerShell scripts from /home/mf/PowerShell/Scripts/*.ps1 ...
|
|
|
|
|
⏳ (2/2) Exporting Markdown manuals to /home/mf/PowerShell/Scripts/../Docs ...
|
|
|
|
|
✔️ exported 518 Markdown manuals in 28 sec
|
2021-10-09 09:34:26 +02:00
|
|
|
|
.LINK
|
2021-10-10 09:24:31 +02:00
|
|
|
|
https://github.com/fleschutz/PowerShell
|
2022-01-29 12:47:46 +01:00
|
|
|
|
.NOTES
|
2022-09-06 21:42:04 +02:00
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
2021-10-09 09:34:26 +02:00
|
|
|
|
#>
|
|
|
|
|
|
2021-10-10 09:24:31 +02:00
|
|
|
|
#requires -version 2
|
2021-10-09 09:34:26 +02:00
|
|
|
|
|
2021-10-10 09:46:38 +02:00
|
|
|
|
param([string]$FilePattern = "$PSScriptRoot/*.ps1", [string]$TargetDir = "$PSScriptRoot/../Docs")
|
2021-10-09 09:34:26 +02:00
|
|
|
|
|
|
|
|
|
try {
|
2021-10-10 09:24:31 +02:00
|
|
|
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
|
|
|
|
|
2023-05-26 12:20:18 +02:00
|
|
|
|
"⏳ (1/2) Reading PowerShell scripts from $FilePattern ..."
|
2021-10-10 09:24:31 +02:00
|
|
|
|
$Scripts = Get-ChildItem "$FilePattern"
|
|
|
|
|
|
2023-05-26 12:20:18 +02:00
|
|
|
|
"⏳ (2/2) Exporting Markdown manuals to $TargetDir ..."
|
2021-10-10 09:24:31 +02:00
|
|
|
|
foreach ($Script in $Scripts) {
|
2021-11-15 07:38:37 +01:00
|
|
|
|
& "$PSScriptRoot/convert-ps2md.ps1" "$Script" > "$TargetDir/$($Script.BaseName).md"
|
2021-10-10 09:24:31 +02:00
|
|
|
|
}
|
2021-10-09 09:34:26 +02:00
|
|
|
|
|
2021-10-10 09:24:31 +02:00
|
|
|
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
2023-05-26 12:20:18 +02:00
|
|
|
|
"✔️ exported $($Scripts.Count) Markdown manuals in $Elapsed sec"
|
2021-10-10 09:46:38 +02:00
|
|
|
|
exit 0 # success
|
2021-10-09 09:34:26 +02:00
|
|
|
|
} catch {
|
2022-04-13 12:06:32 +02:00
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
2021-10-09 09:34:26 +02:00
|
|
|
|
exit 1
|
|
|
|
|
}
|