mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-22 01:48:20 +02:00
Update convert-ps2md.ps1
This commit is contained in:
parent
1f89c6d625
commit
6deaa2fbe7
@ -12,7 +12,7 @@
|
|||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param([string]$script)
|
param([string]$script = "")
|
||||||
|
|
||||||
function EncodePartOfHtml {
|
function EncodePartOfHtml {
|
||||||
param (
|
param (
|
||||||
@ -63,15 +63,14 @@ function GetRemark {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if ($script -eq "") { $script = read-host "Enter path to PowerShell script" }
|
||||||
|
|
||||||
$full = Get-Help $script -Full
|
$full = Get-Help $script -Full
|
||||||
|
|
||||||
"# $($full.Name)"
|
"# $($full.Synopsis)"
|
||||||
"$($full.Synopsis)"
|
|
||||||
|
|
||||||
$Description = ($full.description | Out-String).Trim()
|
$Description = ($full.description | Out-String).Trim()
|
||||||
if ($Description -ne "") {
|
if ($Description -ne "") {
|
||||||
""
|
|
||||||
"## Description"
|
|
||||||
"$Description"
|
"$Description"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,27 +82,29 @@ try {
|
|||||||
"$Syntax"
|
"$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
|
## Examples
|
||||||
"@ + $(foreach ($example in $full.examples.example) {
|
"@ + $(foreach ($example in $full.examples.example) {
|
||||||
@"
|
@"
|
||||||
@ -131,6 +132,7 @@ $(GetRemark $example)
|
|||||||
"## Related Links"
|
"## Related Links"
|
||||||
"$Links"
|
"$Links"
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
} finally {
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
exit 1
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user