Skip to content

Commit 12c7342

Browse files
Merge pull request #131 from StartAutomating/HelpOut-Fix
HelpOut 0.4.7
2 parents 820aa6f + efdc585 commit 12c7342

11 files changed

Lines changed: 88 additions & 43 deletions

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
### HelpOut 0.4.7:
2+
3+
* Get-MarkdownHelp: Automatically renaming help about aliases (Fixes #130)
4+
* Save-MarkdownHelp: Improving resiliency (avoiding null burps) (Fixes #128)
5+
6+
---
7+
18
### HelpOut 0.4.6:
29

310
* Save-MarkdownHelp: Improving resiliency (Fixes #128)
File renamed without changes.

Get-MarkdownHelp.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,19 @@
9797
# We decorate that object with the typename `PowerShell.Markdown.Help`.
9898
$helpObj.pstypenames.clear()
9999
$helpObj.pstypenames.add('PowerShell.Markdown.Help')
100+
$IsHelpAboutAlias = $helpObj.Name -ne $gotHelp.Name
101+
$helpObj | Add-Member NoteProperty IsAlias $IsHelpAboutAlias -Force
102+
if ($IsHelpAboutAlias) {
103+
$aliasCommand = $ExecutionContext.SessionState.InvokeCommand.GetCommand($gotHelp.Name, 'Alias')
104+
$helpObj | Add-Member NoteProperty AliasCommand $aliasCommand -Force
105+
}
100106

101107
# Then we attach parameters passed to this command to the help object.
102108
# * `-Rename` will become `[string] .Rename`
103109
if ($Rename) {
104110
$helpObj | Add-Member NoteProperty Rename $Rename -Force
111+
} elseif ($IsHelpAboutAlias) {
112+
$helpObj | Add-Member NoteProperty Rename $gotHelp.Name -Force
105113
}
106114

107115
# * `-SectionOrder` will become `[string[]] .SectionOrder`

HelpOut-Help.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<maml:description>
99
<maml:para>Gets MAML help</maml:para>
1010
</maml:description>
11-
<dev:version>0.4.6</dev:version>
11+
<dev:version>0.4.7</dev:version>
1212
</command:details>
1313
<maml:description>
1414
<maml:para>Gets help for a given command, as MAML (Microsoft Assistance Markup Language) xml.</maml:para>
@@ -400,7 +400,7 @@ This slightly reduces the size of the MAML file, and reduces the rate of changes
400400
<maml:description>
401401
<maml:para>Gets Markdown Help</maml:para>
402402
</maml:description>
403-
<dev:version>0.4.6</dev:version>
403+
<dev:version>0.4.7</dev:version>
404404
</command:details>
405405
<maml:description>
406406
<maml:para>Gets Help for a given command, in Markdown</maml:para>
@@ -666,7 +666,7 @@ If not provided, this will be the order they are defined in the formatter.</maml
666666
<maml:description>
667667
<maml:para>Gets a script's references</maml:para>
668668
</maml:description>
669-
<dev:version>0.4.6</dev:version>
669+
<dev:version>0.4.7</dev:version>
670670
</command:details>
671671
<maml:description>
672672
<maml:para>Gets the external references of a given PowerShell command. These are the commands the script calls, and the types the script uses.</maml:para>
@@ -792,7 +792,7 @@ If not provided, this will be the order they are defined in the formatter.</maml
792792
<maml:description>
793793
<maml:para>Gets a Script's story</maml:para>
794794
</maml:description>
795-
<dev:version>0.4.6</dev:version>
795+
<dev:version>0.4.7</dev:version>
796796
</command:details>
797797
<maml:description>
798798
<maml:para>Gets the Script's "Story"</maml:para>
@@ -955,7 +955,7 @@ If not provided, this will be the order they are defined in the formatter.</maml
955955
<maml:description>
956956
<maml:para>Installs MAML into a module</maml:para>
957957
</maml:description>
958-
<dev:version>0.4.6</dev:version>
958+
<dev:version>0.4.7</dev:version>
959959
</command:details>
960960
<maml:description>
961961
<maml:para>Installs MAML into a module. </maml:para>
@@ -1309,7 +1309,7 @@ This slightly reduces the size of the MAML file, and reduces the rate of changes
13091309
<maml:description>
13101310
<maml:para>Determines the percentage of documentation</maml:para>
13111311
</maml:description>
1312-
<dev:version>0.4.6</dev:version>
1312+
<dev:version>0.4.7</dev:version>
13131313
</command:details>
13141314
<maml:description>
13151315
<maml:para>Determines the percentage of documentation in a given script</maml:para>
@@ -1452,7 +1452,7 @@ This slightly reduces the size of the MAML file, and reduces the rate of changes
14521452
<maml:description>
14531453
<maml:para>Saves a Module's MAML</maml:para>
14541454
</maml:description>
1455-
<dev:version>0.4.6</dev:version>
1455+
<dev:version>0.4.7</dev:version>
14561456
</command:details>
14571457
<maml:description>
14581458
<maml:para>Generates a Module's MAML file, and then saves it to the appropriate location.</maml:para>
@@ -1713,7 +1713,7 @@ This slightly reduces the size of the MAML file, and reduces the rate of changes
17131713
<maml:description>
17141714
<maml:para>Saves a Module's Markdown Help</maml:para>
17151715
</maml:description>
1716-
<dev:version>0.4.6</dev:version>
1716+
<dev:version>0.4.7</dev:version>
17171717
</command:details>
17181718
<maml:description>
17191719
<maml:para>Get markdown help for each command in a module and saves it to the appropriate location.</maml:para>

HelpOut.psd1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@
77
ModuleToProcess='HelpOut.psm1'
88
FormatsToProcess='HelpOut.format.ps1xml'
99
TypesToProcess='HelpOut.types.ps1xml'
10-
ModuleVersion='0.4.6'
10+
ModuleVersion='0.4.7'
1111
PrivateData = @{
1212
PSData = @{
1313
ProjectURI = 'https://github.com/StartAutomating/HelpOut'
1414
LicenseURI = 'https://github.com/StartAutomating/HelpOut/blob/master/LICENSE'
1515

1616
Tags = 'Markdown', 'Help','PowerShell'
1717
ReleaseNotes = @'
18-
### HelpOut 0.4.6:
18+
### HelpOut 0.4.7:
1919
20-
* Save-MarkdownHelp: Improving resiliency (Fixes #128)
20+
* Get-MarkdownHelp: Automatically renaming help about aliases (Fixes #130)
21+
* Save-MarkdownHelp: Improving resiliency (avoiding null burps) (Fixes #128)
2122
2223
---
24+
2325
Additional Changes in [Changelog](/CHANGELOG.md)
2426
'@
2527
}

HelpOut.types.ps1xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ $this |
111111
.DESCRIPTION
112112
Returns the content of this help topic as a markdown string.
113113
.EXAMPLE
114-
114+
(Get-MarkDownHelp Get-MarkDownHelp).ToMarkdown()
115115
#&gt;
116116
param(
117117
# An optional view.

Save-MarkdownHelp.ps1

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,13 @@
230230
if ($markdownTopic.Save) {
231231
$markdownTopic.Save($docOutputPath)
232232
} else { $null }
233-
234-
$filesChanged += $markdownFile
235233

236-
if ($PassThru) { # If -PassThru was provided, get the path.
237-
$markdownFile
234+
if ($markdownFile) {
235+
$filesChanged += $markdownFile
236+
237+
if ($PassThru) { # If -PassThru was provided, get the path.
238+
$markdownFile
239+
}
238240
}
239241
}
240242

@@ -267,7 +269,7 @@
267269
$getMarkdownHelpSplat.Rename = $replacedCmdName
268270
if ($Wiki) { $getMarkdownHelpSplat.Wiki = $Wiki}
269271
else { $getMarkdownHelpSplat.GitHubDocRoot = "$($outputPath|Split-Path -Leaf)"}
270-
272+
$markdownFile = $null
271273
try {
272274
$markdownTopic = Get-MarkdownHelp @getMarkdownHelpSplat
273275
$markdownFile =
@@ -280,12 +282,14 @@
280282
Write-Error -Exception $ex.Exception -Message "Could not Get Help for $($cmd.Name): $($ex.Exception.Message)" -TargetObject $getMarkdownHelpSplat
281283
}
282284

283-
$filesChanged += # add the file to the changed list.
284-
$markdownFile
285+
if ($markdownFile) {
286+
$filesChanged += # add the file to the changed list.
287+
$markdownFile
285288

286-
# If -PassThru was provided (and we're not going to change anything)
287-
if ($PassThru -and -not $ReplaceLink) {
288-
$filesChanged[-1] # output the file changed now.
289+
# If -PassThru was provided (and we're not going to change anything)
290+
if ($PassThru -and -not $ReplaceLink) {
291+
$filesChanged[-1] # output the file changed now.
292+
}
289293
}
290294

291295
}
@@ -343,12 +347,13 @@
343347
if ($markdownTopic.Save) {
344348
$markdownTopic.Save($docOutputPath)
345349
} else { $null }
346-
347-
$filesChanged += $markdownFile # add the file to the changed list.
350+
if ($markdownFile) {
351+
$filesChanged += $markdownFile # add the file to the changed list.
348352

349-
# If -PassThru was provided (and we're not going to change anything)
350-
if ($PassThru -and -not $ReplaceLink) {
351-
$markdownFile # output the file changed now.
353+
# If -PassThru was provided (and we're not going to change anything)
354+
if ($PassThru -and -not $ReplaceLink) {
355+
$markdownFile # output the file changed now.
356+
}
352357
}
353358
}
354359
}

Types/PowerShell.Markdown.Help/ToMarkdown.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
.DESCRIPTION
55
Returns the content of this help topic as a markdown string.
66
.EXAMPLE
7-
7+
(Get-MarkDownHelp Get-MarkDownHelp).ToMarkdown()
88
#>
99
param(
1010
# An optional view.

allcommands.ps1

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,19 @@ function Get-MarkdownHelp {
500500
# We decorate that object with the typename `PowerShell.Markdown.Help`.
501501
$helpObj.pstypenames.clear()
502502
$helpObj.pstypenames.add('PowerShell.Markdown.Help')
503+
$IsHelpAboutAlias = $helpObj.Name -ne $gotHelp.Name
504+
$helpObj | Add-Member NoteProperty IsAlias $IsHelpAboutAlias -Force
505+
if ($IsHelpAboutAlias) {
506+
$aliasCommand = $ExecutionContext.SessionState.InvokeCommand.GetCommand($gotHelp.Name, 'Alias')
507+
$helpObj | Add-Member NoteProperty AliasCommand $aliasCommand -Force
508+
}
503509

504510
# Then we attach parameters passed to this command to the help object.
505511
# * `-Rename` will become `[string] .Rename`
506512
if ($Rename) {
507513
$helpObj | Add-Member NoteProperty Rename $Rename -Force
514+
} elseif ($IsHelpAboutAlias) {
515+
$helpObj | Add-Member NoteProperty Rename $gotHelp.Name -Force
508516
}
509517

510518
# * `-SectionOrder` will become `[string[]] .SectionOrder`
@@ -1641,11 +1649,13 @@ function Save-MarkdownHelp
16411649
if ($markdownTopic.Save) {
16421650
$markdownTopic.Save($docOutputPath)
16431651
} else { $null }
1644-
1645-
$filesChanged += $markdownFile
16461652

1647-
if ($PassThru) { # If -PassThru was provided, get the path.
1648-
$markdownFile
1653+
if ($markdownFile) {
1654+
$filesChanged += $markdownFile
1655+
1656+
if ($PassThru) { # If -PassThru was provided, get the path.
1657+
$markdownFile
1658+
}
16491659
}
16501660
}
16511661

@@ -1678,7 +1688,7 @@ function Save-MarkdownHelp
16781688
$getMarkdownHelpSplat.Rename = $replacedCmdName
16791689
if ($Wiki) { $getMarkdownHelpSplat.Wiki = $Wiki}
16801690
else { $getMarkdownHelpSplat.GitHubDocRoot = "$($outputPath|Split-Path -Leaf)"}
1681-
1691+
$markdownFile = $null
16821692
try {
16831693
$markdownTopic = Get-MarkdownHelp @getMarkdownHelpSplat
16841694
$markdownFile =
@@ -1691,12 +1701,14 @@ function Save-MarkdownHelp
16911701
Write-Error -Exception $ex.Exception -Message "Could not Get Help for $($cmd.Name): $($ex.Exception.Message)" -TargetObject $getMarkdownHelpSplat
16921702
}
16931703

1694-
$filesChanged += # add the file to the changed list.
1695-
$markdownFile
1704+
if ($markdownFile) {
1705+
$filesChanged += # add the file to the changed list.
1706+
$markdownFile
16961707

1697-
# If -PassThru was provided (and we're not going to change anything)
1698-
if ($PassThru -and -not $ReplaceLink) {
1699-
$filesChanged[-1] # output the file changed now.
1708+
# If -PassThru was provided (and we're not going to change anything)
1709+
if ($PassThru -and -not $ReplaceLink) {
1710+
$filesChanged[-1] # output the file changed now.
1711+
}
17001712
}
17011713

17021714
}
@@ -1754,12 +1766,13 @@ function Save-MarkdownHelp
17541766
if ($markdownTopic.Save) {
17551767
$markdownTopic.Save($docOutputPath)
17561768
} else { $null }
1757-
1758-
$filesChanged += $markdownFile # add the file to the changed list.
1769+
if ($markdownFile) {
1770+
$filesChanged += $markdownFile # add the file to the changed list.
17591771

1760-
# If -PassThru was provided (and we're not going to change anything)
1761-
if ($PassThru -and -not $ReplaceLink) {
1762-
$markdownFile # output the file changed now.
1772+
# If -PassThru was provided (and we're not going to change anything)
1773+
if ($PassThru -and -not $ReplaceLink) {
1774+
$markdownFile # output the file changed now.
1775+
}
17631776
}
17641777
}
17651778
}

docs/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
### HelpOut 0.4.7:
2+
3+
* Get-MarkdownHelp: Automatically renaming help about aliases (Fixes #130)
4+
* Save-MarkdownHelp: Improving resiliency (avoiding null burps) (Fixes #128)
5+
6+
---
7+
18
### HelpOut 0.4.6:
29

310
* Save-MarkdownHelp: Improving resiliency (Fixes #128)

0 commit comments

Comments
 (0)