Skip to content

Commit

Permalink
Get-CompositeSchemaObject now handles missing comment-based help (min…
Browse files Browse the repository at this point in the history
…or bump) (#117)
  • Loading branch information
raandree authored May 9, 2022
1 parent 0528d4f commit d61f552
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 121 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix statement so function passed HQRM tests.
- Tasks now uses `Set-SamplerTaskVariable` from the module Sampler to set
the common build task variables.
- Updated task parameters `ProjectName` and `SourcePath` to reflect Sampler

### Fixed

- Common task variables have not been set, fixed that.
- `Get-CompositeSchemaObject` threw an error when a composite did not have
comment based help, now returns `$null`.

## [0.10.3] - 2022-01-26

Expand Down
25 changes: 16 additions & 9 deletions source/Private/Get-CompositeSchemaObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ function Get-CompositeSchemaObject
throw $script:localizedData.MacOSNotSupportedError
}

$manifestFileName = $FileName -replace '.schema.psm1','.psd1'
$compositeName = [System.IO.Path]::GetFileName($FileName) -replace '.schema.psm1',''
$manifestFileName = $FileName -replace '.schema.psm1', '.psd1'
$compositeName = [System.IO.Path]::GetFileName($FileName) -replace '.schema.psm1', ''
$manifestData = Import-LocalizedData `
-BaseDirectory ([System.IO.Path]::GetDirectoryName($manifestFileName)) `
-FileName ([System.IO.Path]::GetFileName($manifestFileName))
Expand All @@ -57,15 +57,22 @@ function Get-CompositeSchemaObject
{
$parameterName = $parameter.Name.VariablePath.ToString()

# The parameter name in comment-based help is returned as upper so need to match correctly.
$parameterDescription = $commentBasedHelp.Parameters[$parameterName.ToUpper()] -replace '\r?\n+$'
if ($commentBasedHelp)
{
# The parameter name in comment-based help is returned as upper so need to match correctly.
$parameterDescription = $commentBasedHelp.Parameters[$parameterName.ToUpper()] -replace '\r?\n+$'
}
else
{
$parameterDescription = ''
}

@{
Name = $parameterName
State = (Get-CompositeResourceParameterState -Ast $parameter)
Type = $parameter.StaticType.FullName
ValidateSet = (Get-CompositeResourceParameterValidateSet -Ast $parameter)
Description = $parameterDescription
Name = $parameterName
State = (Get-CompositeResourceParameterState -Ast $parameter)
Type = $parameter.StaticType.FullName
ValidateSet = (Get-CompositeResourceParameterValidateSet -Ast $parameter)
Description = $parameterDescription
}
}

Expand Down
15 changes: 6 additions & 9 deletions source/tasks/Generate_Conceptual_Help.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
For instance, if VersionedOutputDirectory is $true, the built module's ModuleBase would be: `output/MyModuleName/2.0.1/`
.PARAMETER ProjectName
The project name. Defaults to the BaseName of the module manifest it finds
in either the folder 'source', 'src, or a folder with the same name as
the module.
The project name. Defaults to the empty string.
.PARAMETER SourcePath
The path to the source folder name. Defaults to the same path where the
module manifest is found.
The path to the source folder name. Defaults to the empty string.
.PARAMETER MarkdownCodeRegularExpression
An array with regular expressions that will be used to remove markdown code
Expand Down Expand Up @@ -65,11 +62,11 @@ param

[Parameter()]
[System.String]
$ProjectName = (property ProjectName $(Get-SamplerProjectName -BuildRoot $BuildRoot)),
$ProjectName = (property ProjectName ''),

[Parameter()]
[System.String]
$SourcePath = (property SourcePath $(Get-SamplerSourcePath -BuildRoot $BuildRoot)),
$SourcePath = (property SourcePath ''),

[Parameter()]
[System.String]
Expand All @@ -82,7 +79,7 @@ param

# Synopsis: This task generates conceptual help for DSC resources.
task Generate_Conceptual_Help {
# Get the values for task variables
# Get the vales for task variables, see https://github.com/gaelcolas/Sampler#task-variables.
. Set-SamplerTaskVariable

$configParameterName = 'MarkdownCodeRegularExpression'
Expand All @@ -108,7 +105,7 @@ task Generate_Conceptual_Help {
"`tMarkdownCodeRegularExpression = RegEx: {0}" -f ($MarkdownCodeRegularExpression -join ' | RegEx: ')
}

Write-Build Magenta "Generating conceptual help for all DSC resources based on source."
Write-Build Magenta 'Generating conceptual help for all DSC resources based on source.'

$newDscResourcePowerShellHelpParameters = @{
ModulePath = $SourcePath
Expand Down
13 changes: 5 additions & 8 deletions source/tasks/Generate_Wiki_Content.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
For instance, if VersionedOutputDirectory is $true, the built module's ModuleBase would be: `output/MyModuleName/2.0.1/`
.PARAMETER ProjectName
The project name. Defaults to the BaseName of the module manifest it finds
in either the folder 'source', 'src, or a folder with the same name as
the module.
The project name. Defaults to the empty string.
.PARAMETER SourcePath
The path to the source folder name. Defaults to the same path where the
module manifest is found.
The path to the source folder name. Defaults to the empty string.
.PARAMETER WikiSourceFolderName
The name of the folder that contains the source markdown files (e.g. 'Home.md')
Expand Down Expand Up @@ -68,11 +65,11 @@ param

[Parameter()]
[System.String]
$ProjectName = (property ProjectName $(Get-SamplerProjectName -BuildRoot $BuildRoot)),
$ProjectName = (property ProjectName ''),

[Parameter()]
[System.String]
$SourcePath = (property SourcePath $(Get-SamplerSourcePath -BuildRoot $BuildRoot)),
$SourcePath = (property SourcePath ''),

[Parameter()]
[System.String]
Expand All @@ -85,7 +82,7 @@ param

# Synopsis: This task generates wiki documentation for the DSC resources.
task Generate_Wiki_Content {
# Get the values for task variables
# Get the vales for task variables, see https://github.com/gaelcolas/Sampler#task-variables.
. Set-SamplerTaskVariable

$wikiOutputPath = Join-Path -Path $OutputDirectory -ChildPath 'WikiContent'
Expand Down
17 changes: 7 additions & 10 deletions source/tasks/Publish_GitHub_Wiki_Content.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
For instance, if VersionedOutputDirectory is $true, the built module's ModuleBase would be: `output/MyModuleName/2.0.1/`
.PARAMETER ProjectName
The project name. Defaults to the BaseName of the module manifest it finds
in either the folder 'source', 'src, or a folder with the same name as
the module.
The project name. Defaults to the empty string.
.PARAMETER SourcePath
The path to the source folder name. Defaults to the same path where the
module manifest is found.
The path to the source folder name. Defaults to the empty string.
.PARAMETER WikiContentFolderName
The name of the folder that contain the content to publish to the wiki.
Expand Down Expand Up @@ -71,11 +68,11 @@ param

[Parameter()]
[System.String]
$ProjectName = (property ProjectName $(Get-SamplerProjectName -BuildRoot $BuildRoot)),
$ProjectName = (property ProjectName ''),

[Parameter()]
[System.String]
$SourcePath = (property SourcePath $(Get-SamplerSourcePath -BuildRoot $BuildRoot)),
$SourcePath = (property SourcePath ''),

[Parameter()]
[System.String]
Expand Down Expand Up @@ -111,13 +108,13 @@ task Publish_GitHub_Wiki_Content {
# Only show debug information if Debug was set to 'true' in build configuration.
if ($debugTask)
{
"Running task with debug information."
'Running task with debug information.'

$local:VerbosePreference = 'Continue'
$local:DebugPreference = 'Continue'
}

# Get the values for task variables
# Get the vales for task variables, see https://github.com/gaelcolas/Sampler#task-variables.
. Set-SamplerTaskVariable

# If variables are not set then update variables from the property values in the build.yaml.
Expand Down Expand Up @@ -183,7 +180,7 @@ task Publish_GitHub_Wiki_Content {
$publishWikiContentParameters.Debug = $true
}

Write-Build Magenta "Publishing Wiki content."
Write-Build Magenta 'Publishing Wiki content.'

Publish-WikiContent @publishWikiContentParameters
}
Expand Down
Loading

0 comments on commit d61f552

Please sign in to comment.