The idea is to highlight the Function through the end of the param block and press a shortcut and the documentation header is generated and placed before your function. Here’s the code to parse the param block hunting for relevant parameters.

So as you can see you select the parameters (and ideally the function name as well) and the script hunts for variables (starts with $ but not in [] to avoid ValidateScript blocks). From there, it looks for default parameters and uses the PascalCase (you are using PascalCase for your function variables right?) to split up the parameter name and make an approximate description.

The Register-EditorCommand tells VSCode to allow that command to be run from the command palate. By default you run Ctrl-Shift-P then select “Show additional commands from powershell modules” and then choose “Create Parameter Documentation”

To use it add the function to your VSCode profile (run $profile from the integrated console in vscode and edit that file to either import a module wiht this function or just have the function directly).

If you want to add a keyboard shortcut for it add the following to your VSCode keybindings.json (with whatever shortcut you want):

{

"key": "ctrl+f6",

"command": "PowerShell.InvokeRegisteredEditorCommand",

"args": {

"commandName": "New-ParamBlock"

},

"when": "editorTextFocus"

}

Caveats and notes: