@@ -86,25 +86,95 @@ Describe 'New-MarkdownHelp' {
86
86
}
87
87
}
88
88
89
- Context ' Generated markdown features' {
89
+ Context ' Generated markdown features: comment-based help ' {
90
90
function global :Test-PlatyPSFunction
91
91
{
92
+ # comment-based help template from https://technet.microsoft.com/en-us/library/hh847834.aspx
93
+
94
+ <#
95
+ . SYNOPSIS
96
+ Adds a file name extension to a supplied name.
97
+
98
+ . DESCRIPTION
99
+ Adds a file name extension to a supplied name.
100
+ Takes any strings for the file name or extension.
101
+
102
+ . PARAMETER Second
103
+ Second parameter help description
104
+
105
+ . OUTPUTS
106
+ System.String. Add-Extension returns a string with the extension or file name.
107
+
108
+ . EXAMPLE
109
+ C:\PS> Test-PlatyPSFunction "File"
110
+ File.txt
111
+
112
+ . EXAMPLE
113
+ C:\PS> Test-PlatyPSFunction "File" -First "doc"
114
+ File.doc
115
+
116
+ . LINK
117
+ http://www.fabrikam.com/extension.html
118
+
119
+ . LINK
120
+ Set-Item
121
+ #>
122
+
92
123
param (
93
124
[Switch ]$Common ,
94
- [Parameter (ParameterSetName = " First" )]
125
+ [Parameter (ParameterSetName = " First" , HelpMessage = ' First parameter help description ' )]
95
126
[string ]$First ,
96
127
[Parameter (ParameterSetName = " Second" )]
97
128
[string ]$Second
98
129
)
99
130
}
100
131
101
- It ' generate markdown with correct parameter set names' {
102
- $file = New-MarkdownHelp - Command Test-PlatyPSFunction - OutputFolder TestDrive:\testAll - Force
103
- $content = cat $file
132
+ $file = New-MarkdownHelp - Command Test-PlatyPSFunction - OutputFolder TestDrive:\testAll1 - Force
133
+ $content = cat $file
134
+
135
+ It ' generates markdown with correct parameter set names' {
104
136
($content | ? {$_ -eq ' Parameter Sets: (All)' } | measure).Count | Should Be 1
105
137
($content | ? {$_ -eq ' Parameter Sets: First' } | measure).Count | Should Be 1
106
138
($content | ? {$_ -eq ' Parameter Sets: Second' } | measure).Count | Should Be 1
107
139
}
140
+
141
+ It ' generates markdown with correct help description specified by HelpMessage attribute' {
142
+ ($content | ? {$_ -eq ' First parameter help description' } | measure).Count | Should Be 1
143
+ }
144
+
145
+ It ' generates markdown with correct help description specified by comment-based help' {
146
+ ($content | ? {$_ -eq ' Second parameter help description' } | measure).Count | Should Be 1
147
+ }
148
+
149
+ It ' generates markdown with placeholder for parameter with no description' {
150
+ ($content | ? {$_ -eq ' {{Fill Common Description}}' } | measure).Count | Should Be 1
151
+ }
152
+ }
153
+
154
+ Context ' Generated markdown features: no comment-based help' {
155
+ function global :Test-PlatyPSFunction
156
+ {
157
+ # there is a help-engine behavior difference for functions with comment-based help (or maml help)
158
+ # and no-comment based help, we test both
159
+ param (
160
+ [Switch ]$Common ,
161
+ [Parameter (ParameterSetName = " First" , HelpMessage = ' First parameter help description' )]
162
+ [string ]$First ,
163
+ [Parameter (ParameterSetName = " Second" )]
164
+ [string ]$Second
165
+ )
166
+ }
167
+
168
+ $file = New-MarkdownHelp - Command Test-PlatyPSFunction - OutputFolder TestDrive:\testAll2 - Force
169
+ $content = cat $file
170
+
171
+ It ' generates markdown with correct help description specified by HelpMessage attribute' {
172
+ ($content | ? {$_ -eq ' First parameter help description' } | measure).Count | Should Be 1
173
+ }
174
+
175
+ It ' generates markdown with placeholder for parameter with no description' {
176
+ ($content | ? {$_ -eq ' {{Fill Common Description}}' } | measure).Count | Should Be 1
177
+ }
108
178
}
109
179
110
180
Context ' Dynamic parameters' {
0 commit comments