-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some improvement ideas for the future #47
Comments
No worries, it's fine to pile it in one issue. It's workable this way, since this isn't too big a project. You may already have considered ideas like these, but here's my thoughts on the topic of annotating multiple types and callbacks on the wiki. With backwards compatibility
This would ensure backwards compatibility with anyone relying on Some downsides:
Breaking changesI guess the "markup/XML way" for this would be adding child elements that annotate more data. However I don't see a way to implement that without omitting backward compatibility for anyone scraping the wiki. Additionally it would require a bunch of work on all sides. I do believe something like this would work best for the wiki. Since data structured like this could be used by the wiki to generate HTML for developers consulting the wiki manually. Some mockups of how that could look:
Combination without breaking changesThe wiki could add a new element in root, e.g: ...
<args>
<arg name="callback"
type="function"
metadata="callback">...<arg>
...
</args>
...
<metadata>
<functionParameters id="callback">...</functionParameters>
</metadata> However this last option is really oriented on those scraping the wiki, whilst the before mentioned options could also be used by the wiki itself to generate useful html for users of the wiki. |
fields and metamethods can be easily added manually
in general there are only Vector, Angle and VMatrix. It is unlikely that anyone will ever change them. |
@TIMONz1535 Thanks for thinking with us. I think you've got a point that the way Vector, Color, etc. work is unlikely to change. Perhaps our attention is better spent elsewhere and we can just implement your manually written up definitions in the meantime. Parsing the markdown table like Vector has is doable, but seems like a waste of time. |
I have implemented a scraper friendly definitions for function callbacks: And for function overloads: It's currently only on these pages as a test for now. |
Wow awesome, thats super useful and a clean implementation! Thanks so much for your continuous work on all this @robotboy655 |
I have been thinking about how to deal with
Makes it detect the custom functions, but doing this:
does not. It might be possible to fix on their end.
|
@robotboy655 I had been looking at the LuaLS plugins (for #50), but sadly they're very limited and only seem to output Lua to a LOGPATH/diffed.lua, from their wiki:
To me, this is a super confusing functionality in LuaLS. If the diffed file was output to a location that would be indexed for LuaLS autocomplete this would make sense, but I can't find that that's the case. |
@robotboy655 I'd like to correct my previous statement. It seems I (and the LuaLS docs) were wrong about plugins not being able to customize diagnostics:
This means we can modify diagnostics with plugins. Sadly I can't find a way to automatically load the plugin from the glua-api-snippets addon. Placing the plugin.lua in the addon folder doesn't seem to work for me (nor any of the other addons that are in the LuaLS-addons repo) |
since 3.8.0 they added
also some interest part LuaLS/lua-language-server#2484 NEW generic pattern (@fesily)
---@generic T
---@param t Cat.`T`
---@return T
local function f(t) end
local t = f('Smile') --> t is `Cat.Smile` I thought this was what we needed, but it just refers to the existing syntax in the class. That is, it cannot create/modify class fields on the fly. Well, but I realized that even before 3.8.0 it was possible to get any class through a ---@generic T
---@param metaName `T` The object type to retrieve the meta table of.
---@return T # The corresponding meta table.
function _G.FindMetaTable(metaName) end
local entMeta = FindMetaTable("Entity") -- entMeta: Entity |
I've added a small note to the original issue above, it's about adding a way to specify table element types. Right now functions like Currently the wiki has a structure like this for the return type of player.GetAll <rets>
<ret name="" type="table">All <page>Player</page>s currently in the server.</ret>
</rets> If Rubat has some time in the future and feels that this is worth it, perhaps they could add some attributes similar to this: <rets>
<ret name="" type="table" keytype="number" valuetype="Player">All <page>Player</page>s currently in the server.</ret>
</rets> Perhaps even a |
Another slightly related note, but it would be cool if functions like util.TraceLine could be documented about their structs: <args>
<arg name="traceConfig" type="table" struct="Trace">
A table of data that configures the Trace.
For the table's format and available options see the <page>Structures/Trace</page> page.
</arg>
</args>
<rets>
<ret name="" type="table" struct="TraceResult">
A table of information detailing where and what the Trace line intersected, or `nil` if the trace is being done before the <page>GM:InitPostEntity</page> hook.
For the table's format and available options see the <page>Structures/TraceResult</page> page.
</ret>
</rets> |
I use strict integer types https://wiki.facepunch.com/gmod/math.ceil ---[SHARED AND MENU] Ceils or rounds a number up.
---
---[(View on wiki)](https://wiki.facepunch.com/gmod/math.ceil)
---@param number number The number to be rounded up.
---@return number # ceiled numbers
function math.ceil(number) end vs sumneko's ---
---Returns the smallest integral value larger than or equal to `x`.
---
---[View documents](command:extension.lua.doc?["en-us/51/manual.html/pdf-math.ceil"])
---
---@param x number
---@return integer
---@nodiscard
function math.ceil(x) end there is no integer for wiki, but we can specify the custom type as you suggested above |
Sorry to pile on these in 1 issue, I just need to write these down before I forget:
TOOL_Hooks
andStrutures/TOOL
pages conflict with their definition for the TOOL global. There are probably other similar cases.Tool
class (because the structure is written first), causing many "Undefined Symbol" warningsedit by luttje:
Player[]
as the return type ofplayer.GetAll()
The text was updated successfully, but these errors were encountered: