Skip to content

Commit 2cb6082

Browse files
🩹 [Patch]: Refactor Build-PSModuleDocumentation to enhance command processing and error handling during markdown generation
1 parent 7e58bbe commit 2cb6082

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

‎scripts/helpers/Build-PSModuleDocumentation.ps1‎

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,31 @@
4747

4848
Write-Host '::group::Build docs - Generate markdown help - Raw'
4949
Install-PSModule -Path $ModuleOutputFolder
50-
Import-Module -Name $ModuleName -Force -Verbose
51-
$moduleInfo = Get-Module $ModuleName
52-
Write-Host $moduleInfo
53-
$DebugPreference = 'Continue'
54-
$VerbosePreference = 'Continue'
55-
New-MarkdownCommandHelp -ModuleInfo $moduleInfo -OutputFolder $DocsOutputFolder -Force -Verbose -Debug
56-
$DebugPreference = 'SilentlyContinue'
57-
$VerbosePreference = 'SilentlyContinue'
50+
$moduleInfo = Import-Module -Name $ModuleName -Force -PassThru
51+
52+
# Get all exported commands from the module
53+
$commands = $moduleInfo.ExportedCommands.Values | Where-Object { $_.CommandType -ne 'Alias' }
54+
55+
Write-Host "Found $($commands.Count) commands to process"
56+
57+
foreach ($command in $commands) {
58+
try {
59+
Write-Host "$($command.Name)" -NoNewline
60+
$params = @{
61+
CommandInfo = $command
62+
OutputFolder = $DocsOutputFolder
63+
Encoding = 'utf8'
64+
ProgressAction = 'SilentlyContinue'
65+
ErrorAction = 'Stop'
66+
Force = $true
67+
}
68+
$null = New-MarkdownCommandHelp @params
69+
Write-Host ' - ✓' -ForegroundColor Green
70+
} catch {
71+
Write-Host ' - ✗' -ForegroundColor Red
72+
}
73+
}
74+
5875
Get-ChildItem -Path $DocsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object {
5976
$fileName = $_.Name
6077
Write-Host "::group:: - [$fileName]"

0 commit comments

Comments
 (0)