forked from Azure/PSRule.Rules.Azure
-
Notifications
You must be signed in to change notification settings - Fork 1
/
BaselineToc.Doc.ps1
36 lines (27 loc) · 1.18 KB
/
BaselineToc.Doc.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Export-PSDocumentConvention 'NameBaseline' -Process {
$PSDocs.Document.InstanceName = $PSDocs.TargetObject.Name;
}
Document 'baseline' {
$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;
if ($obsolete) {
'<!-- OBSOLETE -->'
}
$rules = $PSDocs.TargetObject.Rules | Sort-Object -Property RuleName;
$ruleCount = $rules.Length;
$PSDocs.TargetObject.Synopsis;
Write-Verbose -Message "[Baseline] -- Found $ruleCount rules.";
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
}}
}
}