PowerShell/scripts/export-to-manuals.ps1

39 lines
1.2 KiB
PowerShell
Raw Normal View History

2024-10-01 13:37:53 +02:00
<#
.SYNOPSIS
Exports all scripts as manuals
.DESCRIPTION
This PowerShell script exports the comment-based help of all PowerShell scripts as manuals.
.EXAMPLE
PS> ./export-to-manuals.ps1
2023-10-31 11:32:46 +01:00
(1/2) Reading PowerShell scripts from /home/mf/PowerShell/scripts/*.ps1 ...
2023-10-31 11:05:01 +01:00
(2/2) Exporting Markdown manuals to /home/mf/PowerShell/docs ...
2024-10-01 13:37:53 +02:00
Exported 518 Markdown manuals in 28 sec.
.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-10 09:24:31 +02:00
#requires -version 2
param([string]$filePattern = "$PSScriptRoot/*.ps1", [string]$targetDir = "$PSScriptRoot/../docs")
try {
$stopWatch = [system.diagnostics.stopwatch]::startNew()
2021-10-10 09:24:31 +02:00
"⏳ (1/2) Reading PowerShell scripts from $filePattern ..."
$scripts = Get-ChildItem "$filePattern"
2021-10-10 09:24:31 +02:00
"⏳ (2/2) Exporting Markdown manuals to $targetDir ..."
foreach ($script in $scripts) {
& "$PSScriptRoot/convert-ps2md.ps1" "$script" > "$targetDir/$($script.BaseName).md"
2021-10-10 09:24:31 +02:00
}
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
2024-10-01 13:37:53 +02:00
"✅ Exported $($scripts.Count) Markdown manuals in $elapsed sec."
exit 0 # success
} catch {
2022-04-13 12:06:32 +02:00
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}