luttje / glua-api-snippets

Scrapes the Garry's Mod Wiki in order to build Lua Language Server comments that will provide IDE suggestions and autocompletion.
MIT License
18 stars 6 forks source link

`Panel` tooltips are not only `string` #58

Closed b0mbie closed 4 weeks ago

b0mbie commented 4 weeks ago

The page for Panel:SetTooltip says that str can actually be either a string or false for no tooltip:

Arguments

  1. string str The text to be displayed in the tooltip. Set false to disable it.

Then, the page for Panel:GetTooltip also says that the return value is the tooltip text, if it was set:

Returns

  1. string tooltip The tooltip text, if it was set.

The tooltip type can possibly defined to be string|false for the Panel:SetTooltip parameter type, though I'm not sure about the return type for Panel:GetTooltip.

This change would fix the diagnostics for the example presented on the page for Panel:SetTooltip: image

luttje commented 4 weeks ago

Heya, thanks for reporting.

If I understand you correctly, then this can be fixed by editting the wiki.

I looked up an example that also allows multiple types for a parameter and found concommand.Add which is typed correctly for its flags parameter: https://github.com/luttje/glua-api-snippets/blob/d4940ffbc406630b84588608f218c8aa27db5266/library/concommand.lua#L35

You can see on the wiki edit page that this is achieved with an argument documented like this:

<arg name="flags" type="number" alttype="table" default="0">Console command modifier flags. Either a bitflag, or a table of enums. See <page>Enums/FCVAR</page>.</arg>

If this answers your question, then it'd be great if you could edit the wiki to document this alttype. Let me know if this is the case and I'll close this issue.

Next month when the scraper updates I'll update the extension in LLS-Addons

PS: Maybe @robotboy655 would be okay with setting the alttype="false" for this specific argument in SetTooltip, even though false obviously isn't a datatype. In that situation we could add a type page to the wiki for https://wiki.facepunch.com/gmod/false (and true) that would point to https://wiki.facepunch.com/gmod/boolean

robotboy655 commented 4 weeks ago

I think the wiki has it misdocumented, its not false to disable it (it works, but as a coincidence), it's omitting the argument that is intended, or nil. I have updated the wiki page.

b0mbie commented 4 weeks ago

Oh! That certainly makes more sense. I think it'll be ok to close this now, then.