Skip to content

Commit

Permalink
Allowing Markdown Help sections to be hidden (Fixes #124)
Browse files Browse the repository at this point in the history
  • Loading branch information
James Brundage committed May 26, 2023
1 parent 7308f5f commit 3fd86aa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Formatting/PowerShell.Markdown.Help.format.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,11 @@ If the command sets a ```[ConfirmImpact("Medium")]``` which is lower than ```$co

$sectionCounter = 0
foreach ($sectionName in $orderOfSections) {

$sectionCounter++
$sectionContent =
if ($MarkdownSections.$sectionName -is [ScriptBlock]) {
if ($MarkdownSections.$sectionName -is [ScriptBlock] -and
$helpObject.HideSections -notcontains $sectionName) {
& $MarkdownSections.$sectionName
} else { $null }
if ($sectionContent) {
Expand Down
24 changes: 24 additions & 0 deletions Types/PowerShell.Markdown.Help/HideSection.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<#
.SYNOPSIS
Hides sections of markdown help
.DESCRIPTION
Hides sections of a command's markdown help.
#>
param(
# One or more section names.
[ValidateSet('Name','Synopsis','Description','RelatedLinks','Examples','Parameters','Inputs','Outputs','Notes','Story','Syntax')]
[Alias('SectionName')]
[string[]]
$SectionNames
)


$skipSectionNames = @($This.HideSections)
foreach ($SectionName in $SectionNames) {
if ($skipSectionNames -notcontains $SectionName) {
$skipSectionNames += $SectionName
}
}

$this |
Add-Member NoteProperty HideSections $skipSectionNames -Force

0 comments on commit 3fd86aa

Please sign in to comment.