Comment-based help queries

Welcome Forums General PowerShell Q&A Comment-based help queries

Viewing 0 reply threads
  • Author
    • #5594
      Topics: 1562
      Replies: 0
      Points: 1
      Rank: Member

      by stromnessian at 2013-02-26 00:14:00


      Just a couple of questions about comment-based help:

      1. In the about_Comment_Based_Help help topic:

      All of the lines in a comment-based help topic must be contiguous.

      Does this only apply to single comment lines, as opposed to comment blocks? I’ve inserted multiple blank lines into my comment-based help in a comment block and it still seems to work fine.

      2. In Learn PowerShell Toolmaking in a Month of Lunches:

      For the first function in your script file, however, make sure there is no more than one blank line between the end of the comment-based help block and the function keyword. Also, there must be at least two blank lines between the start of the script and the first line of the comment-based help. Otherwise, the help will be interpreted as being for the script rather than for the function.

      In my experience, I haven’t had to insert "two blank lines between the start of the script and the first line of the comment-based help" to get it to work.

      Best regards

      by DonJ at 2013-02-26 09:42:17

      Having a blank line in the help is fine so long as it’s a comment:

      # This
      # Is Fine


      # This

      # Is not

      The book quote is a bit out of context. The deal is this: If your comment-based help is INSIDE the function declaration, you’re fine. If the comment-based help is OUTSIDE the function declaration, and there aren’t a couple of blank lines before it, then the help is interpreted as help for the SCRIPT FILE, not the function. This is described in about_comment_based_help. If you’re not writing a function, and you just want comment-based help for a script file, then you don’t need the blank lines because that’s how it will interpret it anyway.

      by stromnessian at 2013-02-26 13:32:34

      Thanks for clearing that up Don. Great book series btw 🙂

Viewing 0 reply threads
  • The topic ‘Comment-based help queries’ is closed to new replies.