Function to insert help tags in PowerShell_ISE


posted by Brent Challis
02-14-2011

Downloads: 294
File size: 6.4kB
Views: 1,404

Embed
Function to insert help tags in PowerShell_ISE
  1. <# 
  2. .SYNOPSIS 
  3.   Inset tags to support the Get-Help Cmdlet 
  4. .DESCRIPTION 
  5.   Insert-FunctionHelpText inserts text at the current cursor position to provide 
  6.   a skeleton of tags which can then be editted to provide support for the function 
  7.   and the Get-Help Cmdlet. 
  8. .NOTES 
  9.   This is a useful function to be called from a menu added to the PowerShell-ISE 
  10.   Add-ons menu structure.   
  11. .EXAMPLE 
  12.   Insert-FunctionHelpText 
  13. #> 
  14. function Insert-FunctionHelpText() 
  15. $psISE.CurrentFile.Editor.InsertText("<# 
  16.     .SYNOPSIS 
  17.         A brief description of the function or script. This keyword can be used 
  18.         only once in each topic. 
  19.  
  20.     .DESCRIPTION 
  21.         A detailed description of the function or script. This keyword can be 
  22.         used only once in each topic. 
  23.  
  24.     .PARAMETER  <Parameter-Name> 
  25.         The description of a parameter. You can include a Parameter keyword for 
  26.         each parameter in the function or script syntax. 
  27.  
  28.     .EXAMPLE 
  29.         A sample command that uses the function or script, optionally followed 
  30.         by sample output and a description. Repeat this keyword for each example. 
  31.  
  32.     .INPUTS 
  33.         The Microsoft .NET Framework types of objects that can be piped to the 
  34.         function or script. You can also include a description of the input  
  35.         objects. 
  36.  
  37.     .OUTPUTS 
  38.         The .NET Framework type of the objects that the cmdlet returns. You can 
  39.         also include a description of the returned objects. 
  40.  
  41.     .NOTES 
  42.         Additional information about the function or script. 
  43.  
  44.     .LINK 
  45.         The name of a related topic. Repeat this keyword for each related topic. 
  46.  
  47.         This content appears in the Related Links section of the Help topic. 
  48.  
  49.     .COMPONENT 
  50.         The technology or feature that the function or script uses, or to which 
  51.         it is related. This content appears when the Get-Help command includes 
  52.         the Component parameter of Get-Help. 
  53.  
  54.     .ROLE 
  55.         The user role for the Help topic. This content appears when the Get-Help 
  56.         command includes the Role parameter of Get-Help. 
  57.  
  58.     .FUNCTIONALITY 
  59.         The intended use of the function. This content appears when the Get-Help 
  60.         command includes the Functionality parameter of Get-Help. 
  61.  
  62.     .FORWARDHELPTARGETNAME <Command-Name> 
  63.         Redirects to the Help topic for the specified command. You can redirect 
  64.         users to any Help topic, including Help topics for a function, script, 
  65.         cmdlet, or provider.  
  66.  
  67.     .FORWARDHELPCATEGORY  <Category> 
  68.         Specifies the Help category of the item in ForwardHelpTargetName. 
  69.         Valid values are Alias, Cmdlet, HelpFile, Function, Provider, General, 
  70.         FAQ, Glossary, ScriptCommand, ExternalScript, Filter, or All. Use this 
  71.         keyword to avoid conflicts when there are commands with the same name. 
  72.  
  73.     .REMOTEHELPRUNSPACE <PSSession-variable> 
  74.         Specifies a session that contains the Help topic. Enter a variable that 
  75.         contains a PSSession. This keyword is used by the Export-PSSession 
  76.         cmdlet to find the Help topics for the exported commands. 
  77.  
  78.     .EXTERNALHELP  <XML Help File Path> 
  79.         Specifies the path to an XML-based Help file for the script or function.   
  80.  
  81. #> 
  82. "

The function will insert the comment tags to provide a template for the information required by the Get-Help Cmdlet.  I include this function on my PowerShell_ISE profile and have a menu item added to call it.

Copyright 2012 PowerShell.com. All rights reserved.