Does anyone know if there is a way to add inline comments to InnoSetup source files?
I've done some experiments:
; a comment (allowed)
[Setup]
AppName=MyApp // a comment (allowed)
AppVersion=1.2.3.4 ; a comment (allowed)
DefaultDirName="{pf}\My App" seems you can have anything at all here (allowed)
[Dirs]
Name: "{userdocs}\My App"
Name: {userdocs}\MyApp // a comment (allowed)
Name: "{userdocs}\My App" // a comment (not allowed)
Name: {userdocs}\MyApp ; // a comment (not allowed)
Name: "{userdocs}\My App" ; // a comment (not allowed)
and (I think) I've found that a comment is allowed anywhere where the compiler isn't expecting any more operands, but I would prefer to use a more rigid syntax, if one exists.
In the script part of the source (which includes all the sections except the [Code]
one), a semicolon at the beginning of a line separates a comment. It's described in the Script Format Overview
topic as (emphasized by me):
You can put "comments" in the script (which are ignored by the compiler) by placing a semicolon at the beginning of a line. For example:
; This is a comment. I could put reminders to myself here...
So, that's about the script comment separator (for sections except [Code]
one). Now, let's think about why we can't inline comments to any of those sections.
In the name value sections like e.g. [Setup]
, [Messages]
or similar, you cannot inline comments for their entries because the value portion is everything what follows the equal sign, no matter what it is. So, there is no comment in the following example section. Instead, the directives got pretty long and quite exotic values:
[Setup]
AppName=MyApp // a comment (allowed)
AppVersion=1.2.3.4 ; a comment (allowed)
DefaultDirName="{pf}\My App" seems you can have anything at all here (allowed)
Correct way to comment them would be to use separate lines starting with semicolons:
[Setup]
; comment for AppName
AppName=MyApp
; comment for AppVersion
AppVersion=1.2.3.4
; comment for DefaultDirName
DefaultDirName={pf}\My App
For sections with semicolon separated parameters should not be possible to inline semicolon separated comment, just because of their separator. If that is possible in some condition, I would consider that as a (minor) bug caused by the compiler parser's laziness.