Skip to content

Commit 5df55a7

Browse files
Refactor Build-PSModuleDocumentation.ps1 and main.ps1 to enhance output clarity; replace Write-Host with formatted output for module details and paths.
1 parent 982e70c commit 5df55a7

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

scripts/helpers/Build-PSModuleDocumentation.ps1

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,22 @@
3030
)
3131

3232
Write-Host "::group::Documenting module [$ModuleName]"
33-
Write-Host "Source path: [$ModuleSourceFolderPath]"
33+
[pscustomobject]@{
34+
ModuleName = $ModuleName
35+
ModuleSourceFolderPath = $ModuleSourceFolderPath
36+
ModulesOutputFolderPath = $ModulesOutputFolderPath
37+
DocsOutputFolderPath = $DocsOutputFolderPath
38+
} | Format-List | Out-String
39+
3440
if (-not (Test-Path -Path $ModuleSourceFolderPath)) {
3541
Write-Error "Source folder not found at [$ModuleSourceFolderPath]"
3642
exit 1
3743
}
3844
$moduleSourceFolder = Get-Item -Path $ModuleSourceFolderPath
39-
Write-Host "Module source folder: [$moduleSourceFolder]"
40-
4145
$moduleOutputFolder = New-Item -Path $ModulesOutputFolderPath -Name $ModuleName -ItemType Directory -Force
42-
Write-Host "Module output folder: [$moduleOutputFolder]"
43-
4446
$docsOutputFolder = New-Item -Path $DocsOutputFolderPath -ItemType Directory -Force
45-
Write-Host "Docs output folder: [$docsOutputFolder]"
4647

47-
Write-Host '::group::Build docs - Generate markdown help'
48+
Write-Host '::group::Build docs - Generate markdown help - Raw'
4849
Import-PSModule -Path $ModuleOutputFolder
4950
Write-Host ($ModuleName | Get-Module)
5051
$null = New-MarkdownHelp -Module $ModuleName -OutputFolder $DocsOutputFolder -Force -Verbose
@@ -97,7 +98,7 @@
9798
$docsFilePath = ($scriptPath.FullName).Replace($PublicFunctionsFolder.FullName, $DocsOutputFolder.FullName).Replace('.ps1', '.md')
9899
Write-Host "Doc file path: $docsFilePath"
99100
$docsFolderPath = Split-Path -Path $docsFilePath -Parent
100-
New-Item -Path $docsFolderPath -ItemType Directory -Force
101+
$null = New-Item -Path $docsFolderPath -ItemType Directory -Force
101102
Move-Item -Path $file.FullName -Destination $docsFilePath -Force
102103
}
103104
# Get the MD files that are in the public functions folder and move them to the same place in the docs folder
@@ -107,14 +108,13 @@
107108
$docsFilePath = ($file.FullName).Replace($PublicFunctionsFolder.FullName, $DocsOutputFolder.FullName)
108109
Write-Host "Doc file path: $docsFilePath"
109110
$docsFolderPath = Split-Path -Path $docsFilePath -Parent
110-
New-Item -Path $docsFolderPath -ItemType Directory -Force
111+
$null = New-Item -Path $docsFolderPath -ItemType Directory -Force
111112
Move-Item -Path $file.FullName -Destination $docsFilePath -Force
112113
}
113114

114115
Get-ChildItem -Path $DocsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object {
115116
$fileName = $_.Name
116-
$hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash
117-
Write-Host "::group:: - [$fileName] - [$hash]"
117+
Write-Host "::group:: - [$fileName]"
118118
Show-FileContent -Path $_
119119
}
120120
}

scripts/main.ps1

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,9 @@ Get-ChildItem -Path $path -Filter '*.ps1' -Recurse | Resolve-Path -Relative | Fo
2222
Write-Host '::group::Loading inputs'
2323
$env:GITHUB_REPOSITORY_NAME = $env:GITHUB_REPOSITORY -replace '.+/'
2424
$moduleName = [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Name) ? $env:GITHUB_REPOSITORY_NAME : $env:GITHUB_ACTION_INPUT_Name
25-
Write-Host "Module name: [$moduleName]"
26-
2725
$moduleSourceFolderPath = Resolve-Path -Path 'src' | Select-Object -ExpandProperty Path
28-
Write-Host "Module source path: [$moduleSourceFolderPath]"
29-
3026
$modulesOutputFolderPath = Join-Path -Path . -ChildPath 'outputs/module'
31-
Write-Host "Module output path: [$modulesOutputFolderPath]"
3227
$docsOutputFolderPath = Join-Path -Path . -ChildPath 'outputs/docs'
33-
Write-Host "Docs output path: [$docsOutputFolderPath]"
3428

3529
$params = @{
3630
ModuleName = $moduleName
@@ -39,4 +33,6 @@ $params = @{
3933
DocsOutputFolderPath = $docsOutputFolderPath
4034
}
4135

36+
[pscustomobject]$params | Format-List | Out-String
37+
4238
Build-PSModuleDocumentation @params

0 commit comments

Comments
 (0)