iainbrighton / PScribo

PowerShell documentation framework
MIT License
230 stars 35 forks source link

Sections not adhering to returned values by functions #121

Closed MrM1y4g1 closed 1 year ago

MrM1y4g1 commented 1 year ago

I'm currently working with PScribo and has run into an issue with formatting when utilizing sub functions to determain the sections and content of the document to present in the end.

Import-Module PScribo

function Get-SecondSection {
    Section -Name "Second Section should be landscape" -Style 'Heading1' -Orientation Landscape {
        Get-Service | Select-Object -First 10 | Table -Columns Name,DisplayName,Status -Headers Name,'Display Name',State
    }
}

$MyDocument = Document -Name 'PScribo Test Example 2022' {
    Section -Name "First Section in Portrait mode" -Style 'Heading1' -Orientation Portrait {
        Get-Service | Select-Object -First 10 | Table -Columns Name,DisplayName,Status -Headers Name,'Display Name',State
    }

    Get-SecondSection

    Section -Name "First Section in landscape mode" -Style 'Heading1' -Orientation Landscape {
        Get-Service | Select-Object -First 10 | Table -Columns Name,DisplayName,Status -Headers Name,'Display Name',State
    }
}

$MyDocument | Export-Document -Path "$($PSScriptRoot)" -Format word

this will present three sections where the first two will be in portrait mode and the last in actual landscape mode.

Any suggetions on how to go about this?

MrM1y4g1 commented 1 year ago

I found that the issue lies in the call stack checking of the Section method - i will be creating a PR for patching soon.