|
| 1 | +# Azure PowerShell Help Generation |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +All MAML files containing the help content for cmdlets have been removed from the Azure PowerShell repository and replaced with markdown files, which are generated and maintained using the [`platyPS`](https://github.com/PowerShell/platyPS) module. Each module has a `help` folder (_e.g.,_ `src/ResourceManager/Profile/Commands.Profile/help`) which contains a markdown file for each of the cmdlets found in that given module. When the help content for a cmdlet (or multiple cmdlets) needs to be updated, users will now only have to update the contents of the markdown file, _and not the MAML file as well_. |
| 6 | + |
| 7 | +## Installing `platyPS` |
| 8 | + |
| 9 | +In order to use the cmdlets necessary to update the markdown help files (or generate MAML help locally from these markdown files), you must first install the `platyPS` module mentioned previously. |
| 10 | + |
| 11 | +To do so, you can can follow the below steps (which are outlined in the [**Quick start**](https://github.com/PowerShell/platyPS#quick-start) section of the `platyPS` README): |
| 12 | + |
| 13 | +```powershell |
| 14 | +Install-Module -Name platyPS -Scope CurrentUser |
| 15 | +Import-Module platyPS |
| 16 | +``` |
| 17 | + |
| 18 | +**Note:** this module will need to be installed from the [PowerShell Gallery](http://www.powershellgallery.com/). If, for some reason, this isn't a registered repository when running the `Get-PSRepository` cmdlet, then you will need to register it by running the following command: |
| 19 | + |
| 20 | +```powershell |
| 21 | +Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2/ |
| 22 | +``` |
| 23 | + |
| 24 | +## Using `platyPS` |
| 25 | + |
| 26 | +### Importing your module |
| 27 | + |
| 28 | +Before you run the `platyPS` cmdlets to update your markdown help files, you will need to first import the module containing the changes that you have made to your cmdlets into your current PowerShell session. Once you have built your project (either through Visual Studio or with `msbuild`), you can locate the module manifest that you will need to import in the `src/Package/Debug` folder of your local repository. |
| 29 | + |
| 30 | +For example, if you have made changes to the `Profile` module, you will find the corresponding module manifest in `src/Package/Debug/ResourceManager/AzureResourceManager/AzureRM.Profile/AzureRM.Profile.psd1`. |
| 31 | + |
| 32 | +Once you have located the module manifest, you can import it in your current PowerShell session by running the following command: |
| 33 | + |
| 34 | +```powershell |
| 35 | +$PathToModuleManifest = "../../<module>.psd1" |
| 36 | +Import-Module -Name $PathToModuleManifest |
| 37 | +``` |
| 38 | + |
| 39 | +**Note**: if you do not see all of the changes you made to the cmdlets in your markdown files (_e.g.,_ a cmdlet you deleted is still appearing), you may need to delete any existing Azure PowerShell modules that you have on your machine (installed either through the PowerShell Gallery or by Web Platform Installer) before you import your module. |
| 40 | + |
| 41 | +### Updating help after making cmdlet changes |
| 42 | + |
| 43 | +Whenever the public interface for a cmdlet has changed, the corresponding markdown file for that cmdlet will need to be updated to reflect the changes. Public interface changes include the following: |
| 44 | + |
| 45 | +- Add/change/remove parameter set |
| 46 | +- Add/remove parameter |
| 47 | +- Change attribute of a parameter |
| 48 | + - Type |
| 49 | + - Parameter set(s) |
| 50 | + - Aliases |
| 51 | + - Mandatory |
| 52 | + - Position |
| 53 | + - Accept pipeline input |
| 54 | +- Add/change output type |
| 55 | + |
| 56 | +#### Updating all markdown files in a module |
| 57 | + |
| 58 | +To update all of the markdown files for a single module, use the [`Update-MarkdownHelpModule`](https://github.com/PowerShell/platyPS/blob/master/docs/Update-MarkdownHelpModule.md) cmdlet: |
| 59 | + |
| 60 | +```powershell |
| 61 | +$PathToModuleManifest = "../../<module.psd1" # Full path to the module manifest that you have updated |
| 62 | +Import-Module -Name $PathToModuleManifest |
| 63 | +
|
| 64 | +$PathToHelpFolder = "../../help" # Full path to help folder containing markdown files to be updated |
| 65 | +Update-MarkdownHelpModule -Path $PathToHelpFolder -RefreshModulePage -AlphabeticParamsOrder |
| 66 | +``` |
| 67 | + |
| 68 | +This will update all of the markdown files with public interface changes made to corresponding cmdlets, add markdown files for any new cmdlets, remove markdown files for any deleted cmdlets, and update the module page (_e.g.,_ `AzureRM.Profile.md`) with any added or removed cmdlets. |
| 69 | + |
| 70 | +#### Updating a single markdown file |
| 71 | + |
| 72 | +To update a single markdown file with the changes made to the corresponding cmdlet, use the [`Update-MarkdownHelp`](https://github.com/PowerShell/platyPS/blob/master/docs/Update-MarkdownHelp.md) cmdlet: |
| 73 | + |
| 74 | +```powershell |
| 75 | +$PathToModuleManifest = "../../<module>.psd1" # Full path to the module manifest that you have updated |
| 76 | +Import-Module -Name $PathToModuleManifest |
| 77 | +
|
| 78 | +$PathToMarkdownFile = "../../<cmdlet>.md" # Full path to the markdown file to be updated |
| 79 | +Update-MarkdownHelp -Path $PathToMarkdownFile -AlphabeticParamsOrder |
| 80 | +``` |
| 81 | + |
| 82 | +#### Generating and viewing the MAML help |
| 83 | + |
| 84 | +During the build, the MAML help will be generated from the markdown files in the repository. If you would like to generate the MAML help and preview what the help content will look like for each of your cmdlets, you can do so with two more commands. |
| 85 | + |
| 86 | +To generate the MAML help based on the contents of your markdown files, use the [`New-ExternalHelp`](https://github.com/PowerShell/platyPS/blob/master/docs/New-ExternalHelp.md) cmdlet: |
| 87 | + |
| 88 | +```powershell |
| 89 | +$PathToHelpFolder = "../../help" # Full path to help folder containing markdown files to be updated |
| 90 | +$PathToOutputFolder = "../../.." # Full path to folder where you want the MAML file to be generated |
| 91 | +New-ExternalHelp -Path $PathToHelpFolder -OutputPath $PathToOutputFolder |
| 92 | +``` |
| 93 | + |
| 94 | +To preview the help that you just generated, use the [`Get-HelpPreview`](https://github.com/PowerShell/platyPS/blob/master/docs/Get-HelpPreview.md) cmdlet: |
| 95 | + |
| 96 | +```powershell |
| 97 | +$PathToMAML = "../../<maml>.dll-Help.xml" # Full path to the MAML file that was generated |
| 98 | +
|
| 99 | +# Save the help locally |
| 100 | +$help = Get-HelpPreview -Path $PathToMAML |
| 101 | +
|
| 102 | +# Get the help for a specific cmdlet |
| 103 | +$help | where { $_.Name -eq "<cmdlet>" } |
| 104 | +``` |
0 commit comments