Skip to content

Commit

Permalink
platyps workaround for ProgressAction, fix for notes in Add-AzDataTab…
Browse files Browse the repository at this point in the history
…leEntity
  • Loading branch information
PalmEmanuel committed Dec 30, 2023
1 parent ad3882d commit d24e204
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Docs/Help/Add-AzDataTableEntity.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand All @@ -127,7 +127,7 @@ This cmdlet takes either an array of hashtables or psobjects as input to the Ent
## NOTES
### Regarding Dates, DateTime, and DateTimeOffset
Regarding Dates, DateTime, and DateTimeOffset:
The underlying Azure.Data.Tables SDK expects to work with DateTime fields in UTC format for conversion to DateTimeOffset objects. When submitting a DateTimeOffset object to the SDK, it will be converted to UTC timezone rather than preserving the existing timezone/offset info. Similarly, if a `DateTime` object is submitted in the entity with its Kind set to "local" or "unspecified", the SDK will return an error and state that `Azure SDK requires it to be UTC`. While there isn't any change needed to get `DateTimeOffset` objects to work with AzBobbyTables, the workaround for `DateTime` objects is to set the property to a new `DateTime` object with its `Kind` property set to `Utc`. e.g. `$obj.Time = $obj.Time.ToUniversalFormat()`. [Related issue](https://github.com/Azure/azure-sdk-for-net/issues/30644).

Expand Down
2 changes: 1 addition & 1 deletion Docs/Help/Clear-AzDataTable.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand Down
5 changes: 3 additions & 2 deletions Docs/Help/Get-AzDataTableEntity.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Get-AzDataTableEntity -Context <AzDataTableContext> [-Filter <String>] [-Propert

### Count
```
Get-AzDataTableEntity -Context <AzDataTableContext> [-Count] [<CommonParameters>]
Get-AzDataTableEntity -Context <AzDataTableContext> [-Count]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -186,7 +187,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand Down
2 changes: 1 addition & 1 deletion Docs/Help/New-AzDataTable.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand Down
14 changes: 9 additions & 5 deletions Docs/Help/New-AzDataTableContext.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ Creates a context object with authentication information for the table to operat

### ConnectionString
```
New-AzDataTableContext -TableName <String> -ConnectionString <String> [<CommonParameters>]
New-AzDataTableContext -TableName <String> -ConnectionString <String>
[<CommonParameters>]
```

### SAS
```
New-AzDataTableContext -TableName <String> -SharedAccessSignature <Uri> [<CommonParameters>]
New-AzDataTableContext -TableName <String> -SharedAccessSignature <Uri>
[<CommonParameters>]
```

### Key
Expand All @@ -31,12 +33,14 @@ New-AzDataTableContext -TableName <String> -StorageAccountName <String> -Storage

### Token
```
New-AzDataTableContext -TableName <String> -StorageAccountName <String> -Token <String> [<CommonParameters>]
New-AzDataTableContext -TableName <String> -StorageAccountName <String> -Token <String>
[<CommonParameters>]
```

### ManagedIdentity
```
New-AzDataTableContext -TableName <String> -StorageAccountName <String> [-ManagedIdentity] [<CommonParameters>]
New-AzDataTableContext -TableName <String> -StorageAccountName <String> [-ManagedIdentity]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -200,7 +204,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand Down
2 changes: 1 addition & 1 deletion Docs/Help/Remove-AzDataTable.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand Down
5 changes: 3 additions & 2 deletions Docs/Help/Remove-AzDataTableEntity.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Remove one or more entities from an Azure Table.
## SYNTAX

```
Remove-AzDataTableEntity -Context <AzDataTableContext> -Entity <Object[]> [<CommonParameters>]
Remove-AzDataTableEntity -Context <AzDataTableContext> -Entity <Object[]>
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -85,7 +86,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand Down
5 changes: 3 additions & 2 deletions Docs/Help/Update-AzDataTableEntity.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Update one or more entities in an Azure Table.
## SYNTAX

```
Update-AzDataTableEntity -Context <AzDataTableContext> -Entity <Object[]> [<CommonParameters>]
Update-AzDataTableEntity -Context <AzDataTableContext> -Entity <Object[]>
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -72,7 +73,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand Down
126 changes: 126 additions & 0 deletions Scripts/PlatyPSWorkaround.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Workaround to run post-build to avoid platyPS generating documentation for common parameter ProgressAction
# From issue comment https://github.com/PowerShell/platyPS/issues/595#issuecomment-1850775410
function Remove-CommonParameterFromMarkdown {
<#
.SYNOPSIS
Remove a PlatyPS generated parameter block.
.DESCRIPTION
Removes parameter block for the provided parameter name from the markdown file provided.
#>
param(
[Parameter(Mandatory)]
[string[]]
$Path,

[Parameter(Mandatory = $false)]
[string[]]
$ParameterName = @('ProgressAction')
)
$ErrorActionPreference = 'Stop'
foreach ($p in $Path) {
$content = (Get-Content -Path $p -Raw).TrimEnd()
$updateFile = $false
foreach ($param in $ParameterName) {
if (-not ($Param.StartsWith('-'))) {
$param = "-$($param)"
}
# Remove the parameter block
$pattern = "(?m)^### $param\r?\n[\S\s]*?(?=#{2,3}?)"
$newContent = $content -replace $pattern, ''
# Remove the parameter from the syntax block
$pattern = " \[$param\s?.*?]"
$newContent = $newContent -replace $pattern, ''
if ($null -ne (Compare-Object -ReferenceObject $content -DifferenceObject $newContent)) {
Write-Verbose "Added $param to $p"
# Update file content
$content = $newContent
$updateFile = $true
}
}
# Save file if content has changed
if ($updateFile) {
$newContent | Out-File -Encoding utf8 -FilePath $p
Write-Verbose "Updated file: $p"
}
}
return
}

function Add-MissingCommonParameterToMarkdown {
param(
[Parameter(Mandatory)]
[string[]]
$Path,

[Parameter(Mandatory = $false)]
[string[]]
$ParameterName = @('ProgressAction')
)
$ErrorActionPreference = 'Stop'
foreach ($p in $Path) {
$content = (Get-Content -Path $p -Raw).TrimEnd()
$updateFile = $false
foreach ($NewParameter in $ParameterName) {
if (-not ($NewParameter.StartsWith('-'))) {
$NewParameter = "-$($NewParameter)"
}
$pattern = '(?m)^This cmdlet supports the common parameters:(.+?)\.'
$replacement = {
$Params = $_.Groups[1].Captures[0].ToString() -split ' '
$CommonParameters = @()
foreach ($CommonParameter in $Params) {
if ($CommonParameter.StartsWith('-')) {
if ($CommonParameter.EndsWith(',')) {
$CleanParam = $CommonParameter.Substring(0, $CommonParameter.Length -1)
} elseif ($p.EndsWith('.')) {
$CleanParam = $CommonParameter.Substring(0, $CommonParameter.Length -1)
} else{
$CleanParam = $CommonParameter
}
$CommonParameters += $CleanParam
}
}
if ($NewParameter -notin $CommonParameters) {
$CommonParameters += $NewParameter
}
$CommonParameters = ($CommonParameters | Sort-Object)
$CommonParameters[-1] = "and $($CommonParameters[-1])."
return "This cmdlet supports the common parameters: " + (($CommonParameters) -join ', ')
}
$newContent = $content -replace $pattern, $replacement
if ($null -ne (Compare-Object -ReferenceObject $content -DifferenceObject $newContent)) {
Write-Verbose "Added $NewParameter to $p"
$updateFile = $true
$content = $newContent
}
}
# Save file if content has changed
if ($updateFile) {
$newContent | Out-File -Encoding utf8 -FilePath $p
Write-Verbose "Updated file: $p"
}
}
return
}

function Repair-PlatyPSMarkdown {
param(
[Parameter(Mandatory)]
[string[]]
$Path,

[Parameter()]
[string[]]
$ParameterName = @('ProgressAction')
)
$ErrorActionPreference = 'Stop'
$Parameters = @{
Path = $Path
ParameterName = $ParameterName
}
$null = Remove-CommonParameterFromMarkdown @Parameters
$null = Add-MissingCommonParameterToMarkdown @Parameters
return
}
5 changes: 5 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ Pop-Location

# Run markdown file updates and tests in separate PowerShell sessions to avoid module load assembly locking
& pwsh -c "Import-Module '$OutDir\$ModuleName.psd1'; Update-MarkdownHelpModule -Path '$PSScriptRoot\Docs\Help'"

# Workaround to run post-build to avoid platyPS generating documentation for common parameter ProgressAction
. "$PSScriptRoot\Scripts\PlatyPSWorkaround.ps1"
Repair-PlatyPSMarkdown -Path (Get-ChildItem "$PSScriptRoot\Docs\Help") -ParameterName 'ProgressAction'

if ($RunTests -ne 'None') {
& pwsh -c ".\Tests\TestRunner.ps1 -SkipIntegration:`$$($RunTests -eq 'SkipIntegration')"
}
Expand Down

0 comments on commit d24e204

Please sign in to comment.