Skip to content

Comment-based help NOTES gets extra blank lines and double indenting #26102

@jaberenberg

Description

@jaberenberg

Prerequisites

Steps to reproduce

In a discussion of a documentation issue at PowerShell-Docs/issues, I observed that for comment-based help within .ps1 files, the lines in the Notes section are indented 8. All the other sections indent 4. Also, the Notes text starts two blank lines below its header. @sdwheeler responded This is a bug in the formatting for help object. You can file an issue in the source code repo. @sdwheeler went on to add the following, most of which is above my pay grade.

When the PowerShell help system parses the comments, it strips the leading whitespace from the content lines of each section. The number of characters to strip from each line is based on the number of whitespace characters on the first line of the content. That is the value stored in the object model. When the object is output, the format system adds indentation. For whatever reason, the format of NOTES section is adding 2 blank lines and indents by 4 characters twice. The NOTES section information is in the alertSet property of the help object. The text of the section is in the alert property of alertSet. The MamlCommandHelpInfo#alertSet type has its own formatting. You can see there are extra blank lines and the content is indented 4 characters. The formatted alertSet property is getting wrapped inside of another 4 character indent. So it gets indented twice. The content of alertSet.alert is not indented.

Expected behavior

See comments above and below.

Actual behavior

INPUTS
    None.  The function does not accept input from the pipeline.


OUTPUTS
    System.String


NOTES


        This starts in column 5.

        1. This list starts in column 5
           and has continuation lines in column 8
        2. Here is more of
           the hanging indent list

            This line starts in column 8
                This line starts in column 12
        This line starts in column 1

Error details

Environment data

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.5.3
PSEdition                      Core
GitCommitId                    7.5.3
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Interactive-HelpSystemhelp infrastructure and formatting of help

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions