Monday, 15 April 2013

powershell - Add documentation to custom methods (ScriptMethod) -



powershell - Add documentation to custom methods (ScriptMethod) -

a custom powershell script or function can documented standard comment @ origin of body:

function welldocumented { <# .synopsis documented function .description "be verbose in documentation" - .parameter foo should 42 or 15, not more #> param( [int]$foo ) <# ... #> }

get-help welldocumented returns nice info then. how can document custom scriptmethods in custom objects? next not work:

$myclass | add-member -memtype scriptmethod -name "foo" -value { <# .synopsis - brief .description #> <# ... #> }

is there standard way document scriptmethods?

you can write script method separate function first (like did welldocumented) pass function scriptblock:

class="lang-powershell prettyprint-override">$myclass | add-member -memtype scriptmethod -name "foo" -value ${function:welldocumented}

you still can't phone call get-help $myclass.foo, can phone call get-help welldocumented.

in testing not able help on method.

powershell powershell-v2.0 powershell-v3.0

No comments:

Post a Comment