Skip to content

Commit 8968498

Browse files
🩹 [Patch]: Refactor to use $docsOutputFolder instead of $moduleDocsFolder for improved clarity in documentation generation
1 parent 8ca2d56 commit 8968498

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

β€Žscripts/helpers/Build-PSModuleDocumentation.ps1β€Ž

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,18 @@
7373
}
7474
}
7575

76-
$moduleDocsFolder = Join-Path $docsOutputFolder $ModuleName | Get-Item
77-
7876
Write-Host '::group::Build docs - Generated files'
79-
Get-ChildItem -Path $moduleDocsFolder -Recurse | Select-Object -ExpandProperty FullName
77+
Get-ChildItem -Path $docsOutputFolder -Recurse | Select-Object -ExpandProperty FullName
8078
Write-Host '::endgroup::'
8179

82-
Get-ChildItem -Path $moduleDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
80+
Get-ChildItem -Path $docsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object {
8381
$fileName = $_.Name
8482
Write-Host "::group:: - [$fileName]"
8583
Show-FileContent -Path $_
8684
}
8785

8886
Write-Host '::group::Build docs - Fix markdown code blocks'
89-
Get-ChildItem -Path $moduleDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
87+
Get-ChildItem -Path $docsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object {
9088
$content = Get-Content -Path $_.FullName
9189
$fixedOpening = $false
9290
$newContent = @()
@@ -105,7 +103,7 @@
105103
}
106104

107105
Write-Host '::group::Build docs - Fix markdown escape characters'
108-
Get-ChildItem -Path $moduleDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
106+
Get-ChildItem -Path $docsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object {
109107
$content = Get-Content -Path $_.FullName -Raw
110108
$content = $content -replace '\\`', '`'
111109
$content = $content -replace '\\\[', '['
@@ -118,24 +116,24 @@
118116

119117
Write-Host '::group::Build docs - Structure markdown files to match source files'
120118
$PublicFunctionsFolder = Join-Path $ModuleSourceFolder.FullName 'functions\public' | Get-Item
121-
Get-ChildItem -Path $moduleDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
119+
Get-ChildItem -Path $docsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object {
122120
$file = $_
123-
$relPath = [System.IO.Path]::GetRelativePath($moduleDocsFolder, $file.FullName)
121+
$relPath = [System.IO.Path]::GetRelativePath($docsOutputFolder, $file.FullName)
124122
Write-Host " - $relPath"
125123
Write-Host " Path: $file"
126124

127125
# find the source code file that matches the markdown file
128126
$scriptPath = Get-ChildItem -Path $PublicFunctionsFolder -Recurse -Force | Where-Object { $_.Name -eq ($file.BaseName + '.ps1') }
129127
Write-Host " PS1 path: $scriptPath"
130-
$docsFilePath = ($scriptPath.FullName).Replace($PublicFunctionsFolder.FullName, $moduleDocsFolder).Replace('.ps1', '.md')
128+
$docsFilePath = ($scriptPath.FullName).Replace($PublicFunctionsFolder.FullName, $docsOutputFolder).Replace('.ps1', '.md')
131129
Write-Host " MD path: $docsFilePath"
132130
$docsFolderPath = Split-Path -Path $docsFilePath -Parent
133131
$null = New-Item -Path $docsFolderPath -ItemType Directory -Force
134132
Move-Item -Path $file.FullName -Destination $docsFilePath -Force
135133
}
136134

137135
Write-Host '::group::Build docs - Fix frontmatter title'
138-
Get-ChildItem -Path $moduleDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
136+
Get-ChildItem -Path $docsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object {
139137
$content = Get-Content -Path $_.FullName -Raw
140138
# Replace 'title:' with 'ms.title:' in frontmatter only (between --- markers)
141139
$content = $content -replace '(?s)^(---.*?)title:(.*?---)', '$1ms.title:$2'
@@ -149,15 +147,15 @@
149147
Write-Host " - $relPath"
150148
Write-Host " Path: $file"
151149

152-
$docsFilePath = ($file.FullName).Replace($PublicFunctionsFolder.FullName, $moduleDocsFolder)
150+
$docsFilePath = ($file.FullName).Replace($PublicFunctionsFolder.FullName, $docsOutputFolder)
153151
Write-Host " MD path: $docsFilePath"
154152
$docsFolderPath = Split-Path -Path $docsFilePath -Parent
155153
$null = New-Item -Path $docsFolderPath -ItemType Directory -Force
156154
Move-Item -Path $file.FullName -Destination $docsFilePath -Force
157155
}
158156

159157
Write-Host '────────────────────────────────────────────────────────────────────────────────'
160-
Get-ChildItem -Path $moduleDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
158+
Get-ChildItem -Path $docsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object {
161159
$fileName = $_.Name
162160
Write-Host "::group:: - [$fileName]"
163161
Show-FileContent -Path $_

0 commit comments

Comments
Β (0)