Skip to content

Instantly share code, notes, and snippets.

@cdhunt
Created May 26, 2016 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdhunt/04372211e2f0f06045583ebbccb606c0 to your computer and use it in GitHub Desktop.
Save cdhunt/04372211e2f0f06045583ebbccb606c0 to your computer and use it in GitHub Desktop.
Use the Markdown.types.ps1xml to generate a help file in Markdown
$help = Get-Help Get-Location
$help.Name.MarkdownHeader()
"Synopsis".MarkdownHeader(2)
$help.Synopsis
"Description".MarkdownHeader(2)
$help.description.text
"Syntax".MarkdownHeader(2)
$help.syntax | Foreach {
($help.syntax | out-string )-split "`n" | foreach {"$_ <br />".MarkdownQuote()}
}
"Parameters".MarkdownHeader(2)
$help.parameters.parameter | foreach {
$_.name.MarkdownHeader(3)
$_.description
if ($_.aliases)
{
"Aliases".MarkdownHeader(4)
$_.aliases | foreach {$_.MarkdownUL()}
}
}
"Examples".MarkdownHeader(2)
$i = 1
$help.examples.example | foreach {
"Example $i".MarkdownHeader(3)
$_.code.MarkdownCodeBlock("powershell")
$_.remarks
$i++
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment