Skip to content

Commit

Permalink
(chocolateyGH-774) Autodoc - Fix Aliases
Browse files Browse the repository at this point in the history
The alias determination was not working properly. Run a command to pull
back the aliases instead of trusting they are part of the object.

Also restrict the Get-Command to just Functions to avoid duplicates
when there are command aliases.
  • Loading branch information
ferventcoder committed Jun 6, 2016
1 parent 76725c9 commit d56b974
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions .build.custom/GenerateDocs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ These are the functions from above as one list.
'@

function Get-Aliases($commandName){

$aliasOutput = ''
Get-Alias -Definition $commandName -ErrorAction SilentlyContinue | %{ $aliasOutput += "``$($_.Name)``$lineFeed"}

if ($aliasOutput -eq $null -or $aliasOutput -eq '') {
$aliasOutput = 'None'
}

Write-Output $aliasOutput
}

function Convert-Example($objItem) {
@"
**$($objItem.title.Replace('-','').Trim())**
Expand Down Expand Up @@ -260,7 +272,7 @@ try
if(-not(Test-Path $docsFolder)){ mkdir $docsFolder -EA Continue | Out-Null }

Write-Host 'Creating per PowerShell function markdown files...'
Get-Command -Module $psModuleName | ForEach-Object -Process { Get-Help $_ -Full } | ForEach-Object -Process { `
Get-Command -Module $psModuleName -CommandType Function | ForEach-Object -Process { Get-Help $_ -Full } | ForEach-Object -Process { `
$commandName = $_.Name
$fileName = Join-Path $docsFolder "Helpers$($_.Name.Replace('-','')).md"
$global:powerShellReferenceTOC += "$lineFeed * [[$commandName|$([System.IO.Path]::GetFileNameWithoutExtension($fileName))]]"
Expand All @@ -279,8 +291,7 @@ $( if ($_.alertSet -ne $null) { $lineFeed + "## Notes" + $lineFeed + $lineFeed +
## Aliases
$( if ($_.aliases -ne $null) { $_.aliases } else { 'None'} )
$(Get-Aliases $_.Name)
## Inputs
$( if ($_.InputTypes -ne $null -and $_.InputTypes.Length -gt 0 -and -not $_.InputTypes.Contains('inputType')) { $lineFeed + " * $($_.InputTypes)" + $lineFeed} else { 'None'})
Expand Down

0 comments on commit d56b974

Please sign in to comment.