With the advent of the open-source XmlDoc2CmdletDoc, you can now document your binary PowerShell cmdlets (i.e. those written in C#) just like any other C# libraries, and just like scripted cmdlets (those written in PowerShell): use inline documentation comments.
No longer do you need to maintain a parallel MAML file by hand! Just instrument your build so that when you recompile your C# project it executes the documentation generator and you get both a module.dll and a module.dll-Help.xml. The latter is directly used by PowerShell to provide help on your cmdlets when you invoke Get-Help
.
And XmlDoc2CmdletDoc even offers a -strict
switch to ensure that you have comprehensively documented your cmdlets; if you use the switch and you missed something, your build will fail, as it should.
Other benefits automatically provided by XmlDoc2CmdletDoc ("sections" in this list refers to the sections of help presented by Get-Help
):
- Each custom type in the Outputs section includes a description.
- The Syntax section includes possible values for enumerated types.
- The Parameter section includes possible values for enumerated types.
- Aliases are documented automatically in the Parameters section.
- Aliases are treated as first-class parameters so you can ask for help on an alias.
- You can optionally use a different description for a parameter in the Inputs section as you have for the Parameter section.
- Web links are automatically rendered in markdown format, for possible post-processing to live links. (This enhancement is pending.)
I liked this open-source utility so much I started contributing to it, providing several of the above benefits. And I wrote a comprehensive guide to using it, entitled Documenting Your PowerShell Binary Cmdlets, just published on Simple-Talk.com.