From 12b724009d1b2d43e08450681d11b9cb6c4aee7d Mon Sep 17 00:00:00 2001 From: Jonathan Colon Date: Sat, 25 Apr 2026 15:46:30 -0400 Subject: [PATCH 01/14] chore: update module version to 1.0.7 and enhance Add-HtmlSignatureTable with background color parameters Co-authored-by: Copilot --- .../AsBuiltReport.Diagram.psd1 | 2 +- .../Src/Private/Add-HtmlSignatureTable.ps1 | 26 ++++++++++++++----- CHANGELOG.md | 7 +++++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/AsBuiltReport.Diagram/AsBuiltReport.Diagram.psd1 b/AsBuiltReport.Diagram/AsBuiltReport.Diagram.psd1 index a5b46fb..52ead84 100644 --- a/AsBuiltReport.Diagram/AsBuiltReport.Diagram.psd1 +++ b/AsBuiltReport.Diagram/AsBuiltReport.Diagram.psd1 @@ -12,7 +12,7 @@ RootModule = 'AsBuiltReport.Diagram.psm1' # Version number of this module. - ModuleVersion = '1.0.6' + ModuleVersion = '1.0.7' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 b/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 index 63e6ca4..6f141f0 100644 --- a/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 +++ b/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 @@ -222,6 +222,18 @@ function Add-HtmlSignatureTable { )] [string]$TableBorderColor = '#000000', + [Parameter( + Mandatory = $false, + HelpMessage = 'Allow to set a table background color' + )] + [string] $TableBackgroundColor = '#FFFFFF', + + [Parameter( + Mandatory = $false, + HelpMessage = 'Allow to set a cell background color' + )] + [string] $CellBackgroundColor = '#FFFFFF', + [Parameter( Mandatory = $false, HelpMessage = 'Used inside Graphviz to modify the head or tail of an edge, so that the end attaches directly to the object' @@ -245,9 +257,9 @@ function Add-HtmlSignatureTable { $FormattedRow = Format-HtmlFontProperty -Text $Row -FontSize $FontSize -FontColor $FontColor -FontBold:$FontBold -FontItalic:$FontItalic -FontUnderline:$FontUnderline -FontName $FontName -FontSubscript:$FontSubscript -FontSuperscript:$FontSuperscript -FontStrikeThrough:$FontStrikeThrough -FontOverline:$FontOverline if ($NoFontBold) { - $TR += '{1}' -f $Align, $FormattedRow + $TR += '{2}' -f $CellBackgroundColor, $Align, $FormattedRow } else { - $TR += '{1}' -f $Align, $FormattedRow + $TR += '{2}' -f $CellBackgroundColor, $Align, $FormattedRow } } @@ -255,28 +267,28 @@ function Add-HtmlSignatureTable { if ($IconDebug) { $TRContent = '{1}{2}' -f $Align, $ICON, $TR - Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder + Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBackgroundColor $TableBackgroundColor-TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder } else { if ($ImageSize) { $TRContent = '{4}' -f $Align, $ImageSize.Width, $ImageSize.Height, $ICON, $TR - Format-HtmlTable -TableStyle $TableBorderStyle -TableBorder $TableBorder -TableBorderColor $TableBorderColor -CellBorder 0 -TableRowContent $TRContent + Format-HtmlTable -TableStyle $TableBorderStyle -TableBackgroundColor $TableBackgroundColor -TableBorder $TableBorder -TableBorderColor $TableBorderColor -CellBorder 0 -TableRowContent $TRContent } else { $TRContent = '{2}' -f $Align, $ICON, $TR - Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBorderColor $TableBorderColor -TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder + Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBackgroundColor $TableBackgroundColor -TableBorderColor $TableBorderColor -TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder } } } else { if ($IconDebug) { $TRContent = $TR - Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBorderColor $TableBorderColor -TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder + Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBackgroundColor $TableBackgroundColor -TableBorderColor $TableBorderColor -TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder } else { $TRContent = $TR - Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBorderColor $TableBorderColor -TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder + Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBackgroundColor $TableBackgroundColor -TableBorderColor $TableBorderColor -TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder } } } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e963a38..81118a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.7] - Unreleased + +### :arrows_clockwise: Changed + +- Update module version to v1.0.7 +- Enhance Add-HtmlSignatureTable with background color parameters + ## [1.0.6] - 2026-04-23 ### :arrows_clockwise: Changed From 990985347bf7e4a31b80e87ee95a24e030629ee9 Mon Sep 17 00:00:00 2001 From: Jonathan Colon Date: Sat, 25 Apr 2026 16:12:24 -0400 Subject: [PATCH 02/14] refactor: streamline Add-HtmlSignatureTable function and improve logo handling --- .../Src/Private/Add-HtmlSignatureTable.ps1 | 70 ++++++++++--------- CHANGELOG.md | 1 + 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 b/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 index 6f141f0..ac7d59a 100644 --- a/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 +++ b/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 @@ -241,54 +241,60 @@ function Add-HtmlSignatureTable { [string] $Port = 'EdgeDot' ) - if ($ImagesObj[$Logo]) { - $ICON = $ImagesObj[$Logo] - } else { $ICON = $false } + $ICON = if ($ImagesObj[$Logo]) { $ImagesObj[$Logo] } else { $null } + $ImageSize = $null if ($ImageSizePercent -lt 100) { if (-not $IconPath) { throw 'IconPath is required when ImageSizePercent is less than 100.' } + if (-not $ICON) { + throw 'A valid Logo must be resolved from ImagesObj when ImageSizePercent is less than 100.' + } $ImageSize = Get-ImagePercent -ImageInput (Join-Path -Path $IconPath -Child $ICON) -Percent $ImageSizePercent } - $TR = '' - foreach ($Row in $Rows) { - $FormattedRow = Format-HtmlFontProperty -Text $Row -FontSize $FontSize -FontColor $FontColor -FontBold:$FontBold -FontItalic:$FontItalic -FontUnderline:$FontUnderline -FontName $FontName -FontSubscript:$FontSubscript -FontSuperscript:$FontSuperscript -FontStrikeThrough:$FontStrikeThrough -FontOverline:$FontOverline + $fontParams = @{ + FontSize = $FontSize + FontColor = $FontColor + FontBold = $FontBold + FontItalic = $FontItalic + FontUnderline = $FontUnderline + FontName = $FontName + FontSubscript = $FontSubscript + FontSuperscript = $FontSuperscript + FontStrikeThrough = $FontStrikeThrough + FontOverline = $FontOverline + } - if ($NoFontBold) { - $TR += '{2}' -f $CellBackgroundColor, $Align, $FormattedRow - } else { - $TR += '{2}' -f $CellBackgroundColor, $Align, $FormattedRow - } + $tableParams = @{ + Port = $Port + TableStyle = $TableStyle + TableBackgroundColor = $TableBackgroundColor + TableBorderColor = $TableBorderColor + TableBorder = $TableBorder + CellBorder = $CellBorder + CellSpacing = $CellSpacing + CellPadding = $CellPadding } + $TR = ($Rows | ForEach-Object { + $FormattedRow = Format-HtmlFontProperty -Text $_ @fontParams + '{2}' -f $CellBackgroundColor, $Align, $FormattedRow + }) -join '' + if ($ICON) { if ($IconDebug) { $TRContent = '{1}{2}' -f $Align, $ICON, $TR - - Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBackgroundColor $TableBackgroundColor-TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder + Format-HtmlTable @tableParams -TableRowContent $TRContent + } elseif ($ImageSize) { + $TRContent = '{4}' -f $Align, $ImageSize.Width, $ImageSize.Height, $ICON, $TR + Format-HtmlTable -TableStyle $TableStyle -TableBackgroundColor $TableBackgroundColor -TableBorder $TableBorder -TableBorderColor $TableBorderColor -CellBorder 0 -TableRowContent $TRContent } else { - if ($ImageSize) { - $TRContent = '{4}' -f $Align, $ImageSize.Width, $ImageSize.Height, $ICON, $TR - - Format-HtmlTable -TableStyle $TableBorderStyle -TableBackgroundColor $TableBackgroundColor -TableBorder $TableBorder -TableBorderColor $TableBorderColor -CellBorder 0 -TableRowContent $TRContent - - } else { - $TRContent = '{2}' -f $Align, $ICON, $TR - - Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBackgroundColor $TableBackgroundColor -TableBorderColor $TableBorderColor -TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder - } + $TRContent = '{2}' -f $Align, $ICON, $TR + Format-HtmlTable @tableParams -TableRowContent $TRContent } } else { - if ($IconDebug) { - $TRContent = $TR - - Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBackgroundColor $TableBackgroundColor -TableBorderColor $TableBorderColor -TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder - } else { - $TRContent = $TR - - Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBackgroundColor $TableBackgroundColor -TableBorderColor $TableBorderColor -TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder - } + Format-HtmlTable @tableParams -TableRowContent $TR } } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 81118a6..9a55a45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update module version to v1.0.7 - Enhance Add-HtmlSignatureTable with background color parameters +- refactor: streamline Add-HtmlSignatureTable function and improve logo handling ## [1.0.6] - 2026-04-23 From 5c3f07e897771b1172ab2b03985767944cb31410 Mon Sep 17 00:00:00 2001 From: Jonathan Colon Date: Sat, 25 Apr 2026 16:17:15 -0400 Subject: [PATCH 03/14] refactor: optimize Add-HtmlLabel function for improved readability and maintainability --- .../Src/Private/Add-HtmlLabel.ps1 | 101 ++++++++++-------- CHANGELOG.md | 1 + 2 files changed, 56 insertions(+), 46 deletions(-) diff --git a/AsBuiltReport.Diagram/Src/Private/Add-HtmlLabel.ps1 b/AsBuiltReport.Diagram/Src/Private/Add-HtmlLabel.ps1 index f0fc39a..7d0308d 100644 --- a/AsBuiltReport.Diagram/Src/Private/Add-HtmlLabel.ps1 +++ b/AsBuiltReport.Diagram/Src/Private/Add-HtmlLabel.ps1 @@ -281,71 +281,80 @@ function Add-HtmlLabel { [string] $Port = 'EdgeDot' ) - if ($IconType -eq 'NoIcon') { - $ICON = 'NoIcon' - } elseif ($ImagesObj[$IconType]) { - $ICON = $ImagesObj[$IconType] - } else { $ICON = 'no_icon.png' } + $ICON = if ($IconType -eq 'NoIcon') { 'NoIcon' } + elseif ($ImagesObj[$IconType]) { $ImagesObj[$IconType] } + else { 'no_icon.png' } - if ($ImageSizePercent -lt 100) { + $CalculatedImageSize = $null + if ($ImageSizePercent -lt 100 -and $ICON -ne 'NoIcon') { if (-not $IconPath) { throw 'IconPath is required when ImageSizePercent is less than 100.' } $CalculatedImageSize = Get-ImagePercent -ImageInput (Join-Path -Path $IconPath -Child $ICON) -Percent $ImageSizePercent } - $FormattedLabel = Format-HtmlFontProperty -Text $Label -FontSize $FontSize -FontColor $FontColor -FontBold:$FontBold -FontItalic:$FontItalic -FontUnderline:$FontUnderline -FontName $FontName -FontSubscript:$FontSubscript -FontSuperscript:$FontSuperscript -FontStrikeThrough:$FontStrikeThrough -FontOverline:$FontOverline - - if (-not $SubgraphLabel) { - - if ($IconDebug) { - $TRContent = '{1} Logo{5}DraftMode ON' -f $Align, $ICON, $FontName, $FontColor, $FontSize, $Label - - Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder - } elseif ($ICON -ne 'NoIcon') { - if ($IconWidth -and $IconHeight) { - $TRContent = '{5}' -f $Align, $CellBackgroundColor, $IconWidth, $IconHeight, $ICON, $FormattedLabel - - Format-HtmlTable -Port $Port -TableBackgroundColor $TableBackgroundColor -TableStyle $TableStyle -TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder - } elseif ($CalculatedImageSize) { - $TRContent = '{5}' -f $Align, $CellBackgroundColor, $CalculatedImageSize.Width, $CalculatedImageSize.Height, $ICON, $FormattedLabel - - Format-HtmlTable -Port $Port -TableBackgroundColor $TableBackgroundColor -TableStyle $TableStyle -TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder - } else { - $TRContent = '{3}' -f $Align, $CellBackgroundColor, $ICON, $FormattedLabel - - Format-HtmlTable -Port $Port -TableBackgroundColor $TableBackgroundColor -TableStyle $TableStyle -TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder - } - } else { - $TRContent = '{2}' -f $Align, $CellBackgroundColor, $FormattedLabel - - Format-HtmlTable -Port $Port -TableBackgroundColor $TableBackgroundColor -TableStyle $TableStyle -TableBorder $TableBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent -CellBorder $CellBorder - } + $fontParams = @{ + FontSize = $FontSize + FontColor = $FontColor + FontBold = $FontBold + FontItalic = $FontItalic + FontUnderline = $FontUnderline + FontName = $FontName + FontSubscript = $FontSubscript + FontSuperscript = $FontSuperscript + FontStrikeThrough = $FontStrikeThrough + FontOverline = $FontOverline + } + $FormattedLabel = Format-HtmlFontProperty -Text $Label @fontParams + + $effectiveCellSpacing = if ($SubgraphLabel) { $SubgraphCellSpacing } else { $CellSpacing } + $effectiveCellPadding = if ($SubgraphLabel) { $SubgraphCellPadding } else { $CellPadding } + + # Base table params shared by all branches; TableBackgroundColor is added for non-debug branches only. + $baseTableParams = @{ + Port = $Port + TableStyle = $TableStyle + TableBorder = $TableBorder + CellBorder = $CellBorder + CellSpacing = $effectiveCellSpacing + CellPadding = $effectiveCellPadding } - if ($SubgraphLabel) { - if ($IconDebug) { + if ($IconDebug) { + if ($SubgraphLabel) { $TRContent = '{1} Logo{2}' -f $Align, $ICON, $FormattedLabel - - Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBorder $TableBorder -CellSpacing $SubgraphCellSpacing -CellPadding $SubgraphCellPadding -TableRowContent $TRContent -CellBorder $CellBorder - } elseif ($ICON -ne 'NoIcon') { + } else { + $TRContent = '{1} Logo{5}DraftMode ON' -f $Align, $ICON, $FontName, $FontColor, $FontSize, $Label + } + Format-HtmlTable @baseTableParams -TableRowContent $TRContent + } elseif ($ICON -ne 'NoIcon') { + if ($SubgraphLabel) { + # Side-by-side layout: icon cell | label cell in same TR. Uses uppercase . if ($IconWidth -and $IconHeight) { $TRContent = '{5}' -f $Align, $CellBackgroundColor, $IconWidth, $IconHeight, $ICON, $FormattedLabel - - Format-HtmlTable -Port $Port -TableBackgroundColor $TableBackgroundColor -TableStyle $TableStyle -TableBorder $TableBorder -CellSpacing $SubgraphCellSpacing -CellPadding $SubgraphCellPadding -TableRowContent $TRContent -CellBorder $CellBorder } elseif ($CalculatedImageSize) { $TRContent = '{5}' -f $Align, $CellBackgroundColor, $CalculatedImageSize.Width, $CalculatedImageSize.Height, $ICON, $FormattedLabel - - Format-HtmlTable -Port $Port -TableBackgroundColor $TableBackgroundColor -TableStyle $TableStyle -TableBorder $TableBorder -CellSpacing $SubgraphCellSpacing -CellPadding $SubgraphCellPadding -TableRowContent $TRContent -CellBorder $CellBorder } else { $TRContent = '{3}' -f $Align, $CellBackgroundColor, $ICON, $FormattedLabel - - Format-HtmlTable -Port $Port -TableBackgroundColor $TableBackgroundColor -TableStyle $TableStyle -TableBorder $TableBorder -CellSpacing $SubgraphCellSpacing -CellPadding $SubgraphCellPadding -TableRowContent $TRContent -CellBorder $CellBorder } } else { + # Stacked layout: icon TR on top, label TR below. Uses lowercase . + if ($IconWidth -and $IconHeight) { + $TRContent = '{5}' -f $Align, $CellBackgroundColor, $IconWidth, $IconHeight, $ICON, $FormattedLabel + } elseif ($CalculatedImageSize) { + $TRContent = '{5}' -f $Align, $CellBackgroundColor, $CalculatedImageSize.Width, $CalculatedImageSize.Height, $ICON, $FormattedLabel + } else { + $TRContent = '{3}' -f $Align, $CellBackgroundColor, $ICON, $FormattedLabel + } + } + Format-HtmlTable @baseTableParams -TableBackgroundColor $TableBackgroundColor -TableRowContent $TRContent + } else { + # NoIcon: attribute order differs intentionally between layouts (preserved from original). + if ($SubgraphLabel) { $TRContent = '{2}' -f $Align, $CellBackgroundColor, $FormattedLabel - - Format-HtmlTable -Port $Port -TableBackgroundColor $TableBackgroundColor -TableStyle $TableStyle -TableBorder $TableBorder -CellSpacing $SubgraphCellSpacing -CellPadding $SubgraphCellPadding -TableRowContent $TRContent -CellBorder $CellBorder + } else { + $TRContent = '{2}' -f $CellBackgroundColor, $Align, $FormattedLabel } + Format-HtmlTable @baseTableParams -TableBackgroundColor $TableBackgroundColor -TableRowContent $TRContent } } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a55a45..180312b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update module version to v1.0.7 - Enhance Add-HtmlSignatureTable with background color parameters - refactor: streamline Add-HtmlSignatureTable function and improve logo handling +- refactor: optimize Add-HtmlLabel function for improved readability and maintainability ## [1.0.6] - 2026-04-23 From e8eafd7e1fc32a6f6d9ba81becbc9f380e400b63 Mon Sep 17 00:00:00 2001 From: Jonathan Colon Date: Sat, 25 Apr 2026 16:23:34 -0400 Subject: [PATCH 04/14] test: update HTML table background color in Add-HtmlSignatureTable tests for consistency --- Tests/Add-HtmlSignatureTable.Tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Add-HtmlSignatureTable.Tests.ps1 b/Tests/Add-HtmlSignatureTable.Tests.ps1 index b9519c8..f2cf9fd 100644 --- a/Tests/Add-HtmlSignatureTable.Tests.ps1 +++ b/Tests/Add-HtmlSignatureTable.Tests.ps1 @@ -18,9 +18,9 @@ Describe Add-HtmlSignatureTable { } It 'Should return a multiple column HTML table with an Logo' { - $HTMLSignaturewithLogo | Should -BeExactly '
Jonathan Colon
Zen PR Solutions
' + $HTMLSignaturewithLogo | Should -BeExactly '
Jonathan Colon
Zen PR Solutions
' } It 'Should return a multiple column HTML table with an Logo in Debug Mode' { - $HTMLSignaturewithLogoDebug | Should -BeExactly '
AsBuiltReport.png
Jonathan Colon
Zen PR Solutions
' + $HTMLSignaturewithLogoDebug | Should -BeExactly '
AsBuiltReport.png
Jonathan Colon
Zen PR Solutions
' } } \ No newline at end of file From c7fd000e01f9a0eb255ea047d6a19566c7df55b7 Mon Sep 17 00:00:00 2001 From: Jonathan Colon Date: Sat, 25 Apr 2026 16:27:06 -0400 Subject: [PATCH 05/14] refactor: simplify AditionalInfo handling and consolidate font parameter usage in Add-HtmlNodeTable function Co-authored-by: Copilot --- .../Src/Private/Add-HtmlNodeTable.ps1 | 200 ++++++------------ CHANGELOG.md | 1 + 2 files changed, 69 insertions(+), 132 deletions(-) diff --git a/AsBuiltReport.Diagram/Src/Private/Add-HtmlNodeTable.ps1 b/AsBuiltReport.Diagram/Src/Private/Add-HtmlNodeTable.ps1 index 5b36f4f..1f5fb2b 100644 --- a/AsBuiltReport.Diagram/Src/Private/Add-HtmlNodeTable.ps1 +++ b/AsBuiltReport.Diagram/Src/Private/Add-HtmlNodeTable.ps1 @@ -445,76 +445,22 @@ function Add-HtmlNodeTable { } if ($AditionalInfo) { - switch ($AditionalInfo.GetType().Name) { - 'Hashtable' { - if ($AditionalInfo) { - $Filter = $AditionalInfo.keys | Select-Object -Unique - $RowsGroupHTs = @() - - foreach ($RepoObj in ($Filter)) { - $RowsGroupHTs += @{ - $RepoObj = $AditionalInfo.$RepoObj - } - } - } - } - - 'OrderedDictionary' { - if ($AditionalInfo) { - $Filter = $AditionalInfo.keys | Select-Object -Unique - $RowsGroupHTs = @() - - foreach ($RepoObj in ($Filter)) { - $RowsGroupHTs += @{ - $RepoObj = $AditionalInfo.$RepoObj - } - } - } - } - - 'Object[]' { - if ($AditionalInfo[0].GetType().Name -eq 'PSCustomObject') { - $Filter = $AditionalInfo | ForEach-Object { $_.PSObject.Properties.name } | Select-Object -Unique - $RowsGroupHTs = @() + $RowsGroupHTs = @() + $isPSCustomObj = $AditionalInfo.GetType().Name -eq 'PSCustomObject' -or + ($AditionalInfo.GetType().Name -eq 'Object[]' -and $AditionalInfo[0].GetType().Name -eq 'PSCustomObject') - foreach ($RepoObj in ($Filter)) { - $RowsGroupHTs += @{ - $RepoObj = $AditionalInfo.$RepoObj - } - } - } else { - $Filter = $AditionalInfo.keys | Select-Object -Unique - $RowsGroupHTs = @() - - foreach ($RepoObj in ($Filter)) { - $RowsGroupHTs += @{ - $RepoObj = $AditionalInfo.$RepoObj - } - } - } - } - - 'PSCustomObject' { - if ($AditionalInfo) { - $Filter = $AditionalInfo | ForEach-Object { $_.PSObject.Properties.name } | Select-Object -Unique - $RowsGroupHTs = @() + $Filter = if ($isPSCustomObj) { + $AditionalInfo | ForEach-Object { $_.PSObject.Properties.name } | Select-Object -Unique + } else { + $AditionalInfo.keys | Select-Object -Unique + } - foreach ($RepoObj in ($Filter)) { - $RowsGroupHTs += @{ - $RepoObj = $AditionalInfo.$RepoObj - } - } - } - } + foreach ($RepoObj in $Filter) { + $RowsGroupHTs += @{ $RepoObj = $AditionalInfo.$RepoObj } } } - # Determine FontBold based on NoFontBold switch - if ($NoFontBold) { - $FontBold = $false - } else { - $FontBold = $true - } + $FontBold = $true if ($ImagesObj) { if ($iconType.Count -gt 1) { @@ -528,10 +474,9 @@ function Add-HtmlNodeTable { } $iconGroup = Split-ArrayElement -inArray $Icon -size $columnSize } else { - # $iconGroup = $iconType if ($ImagesObj[$iconType[0]]) { $Icon = $ImagesObj[$iconType[0]] - } else { $Icon = $false } + } else { $Icon = $null } $iconGroup = $Icon } } @@ -539,7 +484,20 @@ function Add-HtmlNodeTable { if ($SubgraphIconType) { if ($ImagesObj[$SubgraphIconType]) { $SubgraphIcon = $ImagesObj[$SubgraphIconType] - } else { $SubgraphIcon = $false } + } else { $SubgraphIcon = $null } + } + + $fontParams = @{ + FontSize = $FontSize + FontColor = $FontColor + FontBold = $FontBold + FontItalic = $FontItalic + FontUnderline = $FontUnderline + FontName = $FontName + FontSubscript = $FontSubscript + FontSuperscript = $FontSuperscript + FontStrikeThrough = $FontStrikeThrough + FontOverline = $FontOverline } $Number = 0 @@ -560,14 +518,14 @@ function Add-HtmlNodeTable { $TDICON = '' foreach ($Element in $Group[$Number]) { - $FormattedName = Format-HtmlFontProperty -Text $Element -FontSize $FontSize -FontColor $FontColor -FontBold:$FontBold -FontItalic:$FontItalic -FontUnderline:$FontUnderline -FontName $FontName -FontSubscript:$FontSubscript -FontSuperscript:$FontSuperscript -FontStrikeThrough:$FontStrikeThrough -FontOverline:$FontOverline + $FormattedName = Format-HtmlFontProperty @fontParams -Text $Element $TDName += '{2}' -f $Element, $Align, $FormattedName } $TR += '{0}' -f $TDName $TDName = '' - if ($AditionalInfo -or $AditionalInfoOrdered) { + if ($AditionalInfo) { if (($RowsGroupHTs.Keys.Count -le 1 ) -and ($RowsGroupHTs.Values.Count -le 1) -and ($inputObject.Count -le 1)) { # $RowsGroupHT is Single key with Single Values # Keys: Path - Values: C:\Backup @@ -624,7 +582,7 @@ function Add-HtmlNodeTable { while ($Number -ne $Group.Count) { foreach ($Element in $Group[$Number]) { - $FormattedName = Format-HtmlFontProperty -Text $Element -FontSize $FontSize -FontColor $FontColor -FontBold:$FontBold -FontItalic:$FontItalic -FontUnderline:$FontUnderline -FontName $FontName -FontSubscript:$FontSubscript -FontSuperscript:$FontSuperscript -FontStrikeThrough:$FontStrikeThrough -FontOverline:$FontOverline + $FormattedName = Format-HtmlFontProperty @fontParams -Text $Element $TDName += '{2}' -f $Element, $Align, $FormattedName } @@ -633,7 +591,7 @@ function Add-HtmlNodeTable { $TDName = '' - if ($AditionalInfo -or $AditionalInfoOrdered) { + if ($AditionalInfo) { if (($RowsGroupHTs.Keys.Count -le 1 ) -and ($RowsGroupHTs.Values.Count -le 1) -and ($inputObject.Count -le 1)) { # $RowsGroupHT is Single key with Single Values # Keys: Path - Values: C:\Backup @@ -693,7 +651,7 @@ function Add-HtmlNodeTable { foreach ($Element in $Group[$Number]) { # Format the name with the specified font properties - $FormattedName = Format-HtmlFontProperty -Text $Element -FontSize $FontSize -FontColor $FontColor -FontBold:$FontBold -FontItalic:$FontItalic -FontUnderline:$FontUnderline -FontName $FontName -FontSubscript:$FontSubscript -FontSuperscript:$FontSuperscript -FontStrikeThrough:$FontStrikeThrough -FontOverline:$FontOverline + $FormattedName = Format-HtmlFontProperty @fontParams -Text $Element if ($CellBackgroundColor) { $TDName += '{3}' -f $CellBackgroundColor, $Element, $Align, $FormattedName @@ -704,7 +662,7 @@ function Add-HtmlNodeTable { $TR += '{0}' -f $TDName $TDName = '' - if ($AditionalInfo -or $AditionalInfoOrdered) { + if ($AditionalInfo) { if (($RowsGroupHTs.Keys.Count -le 1 ) -and ($RowsGroupHTs.Values.Count -le 1) -and ($inputObject.Count -le 1)) { # $RowsGroupHT is Single key with Single Values # Keys: Path - Values: C:\Backup @@ -757,7 +715,7 @@ function Add-HtmlNodeTable { while ($Number -ne $Group.Count) { foreach ($Element in $Group[$Number]) { # Format the name with the specified font properties - $FormattedName = Format-HtmlFontProperty -Text $Element -FontSize $FontSize -FontColor $FontColor -FontBold:$FontBold -FontItalic:$FontItalic -FontUnderline:$FontUnderline -FontName $FontName -FontSubscript:$FontSubscript -FontSuperscript:$FontSuperscript -FontStrikeThrough:$FontStrikeThrough -FontOverline:$FontOverline + $FormattedName = Format-HtmlFontProperty @fontParams -Text $Element if ($CellBackgroundColor) { $TDName += '{3}' -f $CellBackgroundColor, $Element, $Align, $FormattedName @@ -768,7 +726,7 @@ function Add-HtmlNodeTable { $TR += '{0}' -f $TDName $TDName = '' - if ($AditionalInfo -or $AditionalInfoOrdered) { + if ($AditionalInfo) { if (($RowsGroupHTs.Keys.Count -le 1 ) -and ($RowsGroupHTs.Values.Count -le 1) -and ($inputObject.Count -le 1)) { # $RowsGroupHT is Single key with Single Values # Keys: Path - Values: C:\Backup @@ -777,7 +735,7 @@ function Add-HtmlNodeTable { $TDInfo += '{2}: {3}' -f $Align, $FontSize, [string]$Element.Keys, [string]$Element.values } - $TR += '{0}' -f $TDInfobgcolor + $TR += '{0}' -f $TDInfo $TDInfo = '' } elseif (($RowsGroupHTs.Keys.Count -gt 1) -and ($RowsGroupHTs.Values.Count -gt 1) -and ($inputObject.Count -le 1)) { # $RowsGroupHT is Multiple key and each key have a Single Values @@ -819,75 +777,53 @@ function Add-HtmlNodeTable { # This part set the capability to emulate Graphviz Subgraph if ($Subgraph) { - $FormattedSubGraphLabel = Format-HtmlFontProperty -Text $SubGraphLabel -FontSize $SubgraphLabelFontSize -FontColor $SubgraphLabelFontColor -FontBold:$SubgraphFontBold -FontItalic:$SubgraphFontItalic -FontUnderline:$SubgraphFontUnderline -FontName $SubgraphFontName -FontSubscript:$SubgraphFontSubscript -FontSuperscript:$SubgraphFontSuperscript -FontStrikeThrough:$SubgraphFontStrikeThrough -FontOverline:$SubgraphFontOverline + $subgraphFontParams = @{ + FontSize = $SubgraphLabelFontSize + FontColor = $SubgraphLabelFontColor + FontBold = $SubgraphFontBold + FontItalic = $SubgraphFontItalic + FontUnderline = $SubgraphFontUnderline + FontName = $SubgraphFontName + FontSubscript = $SubgraphFontSubscript + FontSuperscript = $SubgraphFontSuperscript + FontStrikeThrough = $SubgraphFontStrikeThrough + FontOverline = $SubgraphFontOverline + } + $FormattedSubGraphLabel = Format-HtmlFontProperty @subgraphFontParams -Text $SubGraphLabel if ($SubgraphIcon) { if ($IconDebug) { $TDSubgraphIcon = '{6}' -f $SubgraphPort, $Align, $columnSize, $FontName, $FontColor, $SubgraphLabelFontSize, $SubGraphIcon - - $TDSubgraph = '{2}' -f $Align, $columnSize, $FormattedSubGraphLabel - - if ($SubgraphLabelPos -eq 'down') { - $TR += '{0}' -f $TDSubgraphIcon - $TR += '{0}' -f $TDSubgraph - } else { - $TRTemp += '{0}' -f $TDSubgraphIcon - $TRTemp += '{0}' -f $TDSubgraph - $TRTemp += $TR - $TR = $TRTemp - } + } elseif ($SubgraphIconWidth -and $SubgraphIconHeight) { + $TDSubgraphIcon = '' -f $SubgraphPort, $Align, $columnSize, $SubGraphIconWidth, $SubGraphIconHeight, $SubGraphIcon } else { - if ($SubgraphIconWidth -and $SubgraphIconHeight) { - $TDSubgraphIcon = '' -f $SubgraphPort, $Align, $columnSize, $SubGraphIconWidth, $SubGraphIconHeight, $SubGraphIcon - - $TDSubgraph = '{2}' -f $Align, $columnSize, $FormattedSubGraphLabel - - if ($SubgraphLabelPos -eq 'down') { - $TR += '{0}' -f $TDSubgraphIcon - $TR += '{0}' -f $TDSubgraph - } else { - $TRTemp += '{0}' -f $TDSubgraphIcon - $TRTemp += '{0}' -f $TDSubgraph - $TRTemp += $TR - $TR = $TRTemp - } - } else { - $TDSubgraphIcon = '' -f $SubgraphPort, $Align, $columnSize, $SubGraphIcon + $TDSubgraphIcon = '' -f $SubgraphPort, $Align, $columnSize, $SubGraphIcon + } - $TDSubgraph = '{2}' -f $Align, $columnSize, $FormattedSubGraphLabel + $TDSubgraph = '{2}' -f $Align, $columnSize, $FormattedSubGraphLabel - if ($SubgraphLabelPos -eq 'down') { - $TR += '{0}' -f $TDSubgraphIcon - $TR += '{0}' -f $TDSubgraph - } else { - $TRTemp += '{0}' -f $TDSubgraphIcon - $TRTemp += '{0}' -f $TDSubgraph - $TRTemp += $TR - $TR = $TRTemp - } - } + if ($SubgraphLabelPos -eq 'down') { + $TR += '{0}' -f $TDSubgraphIcon + $TR += '{0}' -f $TDSubgraph + } else { + $TRTemp += '{0}' -f $TDSubgraphIcon + $TRTemp += '{0}' -f $TDSubgraph + $TRTemp += $TR + $TR = $TRTemp } } else { if ($IconDebug) { $TDSubgraph = '{6}' -f $SubgraphPort, $Align, $columnSize, $FontName, $SubgraphLabelFontSize, $FontColor, [string]$SubgraphLabel - - if ($SubgraphLabelPos -eq 'down') { - $TR += '{0}' -f $TDSubgraph - } else { - $TRTemp = '{0}' -f $TDSubgraph - $TRTemp += $TR - $TR = $TRTemp - } } else { $TDSubgraph = '{3}' -f $SubgraphPort, $Align, $columnSize, $FormattedSubGraphLabel + } - if ($SubgraphLabelPos -eq 'down') { - $TR += '{0}' -f $TDSubgraph - } else { - $TRTemp = '{0}' -f $TDSubgraph - $TRTemp += $TR - $TR = $TRTemp - } + if ($SubgraphLabelPos -eq 'down') { + $TR += '{0}' -f $TDSubgraph + } else { + $TRTemp = '{0}' -f $TDSubgraph + $TRTemp += $TR + $TR = $TRTemp } } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 180312b..e962aca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Enhance Add-HtmlSignatureTable with background color parameters - refactor: streamline Add-HtmlSignatureTable function and improve logo handling - refactor: optimize Add-HtmlLabel function for improved readability and maintainability +- refactor: simplify AditionalInfo handling and consolidate font parameter usage in Add-HtmlNodeTable function ## [1.0.6] - 2026-04-23 From 90a24f365bd2f90ce0b91c7d6856545b5f080d45 Mon Sep 17 00:00:00 2001 From: Jonathan Colon Date: Sat, 25 Apr 2026 16:27:26 -0400 Subject: [PATCH 06/14] refactor: improve formatting consistency in Add-HtmlNodeTable function --- .../Src/Private/Add-HtmlNodeTable.ps1 | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/AsBuiltReport.Diagram/Src/Private/Add-HtmlNodeTable.ps1 b/AsBuiltReport.Diagram/Src/Private/Add-HtmlNodeTable.ps1 index 1f5fb2b..5215f85 100644 --- a/AsBuiltReport.Diagram/Src/Private/Add-HtmlNodeTable.ps1 +++ b/AsBuiltReport.Diagram/Src/Private/Add-HtmlNodeTable.ps1 @@ -447,7 +447,7 @@ function Add-HtmlNodeTable { if ($AditionalInfo) { $RowsGroupHTs = @() $isPSCustomObj = $AditionalInfo.GetType().Name -eq 'PSCustomObject' -or - ($AditionalInfo.GetType().Name -eq 'Object[]' -and $AditionalInfo[0].GetType().Name -eq 'PSCustomObject') + ($AditionalInfo.GetType().Name -eq 'Object[]' -and $AditionalInfo[0].GetType().Name -eq 'PSCustomObject') $Filter = if ($isPSCustomObj) { $AditionalInfo | ForEach-Object { $_.PSObject.Properties.name } | Select-Object -Unique @@ -488,16 +488,16 @@ function Add-HtmlNodeTable { } $fontParams = @{ - FontSize = $FontSize - FontColor = $FontColor - FontBold = $FontBold - FontItalic = $FontItalic - FontUnderline = $FontUnderline - FontName = $FontName - FontSubscript = $FontSubscript - FontSuperscript = $FontSuperscript + FontSize = $FontSize + FontColor = $FontColor + FontBold = $FontBold + FontItalic = $FontItalic + FontUnderline = $FontUnderline + FontName = $FontName + FontSubscript = $FontSubscript + FontSuperscript = $FontSuperscript FontStrikeThrough = $FontStrikeThrough - FontOverline = $FontOverline + FontOverline = $FontOverline } $Number = 0 @@ -778,16 +778,16 @@ function Add-HtmlNodeTable { # This part set the capability to emulate Graphviz Subgraph if ($Subgraph) { $subgraphFontParams = @{ - FontSize = $SubgraphLabelFontSize - FontColor = $SubgraphLabelFontColor - FontBold = $SubgraphFontBold - FontItalic = $SubgraphFontItalic - FontUnderline = $SubgraphFontUnderline - FontName = $SubgraphFontName - FontSubscript = $SubgraphFontSubscript - FontSuperscript = $SubgraphFontSuperscript + FontSize = $SubgraphLabelFontSize + FontColor = $SubgraphLabelFontColor + FontBold = $SubgraphFontBold + FontItalic = $SubgraphFontItalic + FontUnderline = $SubgraphFontUnderline + FontName = $SubgraphFontName + FontSubscript = $SubgraphFontSubscript + FontSuperscript = $SubgraphFontSuperscript FontStrikeThrough = $SubgraphFontStrikeThrough - FontOverline = $SubgraphFontOverline + FontOverline = $SubgraphFontOverline } $FormattedSubGraphLabel = Format-HtmlFontProperty @subgraphFontParams -Text $SubGraphLabel From 7dbd00d0a4e52d905a13e7f1806f57e7d38604b6 Mon Sep 17 00:00:00 2001 From: Jonathan Colon Date: Sat, 25 Apr 2026 16:34:32 -0400 Subject: [PATCH 07/14] refactor: add IconPath parameter and improve icon handling in Add-HtmlSubGraph function --- .../Src/Private/Add-HtmlSubGraph.ps1 | 115 +++++++++--------- CHANGELOG.md | 1 + 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/AsBuiltReport.Diagram/Src/Private/Add-HtmlSubGraph.ps1 b/AsBuiltReport.Diagram/Src/Private/Add-HtmlSubGraph.ps1 index 93a6dc2..ed79799 100644 --- a/AsBuiltReport.Diagram/Src/Private/Add-HtmlSubGraph.ps1 +++ b/AsBuiltReport.Diagram/Src/Private/Add-HtmlSubGraph.ps1 @@ -275,6 +275,12 @@ function Add-HtmlSubGraph { )] [int] $IconHeight = 40, + [Parameter( + Mandatory = $false, + HelpMessage = 'Path to the directory containing icon image files' + )] + [string] $IconPath, + [Parameter( Mandatory, HelpMessage = 'Specifies the name of the node.' @@ -303,15 +309,14 @@ function Add-HtmlSubGraph { if ($ImagesObj -and $ImagesObj[$IconType]) { $Icon = $ImagesObj[$IconType] - } else { $Icon = $false } + } else { $Icon = $null } # Set the image size if ImageSizePercent is less than 100 - if ($ImageSizePercent -lt 100) { + if ($Icon -and $ImageSizePercent -lt 100) { if (-not $IconPath) { throw 'IconPath is required when ImageSizePercent is less than 100.' } $ImageSize = Get-ImagePercent -ImageInput (Join-Path -Path $IconPath -Child $Icon) -Percent $ImageSizePercent - $IconWidth = $ImageSize.Width $IconHeight = $ImageSize.Height } @@ -323,7 +328,6 @@ function Add-HtmlSubGraph { } $Number = 0 - $TD = '' $TR = '' while ($Number -ne $Group.Count) { @@ -335,71 +339,66 @@ function Add-HtmlSubGraph { $Number++ } - # Format the name with the specified font properties - $FormattedLabel = Format-HtmlFontProperty -Text $Label -FontSize $FontSize -FontColor $FontColor -FontBold:$FontBold -FontItalic:$FontItalic -FontUnderline:$FontUnderline -FontName $FontName -FontSubscript:$FontSubscript -FontSuperscript:$FontSuperscript -FontStrikeThrough:$FontStrikeThrough -FontOverline:$FontOverline + $fontParams = @{ + FontSize = $FontSize + FontColor = $FontColor + FontBold = $FontBold + FontItalic = $FontItalic + FontUnderline = $FontUnderline + FontName = $FontName + FontSubscript = $FontSubscript + FontSuperscript = $FontSuperscript + FontStrikeThrough = $FontStrikeThrough + FontOverline = $FontOverline + } + $FormattedLabel = Format-HtmlFontProperty @fontParams -Text $Label - # This part set the capability to emulate Graphviz Subgraph - if ($IconDebug) { - if ($Icon) { + # Build subgraph icon/label rows and prepend or append based on LabelPos + $TRTemp = '' + if ($Icon) { + if ($IconDebug) { $TDSubgraphIcon = '{5}' -f $Align, $columnSize, $fontName, $fontColor, $fontSize, $Icon $TDSubgraph = '{2}' -f $Align, $columnSize, $FormattedLabel - - if ($LabelPos -eq 'down') { - $TR += '{0}' -f $TDSubgraphIcon - $TR += '{0}' -f $TDSubgraph - } else { - $TRTemp += '{0}' -f $TDSubgraphIcon - $TRTemp += '{0}' -f $TDSubgraph - $TRTemp += $TR - $TR = $TRTemp - } } else { - $TDSubgraph = '{2}' -f $Align, $columnSize, $FormattedLabel - if ($LabelPos -eq 'down') { - $TR += '{0}' -f $TDSubgraph - } else { - $TRTemp = '{0}' -f $TDSubgraph - $TRTemp += $TR - $TR = $TRTemp - } - } - } else { - if ($Icon) { $TDSubgraphIcon = '' -f $Align, $columnSize, $Icon, $IconWidth, $IconHeight $TDSubgraph = '{2}' -f $Align, $columnSize, $FormattedLabel - - if ($LabelPos -eq 'down') { - $TR += '{0}' -f $TDSubgraphIcon - $TR += '{0}' -f $TDSubgraph - } else { - $TRTemp += '{0}' -f $TDSubgraphIcon - $TRTemp += '{0}' -f $TDSubgraph - $TRTemp += $TR - $TR = $TRTemp - } + } + if ($LabelPos -eq 'down') { + $TR += '{0}' -f $TDSubgraphIcon + $TR += '{0}' -f $TDSubgraph } else { - $TDSubgraph = '{2}' -f $Align, $columnSize, $FormattedLabel - if ($LabelPos -eq 'down') { - $TR += '{0}' -f $TDSubgraph - } else { - $TRTemp = '{0}' -f $TDSubgraph - $TRTemp += $TR - $TR = $TRTemp - } + $TRTemp += '{0}' -f $TDSubgraphIcon + $TRTemp += '{0}' -f $TDSubgraph + $TRTemp += $TR + $TR = $TRTemp + } + } else { + $TDSubgraph = '{2}' -f $Align, $columnSize, $FormattedLabel + if ($LabelPos -eq 'down') { + $TR += '{0}' -f $TDSubgraph + } else { + $TRTemp = '{0}' -f $TDSubgraph + $TRTemp += $TR + $TR = $TRTemp } } + $tableParams = @{ + TableStyle = $TableStyle + TableBackgroundColor = $TableBackgroundColor + CellSpacing = $CellSpacing + CellPadding = $CellPadding + TableRowContent = $TR + } if ($IconDebug) { - - $HTML = Format-HtmlTable -TableStyle $TableStyle -TableBackgroundColor $TableBackgroundColor -TableBorderColor 'red' -CellBorder 1 -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TR - - Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) - + $tableParams.TableBorderColor = 'red' + $tableParams.TableBorder = 1 + $tableParams.CellBorder = 1 } else { - - $HTML = Format-HtmlTable -TableBorder $TableBorder -TableStyle $TableStyle -TableBackgroundColor $TableBackgroundColor -TableBorderColor $TableBorderColor -CellBorder $CellBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TR - - Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) - + $tableParams.TableBorderColor = $TableBorderColor + $tableParams.TableBorder = $TableBorder + $tableParams.CellBorder = $CellBorder } + $HTML = Format-HtmlTable @tableParams + Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e962aca..7ad9e00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - refactor: streamline Add-HtmlSignatureTable function and improve logo handling - refactor: optimize Add-HtmlLabel function for improved readability and maintainability - refactor: simplify AditionalInfo handling and consolidate font parameter usage in Add-HtmlNodeTable function +- refactor: add IconPath parameter and improve icon handling in Add-HtmlSubGraph function ## [1.0.6] - 2026-04-23 From d8b3893bdcb7c247338f80511a5a6ac09a391c2a Mon Sep 17 00:00:00 2001 From: Jonathan Colon Date: Sat, 25 Apr 2026 17:03:27 -0400 Subject: [PATCH 08/14] refactor: streamline font parameter handling and improve subgraph icon logic in Add-HtmlTable function --- .../Src/Private/Add-HtmlTable.ps1 | 142 +++++++++--------- CHANGELOG.md | 1 + 2 files changed, 68 insertions(+), 75 deletions(-) diff --git a/AsBuiltReport.Diagram/Src/Private/Add-HtmlTable.ps1 b/AsBuiltReport.Diagram/Src/Private/Add-HtmlTable.ps1 index e352bda..0009394 100644 --- a/AsBuiltReport.Diagram/Src/Private/Add-HtmlTable.ps1 +++ b/AsBuiltReport.Diagram/Src/Private/Add-HtmlTable.ps1 @@ -402,7 +402,7 @@ function Add-HtmlTable { ## Getting the Subgraph Icon from the ImagesObj Hashtable if ($ImagesObj -and $ImagesObj[$SubgraphIconType]) { $SubgraphIcon = $ImagesObj[$SubgraphIconType] - } else { $SubgraphIcon = $false } + } else { $SubgraphIcon = $null } ## This part split the array in groups based on the ColumnSize value if ($Rows.Count -le 1) { @@ -411,16 +411,25 @@ function Add-HtmlTable { $Group = Split-ArrayElement -inArray $Rows -size $ColumnSize } - # Index to track the number of rows processed $Number = 0 - $TD = '' $TR = '' + $fontParams = @{ + FontSize = $FontSize + FontColor = $FontColor + FontBold = $FontBold + FontItalic = $FontItalic + FontUnderline = $FontUnderline + FontName = $FontName + FontSubscript = $FontSubscript + FontSuperscript = $FontSuperscript + FontStrikeThrough = $FontStrikeThrough + FontOverline = $FontOverline + } # Create the table and splitting elements based on the ColumnSize value while ($Number -ne $Group.Count) { foreach ($Element in $Group[$Number]) { - $FormattedElement = Format-HtmlFontProperty -Text $Element -FontSize $Fontsize -FontColor $FontColor -FontBold:$FontBold -FontItalic:$FontItalic -FontUnderline:$FontUnderline -FontName $FontName -FontSubscript:$FontSubscript -FontSuperscript:$FontSuperscript -FontStrikeThrough:$FontStrikeThrough -FontOverline:$FontOverline - + $FormattedElement = Format-HtmlFontProperty @fontParams -Text $Element $TD += '{1}' -f $ALIGN, $FormattedElement } $TR += '{0}' -f $TD @@ -430,89 +439,72 @@ function Add-HtmlTable { # This part set the capability to emulate Graphviz Subgraph if ($Subgraph) { - if ($SubGraphLabel) { - # Get the Formatted Subgraph Label Ex: Label - $FormattedName = Format-HtmlFontProperty -Text $SubGraphLabel -FontSize $SubgraphLabelFontsize -FontColor $SubgraphFontColor -FontBold:$SubgraphFontBold -FontItalic:$SubgraphFontItalic -FontUnderline:$SubgraphFontUnderline -FontName $SubgraphFontName -FontSubscript:$SubgraphFontSubscript -FontSuperscript:$SubgraphFontSuperscript -FontStrikeThrough:$SubgraphFontStrikeThrough -FontOverline:$SubgraphFontOverline + $subgraphFontParams = @{ + FontSize = $SubgraphLabelFontsize + FontColor = $SubgraphFontColor + FontBold = $SubgraphFontBold + FontItalic = $SubgraphFontItalic + FontUnderline = $SubgraphFontUnderline + FontName = $SubgraphFontName + FontSubscript = $SubgraphFontSubscript + FontSuperscript = $SubgraphFontSuperscript + FontStrikeThrough = $SubgraphFontStrikeThrough + FontOverline = $SubgraphFontOverline + } + $FormattedName = if ($SubGraphLabel) { + Format-HtmlFontProperty @subgraphFontParams -Text $SubGraphLabel } + + # $TDSubgraph format depends only on $IconDebug, regardless of icon presence + $TDSubgraph = if ($IconDebug) { + '{2}' -f $ALIGN, $columnSize, $FormattedName + } else { + '{2}' -f $ALIGN, $columnSize, $FormattedName + } + + $TRTemp = '' if ($SubgraphIcon) { if ($IconDebug) { $TDSubgraphIcon = 'SubGraph Icon' -f $ALIGN, $columnSize, $FontName, $FontColor, $SubgraphLabelFontsize - - $TDSubgraph = '{2}' -f $ALIGN, $columnSize, $FormattedName - - if ($SubgraphLabelPos -eq 'down') { - $TR += '{0}' -f $TDSubgraphIcon - $TR += '{0}' -f $TDSubgraph - } else { - $TRTemp += '{0}' -f $TDSubgraphIcon - $TRTemp += '{0}' -f $TDSubgraph - $TRTemp += $TR - $TR = $TRTemp - } + } elseif ($SubgraphIconWIDTH -and $SubgraphIconHEIGHT) { + $TDSubgraphIcon = '' -f $ALIGN, $columnSize, $SubGraphIconWIDTH, $SubGraphIconHEIGHT, $SubGraphIcon } else { - if ($SubgraphIconWIDTH -and $SubgraphIconHEIGHT) { - - $TDSubgraphIcon = '' -f $ALIGN, $columnSize, $SubGraphIconWIDTH, $SubGraphIconHEIGHT, $SubGraphIcon - - $TDSubgraph = '{2}' -f $ALIGN, $columnSize, $FormattedName - - if ($SubgraphLabelPos -eq 'down') { - $TR += '{0}' -f $TDSubgraphIcon - $TR += '{0}' -f $TDSubgraph - } else { - $TRTemp += '{0}' -f $TDSubgraphIcon - $TRTemp += '{0}' -f $TDSubgraph - $TRTemp += $TR - $TR = $TRTemp - } - } else { - - $TDSubgraphIcon = '' -f $ALIGN, $columnSize, $SubGraphIcon - - $TDSubgraph = '{2}' -f $ALIGN, $columnSize, $FormattedName - - if ($SubgraphLabelPos -eq 'down') { - $TR += '{0}' -f $TDSubgraphIcon - $TR += '{0}' -f $TDSubgraph - } else { - $TRTemp += '{0}' -f $TDSubgraphIcon - $TRTemp += '{0}' -f $TDSubgraph - $TRTemp += $TR - $TR = $TRTemp - } - } + $TDSubgraphIcon = '' -f $ALIGN, $columnSize, $SubGraphIcon + } + if ($SubgraphLabelPos -eq 'down') { + $TR += '{0}' -f $TDSubgraphIcon + $TR += '{0}' -f $TDSubgraph + } else { + $TRTemp += '{0}' -f $TDSubgraphIcon + $TRTemp += '{0}' -f $TDSubgraph + $TRTemp += $TR + $TR = $TRTemp } } else { - if ($IconDebug) { - $TDSubgraph = '{2}' -f $ALIGN, $columnSize, $FormattedName - if ($SubgraphLabelPos -eq 'down') { - $TR += '{0}' -f $TDSubgraph - } else { - $TRTemp = '{0}' -f $TDSubgraph - $TRTemp += $TR - $TR = $TRTemp - } - + if ($SubgraphLabelPos -eq 'down') { + $TR += '{0}' -f $TDSubgraph } else { - $TDSubgraph = '{2}' -f $ALIGN, $columnSize, $FormattedName - if ($SubgraphLabelPos -eq 'down') { - $TR += '{0}' -f $TDSubgraph - } else { - $TRTemp = '{0}' -f $TDSubgraph - $TRTemp += $TR - $TR = $TRTemp - } + $TRTemp = '{0}' -f $TDSubgraph + $TRTemp += $TR + $TR = $TRTemp } } } + $tableParams = @{ + TableStyle = $SubgraphTableStyle + TableBackgroundColor = $TableBackgroundColor + CellBorder = $CellBorder + CellSpacing = $CellSpacing + CellPadding = $CellPadding + TableRowContent = $TR + } if ($IconDebug) { - $HTML = Format-HtmlTable -TableStyle $SubgraphTableStyle -TableBorderColor 'red' -CellBorder $CellBorder -TableRowContent $TR -Cellspacing $CellSpacing -Cellpadding $CellPadding -TableBackgroundColor $TableBackgroundColor - - Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) + $tableParams.TableBorderColor = 'red' } else { - $HTML = Format-HtmlTable -TableStyle $SubgraphTableStyle -TableBorderColor $TableBorderColor -CellBorder $CellBorder -TableBorder $TableBorder -TableRowContent $TR -Cellspacing $CellSpacing -Cellpadding $CellPadding -TableBackgroundColor $TableBackgroundColor - - Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) + $tableParams.TableBorderColor = $TableBorderColor + $tableParams.TableBorder = $TableBorder } + $HTML = Format-HtmlTable @tableParams + Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ad9e00..62ecbd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - refactor: optimize Add-HtmlLabel function for improved readability and maintainability - refactor: simplify AditionalInfo handling and consolidate font parameter usage in Add-HtmlNodeTable function - refactor: add IconPath parameter and improve icon handling in Add-HtmlSubGraph function +- refactor: streamline font parameter handling and improve subgraph icon logic in Add-HtmlTable function ## [1.0.6] - 2026-04-23 From 813778cf347a23ae6b21eb33d7ad5a7d9ca95e6a Mon Sep 17 00:00:00 2001 From: Jonathan Colon Date: Sat, 25 Apr 2026 17:10:10 -0400 Subject: [PATCH 09/14] refactor: enhance icon handling and streamline additional info processing in Add-NodeIcon function --- .../Src/Private/Add-NodeIcon.ps1 | 99 +++++++------------ CHANGELOG.md | 1 + 2 files changed, 38 insertions(+), 62 deletions(-) diff --git a/AsBuiltReport.Diagram/Src/Private/Add-NodeIcon.ps1 b/AsBuiltReport.Diagram/Src/Private/Add-NodeIcon.ps1 index 10374c0..d1f1e99 100644 --- a/AsBuiltReport.Diagram/Src/Private/Add-NodeIcon.ps1 +++ b/AsBuiltReport.Diagram/Src/Private/Add-NodeIcon.ps1 @@ -357,7 +357,7 @@ function Add-NodeIcon { } else { $ICON = 'no_icon.png' } # Set the image size if ImageSizePercent is less than 100 - if ($ImageSizePercent -lt 100) { + if ($ICON -ne 'NoIcon' -and $ImageSizePercent -lt 100) { if (-not $IconPath) { throw 'IconPath is required when ImageSizePercent is less than 100.' } @@ -365,93 +365,68 @@ function Add-NodeIcon { } # Process additionalinfo if provided + $TRAditionalInfo = '' if ($AditionalInfo) { - $TRAditionalInfo = @() - switch ($AditionalInfo.GetType().Name) { - 'Hashtable' { - foreach ($r in $AditionalInfo) { - [string]$TRAditionalInfo += $r.getEnumerator() | ForEach-Object { - '{4}: {5}' -f $_.Key, $CellBackgroundColor, $Align, $FontSize, $_.Key, $_.Value - } - } - } - - 'OrderedDictionary' { - foreach ($r in $AditionalInfo) { - [string]$TRAditionalInfo += $r.getEnumerator() | ForEach-Object { - '{4}: {5}' -f $_.Key, $CellBackgroundColor, $Align, $FontSize, $_.Key, $_.Value - } - } - } - - 'PSCustomObject' { - foreach ($r in $AditionalInfo) { - [string]$TRAditionalInfo += $r.PSObject.Properties | ForEach-Object { - '{4}: {5}' -f $_.Name, $CellBackgroundColor, $Align, $FontSize, $_.Name, $_.Value - } - } - } - - 'Object[]' { - foreach ($r in $AditionalInfo) { - [string]$TRAditionalInfo += $r.PSObject.Properties | ForEach-Object { - '{4}: {5}' -f $_.Name, $CellBackgroundColor, $Align, $FontSize, $_.Name, $_.Value - } - } + $isPSCustomObj = $AditionalInfo.GetType().Name -in 'PSCustomObject', 'Object[]' + foreach ($r in $AditionalInfo) { + $entries = if ($isPSCustomObj) { $r.PSObject.Properties } else { $r.getEnumerator() } + [string]$TRAditionalInfo += $entries | ForEach-Object { + $key = if ($isPSCustomObj) { $_.Name } else { $_.Key } + '{4}: {5}' -f $key, $CellBackgroundColor, $Align, $FontSize, $key, $_.Value } } } - # Determine FontBold based on NoFontBold switch - if ($NoFontBold) { - $FontBold = $false - } else { - $FontBold = $true - } + $FontBold = -not $NoFontBold if (-not $LabelName) { $LabelName = $Name } - # Format the name with the specified font properties - $FormattedName = Format-HtmlFontProperty -Text $LabelName -FontSize $FontSize -FontColor $FontColor -FontBold:$FontBold -FontItalic:$FontItalic -FontUnderline:$FontUnderline -FontName $FontName -FontSubscript:$FontSubscript -FontSuperscript:$FontSuperscript -FontStrikeThrough:$FontStrikeThrough -FontOverline:$FontOverline - + $fontParams = @{ + Text = $LabelName + FontSize = $FontSize + FontColor = $FontColor + FontBold = $FontBold + FontItalic = $FontItalic + FontUnderline = $FontUnderline + FontName = $FontName + FontSubscript = $FontSubscript + FontSuperscript = $FontSuperscript + FontStrikeThrough = $FontStrikeThrough + FontOverline = $FontOverline + } + $FormattedName = Format-HtmlFontProperty @fontParams + + $tableParams = @{ + Port = $Port + TableStyle = $TableStyle + TableBorderColor = $TableBorderColor + TableBorder = $TableBorder + CellBorder = $CellBorder + CellSpacing = $CellSpacing + CellPadding = $CellPadding + TableBackgroundColor = $TableBackgroundColor + } if ($IconDebug) { if ($ICON -ne 'NoIcon') { $TRContent = '{5}{7}{8}' -f $Align, $TDProperties, $FontName, $FontColor, $FontSize, $ICON, $CellBackgroundColor, $FormattedName, $TRAditionalInfo - - $HTML = Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBorderColor 'red' -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent - - Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) } else { $TRContent = '{3}{4}' -f $Align, $TDProperties, $CellBackgroundColor, $FormattedName, $TRAditionalInfo - - $HTML = Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBorderColor 'red' -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent - - Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) } + $HTML = Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBorderColor 'red' -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent } else { if ($ICON -ne 'NoIcon') { if ($ImageSize) { $TRContent = '{6}{7}' -f $Align, $ImageSize.Width, $ImageSize.Height, $TDProperties, $ICON, $CellBackgroundColor, $FormattedName, $TRAditionalInfo - - $HTML = Format-HtmlTable -Port $Port -TableStyle $TableStyle -Tableborder $TableBorder -TableBorderColor $TableBorderColor -TableRowContent $TRContent -CellBorder $CellBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableBackgroundColor $TableBackgroundColor - - Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) } else { $TRContent = '{4}{5}' -f $Align, $TDProperties, $ICON, $CellBackgroundColor, $FormattedName, $TRAditionalInfo - - $HTML = Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBorderColor $TableBorderColor -TableRowContent $TRContent -TableBorder $TableBorder -CellBorder $CellBorder -CellSpacing $CellSpacing -CellPadding $CellPadding -TableBackgroundColor $TableBackgroundColor - - Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) } } else { $TRContent = '{3}{4}' -f $Align, $TDProperties, $CellBackgroundColor, $FormattedName, $TRAditionalInfo - - $HTML = Format-HtmlTable -Port $Port -TableStyle $TableStyle -TableBorderColor $TableBorderColor -TableRowContent $TRContent -TableBackgroundColor $TableBackgroundColor -TableBorder $TableBorder -CellBorder $CellBorder -CellSpacing $CellSpacing -CellPadding $CellPadding - - Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) } + $HTML = Format-HtmlTable @tableParams -TableRowContent $TRContent } + Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 62ecbd7..181367c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - refactor: simplify AditionalInfo handling and consolidate font parameter usage in Add-HtmlNodeTable function - refactor: add IconPath parameter and improve icon handling in Add-HtmlSubGraph function - refactor: streamline font parameter handling and improve subgraph icon logic in Add-HtmlTable function +- refactor: enhance icon handling and streamline additional info processing in Add-NodeIcon function ## [1.0.6] - 2026-04-23 From 711c9ad284f388e9d8499b8ae121f85e16b385e6 Mon Sep 17 00:00:00 2001 From: Jonathan Colon Date: Sat, 25 Apr 2026 17:19:21 -0400 Subject: [PATCH 10/14] refactor: optimize HTML table generation and streamline parameter handling in Add-NodeImage function --- .../Src/Private/Add-NodeImage.ps1 | 25 ++++++++----------- CHANGELOG.md | 1 + 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/AsBuiltReport.Diagram/Src/Private/Add-NodeImage.ps1 b/AsBuiltReport.Diagram/Src/Private/Add-NodeImage.ps1 index 62f1ccf..170fd22 100644 --- a/AsBuiltReport.Diagram/Src/Private/Add-NodeImage.ps1 +++ b/AsBuiltReport.Diagram/Src/Private/Add-NodeImage.ps1 @@ -173,6 +173,7 @@ function Add-NodeImage { Set-ImageOpacity -SourceImageFilePath $sourcePath -OutputImageFilePath $IconSrc -Opacity $ImageOpacityPercent | Out-Null } + $ImageSize = $null if ($ImageSizePercent -lt 100) { if (-not $IconPath) { throw 'IconPath is required when ImageSizePercent is less than 100.' @@ -182,26 +183,22 @@ function Add-NodeImage { if ($IconDebug) { $TRContent = '{1}' -f 'SOLID', $ICON - - $HTML = Format-HtmlTable -TableBackgroundColor '#FFCCCC' -TableBorderColor 'red' -CellBorder 0 -CellSpacing $CellSpacing -CellPadding $CellPadding -TableRowContent $TRContent - - Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) + $HTML = Format-HtmlTable -TableBackgroundColor '#FFCCCC' -TableBorderColor 'red' -CellBorder 0 -CellSpacing 0 -CellPadding 0 -TableRowContent $TRContent } else { + $tableParams = @{ + TableStyle = $TableBorderStyle + TableBorder = $TableBorder + TableBackgroundColor = $TableBackgroundColor + TableBorderColor = $TableBorderColor + CellBorder = 0 + } if ($ImageSize) { - $TRContent = '' -f $TableBorderStyle, $ImageSize.Width, $ImageSize.Height, $IconSrc - - $HTML = Format-HtmlTable -TableStyle $TableBorderStyle -TableBorder $TableBorder -TableBackgroundColor $TableBackgroundColor -TableBorderColor $TableBorderColor -CellBorder 0 -TableRowContent $TRContent - - Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) } else { - $TRContent = '' -f $TableBorderStyle, $IconSrc - - $HTML = Format-HtmlTable -TableStyle $TableBorderStyle -TableBorder $TableBorder -TableBackgroundColor $TableBackgroundColor -TableBorderColor $TableBorderColor -CellBorder 0 -TableRowContent $TRContent - - Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) } + $HTML = Format-HtmlTable @tableParams -TableRowContent $TRContent } + Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 181367c..25c69b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - refactor: add IconPath parameter and improve icon handling in Add-HtmlSubGraph function - refactor: streamline font parameter handling and improve subgraph icon logic in Add-HtmlTable function - refactor: enhance icon handling and streamline additional info processing in Add-NodeIcon function +- refactor: optimize HTML table generation and streamline parameter handling in Add-NodeImage function ## [1.0.6] - 2026-04-23 From c81f28330dba0d69b40be814202c48c5bedd8294 Mon Sep 17 00:00:00 2001 From: Jonathan Colon Date: Sat, 25 Apr 2026 17:23:32 -0400 Subject: [PATCH 11/14] refactor: streamline font parameter handling in Add-NodeText function --- .../Src/Private/Add-NodeText.ps1 | 19 +++++++++++-------- CHANGELOG.md | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/AsBuiltReport.Diagram/Src/Private/Add-NodeText.ps1 b/AsBuiltReport.Diagram/Src/Private/Add-NodeText.ps1 index 7320864..eee77d0 100644 --- a/AsBuiltReport.Diagram/Src/Private/Add-NodeText.ps1 +++ b/AsBuiltReport.Diagram/Src/Private/Add-NodeText.ps1 @@ -186,21 +186,24 @@ function Add-NodeText { throw 'TableBorderStyle must be specified when TableBorderColor is used.' } - $FormattedText = Format-HtmlFontProperty -Text $Text -FontSize $FontSize -FontColor $FontColor -FontBold:$FontBold -FontItalic:$FontItalic -FontUnderline:$FontUnderline -FontName $FontName + $fontParams = @{ + Text = $Text + FontSize = $FontSize + FontColor = $FontColor + FontBold = $FontBold + FontItalic = $FontItalic + FontUnderline = $FontUnderline + FontName = $FontName + } + $FormattedText = Format-HtmlFontProperty @fontParams if ($IconDebug) { $TRContent = '{2}' -f 'SOLID', $TextAlign, $FormattedText - $HTML = Format-HtmlTable -TableBackgroundColor '#FFCCCC' -TableBorderColor 'red' -CellBorder 0 -TableRowContent $TRContent - - Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) - } else { $TRContent = '{2}' -f $TableBorderStyle, $TextAlign, $FormattedText - $HTML = Format-HtmlTable -TableStyle $TableBorderStyle -TableBorder $TableBorder -TableBorderColor $TableBorderColor -TableBackgroundColor $TableBackgroundColor -CellBorder 0 -TableRowContent $TRContent - - Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) } + Format-NodeObject -Name $Name -HtmlObject $HTML -GraphvizAttributes $GraphvizAttributes -AsHtml:(-not $NodeObject) } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 25c69b8..d9c656e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - refactor: streamline font parameter handling and improve subgraph icon logic in Add-HtmlTable function - refactor: enhance icon handling and streamline additional info processing in Add-NodeIcon function - refactor: optimize HTML table generation and streamline parameter handling in Add-NodeImage function +- refactor: streamline font parameter handling in Add-NodeText function ## [1.0.6] - 2026-04-23 From 0df56f5c983d62412145952a31f58e08764cad1f Mon Sep 17 00:00:00 2001 From: Jonathan Colon Date: Sat, 2 May 2026 12:32:06 -0400 Subject: [PATCH 12/14] fix: resolve duplicate pester test names in AdvancedExample02.Tests --- CHANGELOG.md | 4 ++++ Tests/AdvancedExample02.Tests.ps1 | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9c656e..f4cbb6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - refactor: optimize HTML table generation and streamline parameter handling in Add-NodeImage function - refactor: streamline font parameter handling in Add-NodeText function +### :wrench: Fixed + +- Fix duplicate pester test names in AdvancedExample02.Tests tests + ## [1.0.6] - 2026-04-23 ### :arrows_clockwise: Changed diff --git a/Tests/AdvancedExample02.Tests.ps1 b/Tests/AdvancedExample02.Tests.ps1 index 9098ce0..818c42e 100644 --- a/Tests/AdvancedExample02.Tests.ps1 +++ b/Tests/AdvancedExample02.Tests.ps1 @@ -113,7 +113,7 @@ Describe AdvancedExample02 { } } - Context 'Graphviz Dot Node Icon (Label) Tests' { + Context 'Graphviz Dot Node Icon (Label) Tests - Web-Server Nodes' { It 'Should match HTML label Web-Server-01 node with embedded image' { $DotFile = ($RunFile).FullName $DotContent = Get-Content -Path $DotFile -Raw @@ -193,7 +193,7 @@ Describe AdvancedExample02 { } } - Context 'Graphviz Dot Node Icon (Label) Tests' { + Context 'Graphviz Dot Node Icon (Label) Tests - Info-Box Nodes' { It 'Should match HTML label Info-Box node with embedded image' { $DotFile = ($RunFile).FullName $DotContent = Get-Content -Path $DotFile -Raw From 4188f36e5b4279312366cc3eabdb0b06a4d20c53 Mon Sep 17 00:00:00 2001 From: Jonathan Colon Date: Sat, 2 May 2026 16:45:01 -0400 Subject: [PATCH 13/14] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 b/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 index ac7d59a..ef668c5 100644 --- a/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 +++ b/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 @@ -289,7 +289,7 @@ function Add-HtmlSignatureTable { Format-HtmlTable @tableParams -TableRowContent $TRContent } elseif ($ImageSize) { $TRContent = '{4}' -f $Align, $ImageSize.Width, $ImageSize.Height, $ICON, $TR - Format-HtmlTable -TableStyle $TableStyle -TableBackgroundColor $TableBackgroundColor -TableBorder $TableBorder -TableBorderColor $TableBorderColor -CellBorder 0 -TableRowContent $TRContent + Format-HtmlTable @tableParams -TableRowContent $TRContent } else { $TRContent = '{2}' -f $Align, $ICON, $TR Format-HtmlTable @tableParams -TableRowContent $TRContent From a0bfe5756c8cff41076c141222535aaa7f7d7105 Mon Sep 17 00:00:00 2001 From: Jonathan Colon Date: Sat, 2 May 2026 16:55:01 -0400 Subject: [PATCH 14/14] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 b/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 index ef668c5..d4191a3 100644 --- a/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 +++ b/AsBuiltReport.Diagram/Src/Private/Add-HtmlSignatureTable.ps1 @@ -254,10 +254,12 @@ function Add-HtmlSignatureTable { $ImageSize = Get-ImagePercent -ImageInput (Join-Path -Path $IconPath -Child $ICON) -Percent $ImageSizePercent } + $effectiveFontBold = if ($NoFontBold) { $false } else { $FontBold } + $fontParams = @{ FontSize = $FontSize FontColor = $FontColor - FontBold = $FontBold + FontBold = $effectiveFontBold FontItalic = $FontItalic FontUnderline = $FontUnderline FontName = $FontName