@@ -24,44 +24,43 @@ $moduleName = $ExecutionContext.SessionState.Module
24
24
$script :localizedData = Get-LocalizedData - ModuleName $moduleName - ModuleRoot $PSScriptRoot
25
25
26
26
<#
27
- . SYNOPSIS
28
- New-DscResourcePowerShellHelp generates PowerShell compatible help files for a DSC
29
- resource module
30
-
31
- . DESCRIPTION
32
- The New-DscResourcePowerShellHelp cmdlet will review all of the MOF based resources
33
- in a specified module directory and will inject PowerShell help files for each resource.
34
- These help files include details on the property types for each resource, as well as a text
35
- description and examples where they exist.
27
+ . SYNOPSIS
28
+ New-DscResourcePowerShellHelp generates PowerShell compatible help files for a DSC
29
+ resource module
36
30
37
- The help files are output to the OutputPath directory if specified, or if not, they are
38
- output to the releveant resource's 'en-US' directory.
31
+ . DESCRIPTION
32
+ The New-DscResourcePowerShellHelp cmdlet will review all of the MOF based resources
33
+ in a specified module directory and will inject PowerShell help files for each resource.
34
+ These help files include details on the property types for each resource, as well as a text
35
+ description and examples where they exist.
39
36
40
- A README.md with a text description must exist in the resource's subdirectory for the
41
- help file to be generated .
37
+ The help files are output to the OutputPath directory if specified, or if not, they are
38
+ output to the releveant resource's 'en-US' directory .
42
39
43
- These help files can then be read by passing the name of the resource as a parameter to Get-Help.
40
+ A README.md with a text description must exist in the resource's subdirectory for the
41
+ help file to be generated.
44
42
45
- . PARAMETER ModulePath
46
- The path to the root of the DSC resource module (where the PSD1 file is found, not the folder for
47
- each individual DSC resource)
43
+ These help files can then be read by passing the name of the resource as a parameter to Get-Help.
48
44
49
- . EXAMPLE
50
- This example shows how to generate help for a specific module
45
+ . PARAMETER ModulePath
46
+ The path to the root of the DSC resource module (where the PSD1 file is found, not the folder for
47
+ each individual DSC resource)
51
48
52
- New-DscResourcePowerShellHelp -ModulePath C:\repos\SharePointdsc
49
+ . EXAMPLE
50
+ This example shows how to generate help for a specific module
53
51
52
+ New-DscResourcePowerShellHelp -ModulePath C:\repos\SharePointdsc
54
53
#>
55
54
function New-DscResourcePowerShellHelp
56
55
{
57
56
[CmdletBinding ()]
58
57
param
59
58
(
60
- [parameter (Mandatory = $true )]
59
+ [Parameter (Mandatory = $true )]
61
60
[System.String ]
62
61
$ModulePath ,
63
62
64
- [parameter ()]
63
+ [Parameter ()]
65
64
[System.String ]
66
65
$OutputPath
67
66
)
@@ -70,14 +69,17 @@ function New-DscResourcePowerShellHelp
70
69
71
70
$mofSearchPath = (Join-Path - Path $ModulePath - ChildPath ' \**\*.schema.mof' )
72
71
$mofSchemas = Get-ChildItem - Path $mofSearchPath - Recurse
72
+
73
73
Write-Verbose - Message ($script :localizedData.FoundMofFilesMessage -f $mofSchemas.Count , $ModulePath )
74
+
74
75
$mofSchemas | ForEach-Object {
75
76
$mofFileObject = $_
76
77
77
78
$result = (Get-MofSchemaObject - FileName $_.FullName ) | Where-Object - FilterScript {
78
79
($_.ClassName -eq $mofFileObject.Name.Replace (' .schema.mof' , ' ' )) `
79
80
-and ($null -ne $_.FriendlyName )
80
81
}
82
+
81
83
$descriptionPath = Join-Path - Path $mofFileObject.DirectoryName - ChildPath ' readme.md'
82
84
83
85
if (Test-Path - Path $descriptionPath )
@@ -89,8 +91,11 @@ function New-DscResourcePowerShellHelp
89
91
$output += [Environment ]::NewLine + [Environment ]::NewLine
90
92
91
93
$descriptionContent = Get-Content - Path $descriptionPath - Raw
92
- $descriptionContent = $descriptionContent -replace " \n" , " `n "
93
- $descriptionContent = $descriptionContent -replace " # Description\r\n " , " .DESCRIPTION"
94
+
95
+ $descriptionContent = $descriptionContent -replace ' \n' , " `n "
96
+ $descriptionContent = $descriptionContent -replace ' # Description\r\n ' , ' .DESCRIPTION'
97
+ $descriptionContent = $descriptionContent -replace ' \r\n\s{4}\r\n' , " `n`n "
98
+ $descriptionContent = $descriptionContent -replace ' \s{4}$' , ' '
94
99
95
100
$output += $descriptionContent
96
101
$output += [Environment ]::NewLine
@@ -150,8 +155,10 @@ function New-DscResourcePowerShellHelp
150
155
{
151
156
$savePath = Join-Path - Path $mofFileObject.DirectoryName - ChildPath ' en-US' | Join-Path - ChildPath $outputFileName
152
157
}
158
+
153
159
Write-Verbose - Message ($script :localizedData.OutputHelpDocumentMessage -f $savePath )
154
- $output | Out-File - FilePath $savePath - Encoding utf8 - Force
160
+
161
+ $output | Out-File - FilePath $savePath - Encoding ascii - Force
155
162
}
156
163
else
157
164
{
0 commit comments