Skip to content

Commit e81ffb0

Browse files
Merge pull request #3 from techthoughts2/Enhancements
Enhancements
2 parents 724a682 + 463e4be commit e81ffb0

File tree

10 files changed

+162
-11
lines changed

10 files changed

+162
-11
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
],
2222
"cSpell.words": [
2323
"jakemorrison",
24+
"Pscx",
2425
"shortcode"
2526
]
2627
}

docs/Add-EmojiToText.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Accept wildcard characters: False
8989
```
9090
9191
### CommonParameters
92-
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
92+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction.
9393
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
9494
9595
## INPUTS
@@ -110,4 +110,3 @@ This function uses the Public data set from the Unicode Data Files and adheres t
110110
[https://pwshEmojiExplorer.readthedocs.io/en/latest/Add-EmojiToText/](https://pwshEmojiExplorer.readthedocs.io/en/latest/Add-EmojiToText/)
111111
112112
[https://www.unicode.org/license.txt](https://www.unicode.org/license.txt)
113-

docs/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.2.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.8.4]
9+
10+
- Module Changes
11+
- Addressed bug where `Expand-XMLDataSet` can fail if user has `Expand-Archive` from `Pscx` module, not from `Microsoft.PowerShell.Archive`
12+
- Build Updates
13+
- Added `MarkdownRepair.ps1` and added Markdown repair logic to InvokeBuild script. This is to account for an issue in PowerShell `7.4.0`+ where a new parameter was introduced that platyPS can not handle during help creation. Ref: [platyPS issue]([text](https://github.com/PowerShell/platyPS/issues/595)).
14+
815
## [0.8.2]
916

1017
- Module Changes

docs/Get-AllEmoji.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Accept wildcard characters: False
5656
```
5757
5858
### CommonParameters
59-
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
59+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction.
6060
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
6161
6262
## INPUTS
@@ -80,4 +80,3 @@ This function uses the Public data set from the Unicode Data Files and adheres t
8080
[https://pwshEmojiExplorer.readthedocs.io/en/latest/Get-AllEmoji/](https://pwshEmojiExplorer.readthedocs.io/en/latest/Get-AllEmoji/)
8181
8282
[https://www.unicode.org/license.txt](https://www.unicode.org/license.txt)
83-

docs/Get-Emoji.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ Accept wildcard characters: False
277277
```
278278
279279
### CommonParameters
280-
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
280+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction.
281281
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
282282
283283
## INPUTS
@@ -301,4 +301,3 @@ This function uses the Public data set from the Unicode Data Files and adheres t
301301
[https://pwshEmojiExplorer.readthedocs.io/en/latest/Get-Emoji/](https://pwshEmojiExplorer.readthedocs.io/en/latest/Get-Emoji/)
302302
303303
[https://www.unicode.org/license.txt](https://www.unicode.org/license.txt)
304-

docs/pwshEmojiExplorer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Module Name: pwshEmojiExplorer
33
Module Guid: 6e4813c7-6f30-42e8-adc4-b3d9b46bce9a
44
Download Help Link: NA
5-
Help Version: 0.8.2
5+
Help Version: 0.8.4
66
Locale: en-US
77
---
88

src/MarkdownRepair.ps1

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<#
2+
.SYNOPSIS
3+
Repair PlatyPS generated markdown files.
4+
.NOTES
5+
This file is temporarily required to handle platyPS help generation.
6+
https://github.com/PowerShell/platyPS/issues/595
7+
This is a result of a breaking change introduced in PowerShell 7.4.0:
8+
https://learn.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-74?view=powershell-7.4
9+
Breaking Changes: Added the ProgressAction parameter to the Common Parameters
10+
modified from source: https://github.com/PowerShell/platyPS/issues/595#issuecomment-1820971702
11+
#>
12+
13+
function Remove-CommonParameterFromMarkdown {
14+
<#
15+
.SYNOPSIS
16+
Remove a PlatyPS generated parameter block.
17+
.DESCRIPTION
18+
Removes parameter block for the provided parameter name from the markdown file provided.
19+
#>
20+
param(
21+
[Parameter(Mandatory)]
22+
[string[]]
23+
$Path,
24+
25+
[Parameter(Mandatory = $false)]
26+
[string[]]
27+
$ParameterName = @('ProgressAction')
28+
)
29+
$ErrorActionPreference = 'Stop'
30+
foreach ($p in $Path) {
31+
$content = (Get-Content -Path $p -Raw).TrimEnd()
32+
$updateFile = $false
33+
foreach ($param in $ParameterName) {
34+
if (-not ($Param.StartsWith('-'))) {
35+
$param = "-$($param)"
36+
}
37+
# Remove the parameter block
38+
$pattern = "(?m)^### $param\r?\n[\S\s]*?(?=#{2,3}?)"
39+
$newContent = $content -replace $pattern, ''
40+
# Remove the parameter from the syntax block
41+
$pattern = " \[$param\s?.*?]"
42+
$newContent = $newContent -replace $pattern, ''
43+
if ($null -ne (Compare-Object -ReferenceObject $content -DifferenceObject $newContent)) {
44+
Write-Verbose "Added $param to $p"
45+
# Update file content
46+
$content = $newContent
47+
$updateFile = $true
48+
}
49+
}
50+
# Save file if content has changed
51+
if ($updateFile) {
52+
$newContent | Out-File -Encoding utf8 -FilePath $p
53+
Write-Verbose "Updated file: $p"
54+
}
55+
}
56+
return
57+
}
58+
59+
function Add-MissingCommonParameterToMarkdown {
60+
param(
61+
[Parameter(Mandatory)]
62+
[string[]]
63+
$Path,
64+
65+
[Parameter(Mandatory = $false)]
66+
[string[]]
67+
$ParameterName = @('ProgressAction')
68+
)
69+
$ErrorActionPreference = 'Stop'
70+
foreach ($p in $Path) {
71+
$content = (Get-Content -Path $p -Raw).TrimEnd()
72+
$updateFile = $false
73+
foreach ($NewParameter in $ParameterName) {
74+
if (-not ($NewParameter.StartsWith('-'))) {
75+
$NewParameter = "-$($NewParameter)"
76+
}
77+
$pattern = '(?m)^This cmdlet supports the common parameters:(.+?)\.'
78+
$replacement = {
79+
$Params = $_.Groups[1].Captures[0].ToString() -split ' '
80+
$CommonParameters = @()
81+
foreach ($CommonParameter in $Params) {
82+
if ($CommonParameter.StartsWith('-')) {
83+
if ($CommonParameter.EndsWith(',')) {
84+
$CleanParam = $CommonParameter.Substring(0, $CommonParameter.Length - 1)
85+
}
86+
elseif ($p.EndsWith('.')) {
87+
$CleanParam = $CommonParameter.Substring(0, $CommonParameter.Length - 1)
88+
}
89+
else {
90+
$CleanParam = $CommonParameter
91+
}
92+
$CommonParameters += $CleanParam
93+
}
94+
}
95+
if ($NewParameter -notin $CommonParameters) {
96+
$CommonParameters += $NewParameter
97+
}
98+
$CommonParameters[-1] = "and $($CommonParameters[-1]). "
99+
return "This cmdlet supports the common parameters: " + (($CommonParameters | Sort-Object) -join ', ')
100+
}
101+
$newContent = $content -replace $pattern, $replacement
102+
if ($null -ne (Compare-Object -ReferenceObject $content -DifferenceObject $newContent)) {
103+
Write-Verbose "Added $NewParameter to $p"
104+
$updateFile = $true
105+
$content = $newContent
106+
}
107+
}
108+
# Save file if content has changed
109+
if ($updateFile) {
110+
$newContent | Out-File -Encoding utf8 -FilePath $p
111+
Write-Verbose "Updated file: $p"
112+
}
113+
}
114+
return
115+
}
116+
117+
function Repair-PlatyPSMarkdown {
118+
param(
119+
[Parameter(Mandatory)]
120+
[string[]]
121+
$Path,
122+
123+
[Parameter()]
124+
[string[]]
125+
$ParameterName = @('ProgressAction')
126+
)
127+
$ErrorActionPreference = 'Stop'
128+
$Parameters = @{
129+
Path = $Path
130+
ParameterName = $ParameterName
131+
}
132+
$null = Remove-CommonParameterFromMarkdown @Parameters
133+
$null = Add-MissingCommonParameterToMarkdown @Parameters
134+
return
135+
}

src/pwshEmojiExplorer.build.ps1

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#>
3939

4040
#Include: Settings
41-
$ModuleName = (Split-Path -Path $BuildFile -Leaf).Split('.')[0]
41+
$ModuleName = [regex]::Match((Get-Item $BuildFile).Name, '^(.*)\.build\.ps1$').Groups[1].Value
4242
. "./$ModuleName.Settings.ps1"
4343

4444
function Test-ManifestBool ($Path) {
@@ -67,7 +67,7 @@ Add-BuildTask BuildNoIntegration -Jobs $str2
6767

6868
# Pre-build variables to be used by other portions of the script
6969
Enter-Build {
70-
$script:ModuleName = (Split-Path -Path $BuildFile -Leaf).Split('.')[0]
70+
$script:ModuleName = [regex]::Match((Get-Item $BuildFile).Name, '^(.*)\.build\.ps1$').Groups[1].Value
7171

7272
# Identify other required paths
7373
$script:ModuleSourcePath = Join-Path -Path $BuildRoot -ChildPath $script:ModuleName
@@ -384,6 +384,17 @@ Add-BuildTask CreateMarkdownHelp -After CreateHelpStart {
384384
throw 'Missing GUID. Please review and rebuild.'
385385
}
386386

387+
Write-Build Gray ' Evaluating if running 7.4.0 or higher...'
388+
# https://github.com/PowerShell/platyPS/issues/595
389+
if ($PSVersionTable.PSVersion -ge [version]'7.4.0') {
390+
Write-Build Gray ' Performing Markdown repair'
391+
# dot source markdown repair
392+
. $BuildRoot\MarkdownRepair.ps1
393+
$OutputDir | Get-ChildItem -File | ForEach-Object {
394+
Repair-PlatyPSMarkdown -Path $_.FullName
395+
}
396+
}
397+
387398
Write-Build Gray ' Checking for missing documentation in md files...'
388399
$MissingDocumentation = Select-String -Path "$script:ArtifactsPath\docs\*.md" -Pattern "({{.*}})"
389400
if ($MissingDocumentation.Count -gt 0) {

src/pwshEmojiExplorer/Private/Expand-XMLDataSet.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function Expand-XMLDataSet {
5757
ErrorAction = 'Stop'
5858
Path = '{0}/{1}' -f $script:dataPath, $script:dataFileZip
5959
}
60-
$null = Expand-Archive @expandArchiveSplat
60+
$null = Microsoft.PowerShell.Archive\Expand-Archive @expandArchiveSplat
6161
Write-Verbose -Message 'Expand completed.'
6262
} #try
6363
catch {

src/pwshEmojiExplorer/pwshEmojiExplorer.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'pwshEmojiExplorer.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.8.2'
15+
ModuleVersion = '0.8.4'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

0 commit comments

Comments
 (0)