Refactor baseline doc generate task (#950)
This commit is contained in:
Родитель
320bc03d07
Коммит
194ba27899
|
@ -1,9 +1,16 @@
|
|||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
Export-PSDocumentConvention 'NameBaseline' -Process {
|
||||
$PSDocs.Document.InstanceName = $PSDocs.TargetObject.Name;
|
||||
}
|
||||
|
||||
Document 'baseline' {
|
||||
$baselineName = $InputObject.Name;
|
||||
$obsolete = $InputObject.metadata.annotations.obsolete -eq $True;
|
||||
$baselineName = $PSDocs.TargetObject.Name;
|
||||
$obsolete = $PSDocs.TargetObject.metadata.annotations.obsolete -eq $True;
|
||||
|
||||
Write-Verbose -Message "[Baseline] -- Processing baseline: $baselineName";
|
||||
Write-Verbose -Message "[Baseline] -- Baseline is obsolete: $obsolete";
|
||||
|
||||
Title $baselineName;
|
||||
|
||||
|
@ -11,16 +18,16 @@ Document 'baseline' {
|
|||
'Obsolete' | BlockQuote
|
||||
}
|
||||
|
||||
Import-Module ./out/modules/PSRule.Rules.Azure;
|
||||
$rules = @(Get-PSRule -Module PSRule.Rules.Azure -Baseline $baselineName -WarningAction SilentlyContinue);
|
||||
$rules = $PSDocs.TargetObject.Rules | Sort-Object -Property RuleName;
|
||||
$ruleCount = $rules.Length;
|
||||
|
||||
$InputObject.Synopsis;
|
||||
$PSDocs.TargetObject.Synopsis;
|
||||
|
||||
Section 'Rules' {
|
||||
"The following rules are included within ``$baselineName``. This baseline includes a total of $ruleCount rules."
|
||||
Write-Verbose -Message "[Baseline] -- Found $ruleCount rules.";
|
||||
|
||||
$rules | Sort-Object -Property RuleName | Table -Property @{ Name = 'Name'; Expression = {
|
||||
Section 'Rules' -If { $ruleCount -gt 0 } {
|
||||
"The following rules are included within ``$baselineName``. This baseline includes a total of $ruleCount rules.";
|
||||
$rules | Table -Property @{ Name = 'Name'; Expression = {
|
||||
"[$($_.RuleName)](../rules/$($_.RuleName).md)"
|
||||
}}, Synopsis, @{ Name = 'Severity'; Expression = {
|
||||
$_.Info.Annotations.severity
|
||||
|
|
|
@ -407,9 +407,15 @@ task BuildRuleDocs Build, PSRule, PSDocs, {
|
|||
task BuildBaselineDocs Build, PSRule, PSDocs, {
|
||||
Import-Module (Join-Path -Path $PWD -ChildPath out/modules/PSRule.Rules.Azure) -Force;
|
||||
$baselines = Get-PSRuleBaseline -Module PSRule.Rules.Azure -WarningAction SilentlyContinue;
|
||||
$Null = $baselines | ForEach-Object {
|
||||
$_ | Invoke-PSDocument -Name baseline -InstanceName $_.Name -OutputPath ./docs/en/baselines/ -Path ./BaselineToc.Doc.ps1;
|
||||
}
|
||||
$baselines | ForEach-Object {
|
||||
$baselineDoc = [PSCustomObject]@{
|
||||
Name = $_.Name
|
||||
Metadata = $_.Metadata
|
||||
Synopsis = $_.Synopsis
|
||||
Rules = @(Get-PSRule -Module PSRule.Rules.Azure -Baseline $_.Name -WarningAction SilentlyContinue)
|
||||
}
|
||||
$baselineDoc;
|
||||
} | Invoke-PSDocument -Name baseline -OutputPath ./docs/en/baselines/ -Path ./BaselineToc.Doc.ps1 -Convention 'NameBaseline';
|
||||
}
|
||||
|
||||
# Synopsis: Build help
|
||||
|
|
Загрузка…
Ссылка в новой задаче