Skip to content

Commit 4eb8435

Browse files
🪲 [Fix]: A linting issue with fence on markdown (#28)
## Description - Fix a linting issue with fence on markdown files, after generating with platyPS. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [x] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent ba96b7c commit 4eb8435

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

scripts/helpers/Build/Build-PSModuleDocumentation.ps1

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,43 @@ function Build-PSModuleDocumentation {
3030
Import-PSModule -Path $ModuleOutputFolder -ModuleName $moduleName
3131

3232
Start-LogGroup 'Build documentation'
33-
New-MarkdownHelp -Module $moduleName -OutputFolder $DocsOutputFolder -Force -Verbose
33+
$null = New-MarkdownHelp -Module $moduleName -OutputFolder $DocsOutputFolder -Force -Verbose
3434
Stop-LogGroup
3535

36-
Start-LogGroup 'Build documentation - Result'
36+
Start-LogGroup 'Build documentation - Fix fence'
3737
Get-ChildItem -Path $DocsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object {
38-
Write-Verbose "[$_] - [$(Get-FileHash -Path $_.FullName -Algorithm SHA256)]"
38+
$content = Get-Content -Path $_.FullName
39+
$fixedOpening = $false
40+
$newContent = @()
41+
foreach ($line in $content) {
42+
if ($line -match '^```$' -and -not $fixedOpening) {
43+
$line = $line -replace '^```$', '```powershell'
44+
$fixedOpening = $true
45+
} elseif ($line -match '^```.+$') {
46+
$fixedOpening = $true
47+
} elseif ($line -match '^```$'){
48+
$fixedOpening = $false
49+
}
50+
$newContent += $line
51+
}
52+
$newContent | Set-Content -Path $_.FullName
3953
}
4054
Stop-LogGroup
55+
56+
Start-LogGroup 'Build documentation - Result'
57+
Write-Verbose (Get-ChildItem -Path $DocsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object {
58+
@{
59+
Name = $_.FullName
60+
Hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash
61+
}
62+
} | Format-Table -AutoSize | Out-String)
63+
Stop-LogGroup
64+
65+
Get-ChildItem -Path $DocsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object {
66+
$fileName = $_.Name
67+
$hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash
68+
Start-LogGroup "- File: [$fileName] - [$hash]"
69+
Show-FileContent -Path $_
70+
Stop-LogGroup
71+
}
4172
}

0 commit comments

Comments
 (0)