forked from Azure/PSRule.Rules.Azure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RuleHelp.Doc.ps1
54 lines (45 loc) · 1.19 KB
/
RuleHelp.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# Generate rule help
#
Document 'RuleHelp' {
$tags = $InputObject.Tag;
$rule = $InputObject.Info;
Title $rule.Name
$annotations = [ordered]@{}
if ($Null -ne $rule.Annotations) {
$annotations += $rule.Annotations;
}
elseif ($Null -ne $tags) {
$annotations += $tags.ToHashTable();
}
if (!$annotations.Contains('online version')) {
$annotations['online version'] = "https://github.com/Azure/PSRule.Rules.Azure/blob/main/docs/rules/en/$($rule.Name).md";
}
Metadata $annotations;
Section 'SYNOPSIS' -Force {
if ($Null -ne $rule.Synopsis) {
$rule.Synopsis;
}
}
Section 'DESCRIPTION' -Force {
if ($Null -ne $rule.Description) {
$rule.Description;
}
elseif ($Null -ne $rule.Synopsis) {
$rule.Synopsis;
}
}
Section 'RECOMMENDATION' -Force {
if ($Null -ne $rule.Recommendation) {
$rule.Recommendation;
}
elseif ($Null -ne $rule.Synopsis) {
$rule.Synopsis;
}
}
Section 'NOTES' {
$rule.Notes;
}
}