You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see some type annotations using # and some not. Also even the wiki https://luals.github.io/wiki/annotations/ sometimes uses it and sometimes not. Is it good style? Is it more portable?
---@aliasDeviceSide---| '"left"' # The left side of the device---| '"right"' # The right side of the device---| '"top"' # The top side of the device---| '"bottom"' # The bottom side of the device---| '"front"' # The front side of the device---| '"back"' # The back side of the device---@paramsideDeviceSidelocalfunctioncheckSide(side) end
------Gets the current running version of LÖVE.---------[Open in Browser](https://love2d.org/wiki/love.getVersion)------@returnnumber major # The major version of LÖVE, i.e. 0 for version 0.9.1.---@returnnumber minor # The minor version of LÖVE, i.e. 9 for version 0.9.1.---@returnnumber revision # The revision version of LÖVE, i.e. 1 for version 0.9.1.---@returnstring codename # The codename of the current version, i.e. 'Baby Inspector' for version 0.9.1.functionlove.getVersion() end
Or here one from the wiki without hashtags in the "Simple Documentation of a Class" example
---@classPerson---@fieldheightnumber The height of this person in cm---@fieldweightnumber The weight of this person in kg---@fieldfirstNamestring The first name of this person---@fieldlastName? string The last name of this person---@fieldageinteger The age of this person---@parampersonPersonlocalfunctionhire(person) end
I understand it starts the description. But I don't understand when its needed and if I should use it or not.
The purpose seems to be primarily to help simpler parsing (like github highlighting). In some cases it determines if the next line is checked for documentation or not. I cannot tell you where I came across that, though.
We can automatically infer which parts are descriptions from the doc syntax, but sometimes if your descriptor contains structures that could be parsed as continuation you must use an explicit marker to indicate where the description begins; for aliases, adding a # to attach a description is usually required
Activity
litoj commentedon Mar 11, 2026
The purpose seems to be primarily to help simpler parsing (like github highlighting). In some cases it determines if the next line is checked for documentation or not. I cannot tell you where I came across that, though.
CppCXY commentedon Mar 11, 2026
We can automatically infer which parts are descriptions from the doc syntax, but sometimes if your descriptor contains structures that could be parsed as continuation you must use an explicit marker to indicate where the description begins; for aliases, adding a # to attach a description is usually required
ChillerDragon commentedon Mar 11, 2026
Okay good to know thanks. So its not some old deprecated syntax and if I aim for maximum portability I should probably develop the habit of using it.