Skip to content

platyPS documentation and Profile conversion #2932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 10, 2016

Conversation

cormacpayne
Copy link
Member

@cormacpayne cormacpayne commented Sep 13, 2016

Comments

Fix for issue #2921

platyPS is a tool used to convert the current MAML help files into individual markdown files for each cmdlet in a service. This allows partners to easily edit the help for cmdlets using markdown rather than MAML.

This commit contains documentation on how to use the platyPS tool to make these changes, as well as scripts that will help a service team generate these markdown files and validate that they have all of the necessary help information for each cmdlet.

This commit also converts Profile to the markdown help, which will need to be updated in a separate PR.


This checklist is used to make sure that common issues in a pull request are covered by the creator. You can find a more complete discussion of PowerShell cmdlet best practices here.

Below in Overall Changes, check off the boxes that apply to your PR. For the categories that you did not check off, you can remove them from this body. Within each of the categories that you did select, make sure that you can check off all of the boxes.

For information on cleaning up the commits in your pull request, click here.

Overall Changes

General

  • Title of the PR is clear and informative
  • There are a small number of commits that each have an informative message
  • If it applies, references the bug/issue that the PR fixes
  • All files have the Microsoft copyright header
  • Cmdlets refer to management libraries through nuget references - no dlls are checked in
  • The PR does not introduce breaking changes (unless a major version change occurs in the assembly and module)

Tests

  • PR includes test coverage for the included changes
  • Tests must use xunit, and should either use Moq to mock management client calls, or use the scenario test framework
  • PowerShell scripts used in tests must not use hard-coded values for location
  • PowerShell scripts used in tests should do any necessary setup as part of the test or suite setup, and should not use hard-coded values for existing resources
  • Tests should not use App.config files for settings
  • Tests should use the built-in PowerShell functions for generating random names when unique names are necessary - this will store names in the test recording
  • Tests should use Start-Sleep to pause rather than Thread.Sleep

@cormacpayne cormacpayne changed the title platyPS documentation and Profile conversion [DO NOT MERGE] platyPS documentation and Profile conversion Sep 13, 2016
@cormacpayne cormacpayne changed the title [DO NOT MERGE] platyPS documentation and Profile conversion platyPS documentation and Profile conversion Sep 26, 2016
Copy link
Member

@markcowl markcowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One other comment: We should really have tests at least for the validate cmdlets and the transofmration we are doing - a couple of dummy help files and cmdlets, using the simple test framework we use in the setup tests would suffice.


## Description

PlatyPS is used to create PowerShell external help in markdown rather than MAML. Where as MAML can be difficult to edit by hand or read, markdown is designed to be human-readable and easy to edit. This will allow service teams to quickly and easily edit any help documentation they have for their cmdlets.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... rather than XML (MAML). Whereas powershell XML help (MAML) can be difficult to read, edit, or review in github, ...

Our users do not really know that MAML is the name of the Xml schema for PowerShell help, so I would avois making it too prominent

```
then the markdown files will be generated from the information in the MAML file (found in the module) **and** using reflection on the cmdlet implementation in the module.

#### NOTE
Copy link
Member

@markcowl markcowl Sep 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would refer to this note here and place the note itself further down in the document. It detracts a little bit from the flow of figuring out what I need to do

- [How it Works](#how-it-works)
- [Creating markdown](#creating-markdown)
- [Updating markdown](#updating-markdown)
- [Updating MAML](#updating-maml)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating Xml help

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change is still needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been changed.

- [Creating markdown](#creating-markdown)
- [Updating markdown](#updating-markdown)
- [Updating MAML](#updating-maml)
- [Previewing MAML](#previewing-maml)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previewing xml help

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change is still needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been changed.

- [Updating markdown](#updating-markdown)
- [Updating MAML](#updating-maml)
- [Previewing MAML](#previewing-maml)
- [Getting Started](#getting-started)
Copy link
Member

@markcowl markcowl Sep 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put the 'Getting Started' section above 'How it Works'

$idx++

# Check each line between SYNOPSIS and SYNTAX for any text
for (;;)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not do the for over all lines in the file and break if synopsis is found? What happens if idx is past the length of the array (i.e. there is no syntax)?

Copy link
Member Author

@cormacpayne cormacpayne Sep 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that each of the major sections (synopsis, syntax, description, etc.) is always generated by platyPS, regardless of whether or not there is corresponding information for it. In that case, it is guaranteed to have a synopsis section and a syntax section, so this for-loop will always be triggered and will always terminate.

for (;;)
{
$foundSynopsis = $foundSynopsis -or (!([string]::IsNullOrWhiteSpace("$($content[$idx])")))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might consider using a regular expression and the C# Regex class for each of these. You can see examples of usage in the PublishModules script.

# Check each line between OUTPUTS and NOTES for any text
for (;;)
{
$foundOutput = $foundOutput -or (!([string]::IsNullOrWhiteSpace("$($content[$idx])")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all commands produce output, so we might consider this as a warning.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was something I thought about but didn't continue with. I will find a way to separate the output warnings from the regular errors in the script.

# If the markdown file had any missing help, add them to the list to be printed later
if ($fileErrors.Count -gt 0)
{
$errors += $file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a readble format for this:

=========
File: Get-AzureRMWidget.md
-- Syntax missing


where `$service` is the name of your service (*e.g.,* Profile, Compute, Network, etc.) and `$pathToRepo` is the path to the **azure-powershell** repo locally on your machine.

This script can be used for new services looking to create markdown files, or services looking to update their existing markdown files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we suggest a good editor for editing / visualizing markdown?

@markcowl
Copy link
Member

markcowl commented Oct 8, 2016

@cormacpayne Looks liek soem of the help comments havn't been addressed. Is this ready to review otherwise?

Copy link
Member

@markcowl markcowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really nice. A couple of suggested changes

@@ -0,0 +1,22 @@
---
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the module page that is generated by platyPS when the markdown files are initially created. It is used when Update-MarkdownHelpModule is executed.

[Parameter(ParameterSetName="ResourceManager", Mandatory=$True)]
[Parameter(ParameterSetName="ServiceManagement", Mandatory=$True)]
[Parameter(ParameterSetName="Storage", Mandatory=$True)]
[String]$PathToRepo,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that this is a module, you shouldn't need this info, so this can be optional. To get the directory that contains your module, use:

$PSModule = $ExecutionContext.SessionState.Module
$PSModuleRoot = $PSModule.ModuleBase

Using this, we should be able to remove this as a required parameter

[String]$PathToCommandsFolder,

[Parameter(ParameterSetName="FullPath", Mandatory=$True)]
[String]$ModuleName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we infer this from PathToModule?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that these parameter comments apply everywhere

[Parameter(ParameterSetName="ResourceManager", Mandatory=$True)]
[Parameter(ParameterSetName="ServiceManagement", Mandatory=$True)]
[Parameter(ParameterSetName="Storage", Mandatory=$True)]
[String]$PathToRepo,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment

[String]$PathToCommandsFolder,

[Parameter(ParameterSetName="FullPath", Mandatory=$True)]
[String]$ModuleName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment

)

$dlls = @{
"Automation" = "Automation\Microsoft.Azure.Commands.Automation.dll";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

[String]$PathToModule
)

for (;;)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you can use the Get-Item commands to treat paths as files and extract properties, see: https://github.com/Azure/azure-powershell/blob/dev/tools/PublishModules.ps1#L183

[Parameter(ParameterSetName="ResourceManager", Mandatory=$True)]
[Parameter(ParameterSetName="ServiceManagement", Mandatory=$True)]
[Parameter(ParameterSetName="Storage", Mandatory=$True)]
[String]$PathToRepo,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

[String]$PathToHelp,

[Parameter(ParameterSetName="FullPath", Mandatory=$True)]
[String]$ModuleName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please make md changes as suggested in previous review

@cormacpayne
Copy link
Member Author

@markcowl addressed new code review comments. What are the md changes that you suggested in the previous review that were not resolved?

@markcowl markcowl merged commit afa7cb0 into Azure:dev Oct 10, 2016
@cormacpayne cormacpayne deleted the platyps-help branch October 28, 2016 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants