mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-23 06:08:36 +01:00
Update convert-ps2md.ps1
This commit is contained in:
parent
1f89c6d625
commit
6deaa2fbe7
@ -12,7 +12,7 @@
|
||||
https://github.com/fleschutz/PowerShell
|
||||
#>
|
||||
|
||||
param([string]$script)
|
||||
param([string]$script = "")
|
||||
|
||||
function EncodePartOfHtml {
|
||||
param (
|
||||
@ -63,15 +63,14 @@ function GetRemark {
|
||||
}
|
||||
|
||||
try {
|
||||
if ($script -eq "") { $script = read-host "Enter path to PowerShell script" }
|
||||
|
||||
$full = Get-Help $script -Full
|
||||
|
||||
"# $($full.Name)"
|
||||
"$($full.Synopsis)"
|
||||
"# $($full.Synopsis)"
|
||||
|
||||
$Description = ($full.description | Out-String).Trim()
|
||||
if ($Description -ne "") {
|
||||
""
|
||||
"## Description"
|
||||
"$Description"
|
||||
}
|
||||
|
||||
@ -83,27 +82,29 @@ try {
|
||||
"$Syntax"
|
||||
"``````"
|
||||
}
|
||||
|
||||
foreach($parameter in $full.parameters.parameter) {
|
||||
""
|
||||
"## Parameter -$($parameter.name) <$($parameter.type.name)>"
|
||||
"$(($parameter.description | Out-String).Trim())"
|
||||
"``````"
|
||||
"$(((($parameter | Out-String).Trim() -split "`r`n")[-5..-1] | % { $_.Trim() }) -join "`r`n")"
|
||||
"``````"
|
||||
}
|
||||
|
||||
foreach($input in $full.inputTypes) {
|
||||
""
|
||||
"## Inputs"
|
||||
"$($input.inputType.type.name)"
|
||||
}
|
||||
|
||||
foreach($output in $full.outputTypes) {
|
||||
""
|
||||
"## Outputs"
|
||||
"$($output.outputType.type.name)"
|
||||
}
|
||||
@"
|
||||
|
||||
|
||||
## Parameters
|
||||
"@ + $(foreach ($parameter in $full.parameters.parameter) {
|
||||
@"
|
||||
|
||||
### -$($parameter.name) <$($parameter.type.name)>
|
||||
$(($parameter.description | Out-String).Trim())
|
||||
``````
|
||||
$(((($parameter | Out-String).Trim() -split "`r`n")[-5..-1] | % { $_.Trim() }) -join "`r`n")
|
||||
``````
|
||||
|
||||
"@
|
||||
}) + @"
|
||||
|
||||
## Inputs
|
||||
$($full.inputTypes.inputType.type.name)
|
||||
|
||||
## Outputs
|
||||
|
||||
## Examples
|
||||
"@ + $(foreach ($example in $full.examples.example) {
|
||||
@"
|
||||
@ -131,6 +132,7 @@ $(GetRemark $example)
|
||||
"## Related Links"
|
||||
"$Links"
|
||||
}
|
||||
|
||||
} finally {
|
||||
}
|
||||
} catch {
|
||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user