Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Make test reference docs more friendly
Browse files Browse the repository at this point in the history
+ Test reference docs used the test-file name for their first level header and file name
in documentation. This is problematic because it assumes that the test file name was
written to be easily and cleanly human-parsable. That is not the case for numerous
tests. Updating the psake task for the reference docs makes them easier to discover
and easier to understand.
  • Loading branch information
michaeltlombardi committed Jun 16, 2017
1 parent 8dc80a3 commit a69dc79
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions psake.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,17 @@ Task Compile -depends Clean {
Write-Host -ForegroundColor DarkMagenta "Generating test reference documents..."
ForEach ($Test in (Get-ChildItem -Path $ProjectRoot/Vester/Tests -Recurse -File)) {
[string]$Category = $(Split-Path -Path (Split-Path -Path $Test.FullName -Parent) -Leaf)
$DocumentPath = "$CompilingFolder/reference/tests/$Category/$($Test.BaseName.split('.')[0]).md"
. $Test.FullName
$DocumentPath = "$CompilingFolder/reference/tests/$Category/$($Title.replace(' ','-').replace(':','')).md"
If (!(Test-Path -Path (Split-Path $DocumentPath -Parent))) {
$null = New-Item -Path "$(Split-Path $DocumentPath -Parent)/readme.md" -Value "# $Category Tests`r`nSee the following chapters for more information." -Force
}
If (!(Test-Path -Path $DocumentPath)) {
$null = New-Item -Path $DocumentPath -Value "# $((Split-Path $DocumentPath -Leaf).split('.')[0]) Tests`r`n" -Force
$null = New-Item -Path $DocumentPath -Value "# $Title`r`n$Description" -Force
}
. $Test.FullName
@(
"`r`n## $Title`r`n$Description"
"`r`n### Discovery Code`r`n" + '```powershell' + "$Actual" + '```'
"`r`n### Remediation Code`r`n" + '```powershell' + "$Fix" + '```'
"`r`n## Discovery Code`r`n" + '```powershell' + "$Actual" + '```'
"`r`n## Remediation Code`r`n" + '```powershell' + "$Fix" + '```'
) | Add-Content -Path $DocumentPath
}
Push-Location -Path $CompilingFolder
Expand Down

0 comments on commit a69dc79

Please sign in to comment.