Skip to content

Conversation

teramako
Copy link

PR Summary

This patch fixes a problem with reading and writing syntax parameters in the Maml help.

Fix following issues:

Additionaly, removed no longer needed codes.

PR Context

To fix following issues:

Fix following issues:

MamlWriter:
- generates syntax parameters as wrong order.
  The order should be positional parameters, mandatory parameters, and others

MamlReader:
- PowerShell#816
  - Read `position` attribute correctly. And treat the parameter is positional or not.
  - Read `<command:parameterValue>` correctly as ParameterType. (if `<command:parameterValue>` is not defined, read '<dev:type>`)
    And treat the type is SwitchParameter or not.
- PowerShell#815
  - Fixed problem that `Parameter` instances are registered as duplicately
- Remove property: `Model.SyntaxItem.PositionalParameterKeys`
- Remove field: `Model.SyntaxItem._positionalParameters`
- Remove field: `Model.SyntaxItem._requiredParameters`
- Remove method: `GetParametersInOrder()`
- Remove codes related `SyntaxItem.Parameters`.
  Because all of these are no longer needed for syntax generation.
  - Remove `SyntaxItem._parameterNames`
  - Remove `SyntaxItem._alphabeticOrderParameters`
  - Remove `SyntaxItem.Parameters`
  - Remove `SyntaxItem.ParameterNames`
  - Remove `SyntaxItem.AddParameter()`
- Added code to reset `SyntaxItem.HasCmdletBinding` value to `CommandHelp.HasCmdletBinding` when loading Markdown.
  This is the same behavior as when loading Yaml.
- Fix tests: Since `SyntaxItem.ParameterNames` has been removed,
  differences in `CommandHelp.Syntax.ParameterNames` are no longer reported.
…eter

If the parameter is a SwitchParameter, skip rendering the <command:parameterValue> element.
Instead, use the <dev:type> element to represent the formal parameter type.

This change will result in the following changes in the help display

SYNTAX:
... `[-Confirm <SwichParameter>]` -> ... `[-Confirm]`

PARAMETERS:
`-Confirm [<System.Management.Automation.SwitchParameter>]` -> `-Confirm`
outputs XML like the following:

```xml
<command:parameter attrs="...">
  <!-- ... -->
  <command:parameterValueGroup>
    <command:parameterValue required="false" variableLength="false">Accepted Value 1</command:parameterValue>
    <command:parameterValue required="false" variableLength="false">Accepted Value 2</command:parameterValue>
  </command:parameterValueGroup>
</command:parameter>
```
…ue` always.

This affects to Help display.

Before:
```
PARAMETERS:
    NAME [<Type>]
```

After:
```
PARAMETERS:
    NAME <Type>
```
@teramako
Copy link
Author

Update 2025-09-14

New features:

  • Add <dev:type> in <command:parameterValue> for Maml help generation.
    In order to be able to read the parameter type from the Maml reader.
  • Assign alias values for parameter in MAML help generation
  • Render accepted values in generating Maml help.

Bug fixes:

  • Don't render <command:parameterValue> if the parameter is SwitchParameter.
    This fixes a problem that the syntax parameter have been outputed as [-Flag <SwitchParamerter>] instead of [-Flag]
  • Fix: required attribute of <command:parameterValue> should be true
  • Fix: a problem in which HasCmdletBinding of CommandHelp and HasCmdletBinding of each SytanxItem were out of sync when loading Maml Help.
    This will cause [<CommonParameters>] to be missing from the end of the syntax when exported.

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.

1 participant