Public/ReleaseNotes/ExportMarkDown/Export-MarkDown.ps1
function Export-MarkDown { <# .SYNOPSIS Converts set of ReleaseNotesDataItems to MarkDown. .PARAMETER ExportData Export data prepared by ConvertTo-ExportData. .PARAMETER Path Filename for the exported data to be saved to. .PARAMETER TesterWorkItemTypesHashTable Desired WI types for testers in hash table with format: key = type, value = human friendly name .PARAMETER ManagementWorkItemTypesHashTable Desired WI types for management in hash table with format: key = type, value = human friendly name .PARAMETER Environment Environment name. .PARAMETER UseConstantFileName Flag, whether to always use the same filename. If Path is a folder, uses constant string for the new file. .PARAMETER PassThru Flag, whether return the generated file. .PARAMETER ProgressPreference Determines how PowerShell responds to progress updates generated by a script, cmdlet, or provider, such as the progress bars generated by the Write-Progress cmdlet. #> [CmdletBinding(DefaultParameterSetName = 'List')] param( [PSTypeName('PSTypeNames.AzureDevOpsApi.ExportData')] [Parameter(Mandatory, Position = 1)] [Alias('Data')] $ExportData, $Path = '.\', $TesterWorkItemTypes, $ManagementWorkItemTypes, [string] $TimeZone = 'Central Europe Standard Time', $Environment, [switch] $UseConstantFileName, [switch] $PassThru, [System.Management.Automation.ActionPreference] $ProgressPreference = $PSCmdlet.GetVariableValue('ProgressPreference') ) begin { # Show the progress $activity = "Exporting data" Write-Progress -Activity $activity # Determine the time zone $targetTimeZone = Get-CustomTimeZone -Id $TimeZone # Determine the output file name $file = Export-DetermineOutputFileName ` -ExportData $ExportData ` -Path $Path ` -FileExtension 'md' ` -UseConstantFileName:$UseConstantFileName ` -TimeZone $targetTimeZone # Fix empty parameters if (!$TesterWorkItemTypes) { $TesterWorkItemTypes = @( [PSCustomObject] @{ type = 'bug'; name = "Bugy" }, [PSCustomObject] @{ type = 'requirement'; name = "Requirementy" } ) } if (!$ManagementWorkItemTypes) { $ManagementWorkItemTypes = @( [PSCustomObject] @{ type = 'task'; name = "Tasky" } ) } $AllWorkItemTypes = $TesterWorkItemTypes + $ManagementWorkItemTypes } process { # Convert the DateTo to the target time zone $DateTo = ConvertTo-TimeZoneDateTime ` -Date $ExportData.Release.DateTo ` -TimeZone $targetTimeZone $DateTo = $DateTo.ToString('yyyy-MM-dd') Set-Content -Path $file "---" Add-Content -Path $file "fontsize: 10pt" Add-Content -Path $file "fontfamily: Archivo" Add-Content -Path $file "colorlinks: true" Add-Content -Path $file "documentclass: report" Add-Content -Path $file "papersize: a4" Add-Content -Path $file "toc: true" Add-Content -Path $file "toc-title: Obsah" Add-Content -Path $file "title: |" Add-Content -Path $file " # Release Notes $($ExportData.Release.Project)" Add-Content -Path $file " ### Prostredie: ``$($Environment)``" Add-Content -Path $file " ### Dátum: ``$($DateTo)``" Add-Content -Path $file "---" $null = Export-MarkDownSection ` -ExportData $ExportData ` -File $file ` -Header "Otestované a uzavreté" ` -SubHeaders $TesterWorkItemTypes ` -State 'closed' ` -ProgressPreference $ProgressPreference $null = Export-MarkDownSection ` -ExportData $ExportData ` -File $file ` -Header "Na testovanie" ` -SubHeaders $TesterWorkItemTypes ` -State 'resolved' ` -ProgressPreference $ProgressPreference $null = Export-MarkDownSection ` -ExportData $ExportData ` -File $file ` -Header "DokonĨený vývoj" ` -SubHeaders $ManagementWorkItemTypes ` -State 'resolved' ` -ProgressPreference $ProgressPreference $null = Export-MarkDownSection ` -ExportData $ExportData ` -File $file ` -Header "V aktívnom vývoji" ` -SubHeaders $AllWorkItemTypes ` -State 'active' ` -ProgressPreference $ProgressPreference } end { Write-Progress -Activity $activity -Completed } } |