New Script Editor Hover Tips and User-Defined Function Documentation

Yes, I know about native code, though I believe it was said it takes extra memory (or something along those lines). I often use it on server code.

Thanks for the response, I couldn’t think of anything to search that would give me any answers for this :slightly_smiling_face:

3 Likes

There’s no interface or request/response model change to this API, but you will get user-defined documentation content as part of the Response (if it exists).

It’s on the same property as our built-in documentation (ie. Response.items[n].documentation)

4 Likes

you are correct, codegen takes up a bit more memory but the current limit is 64mb; it’s more about scripts taking slightly longer to load (due to compilation) and the average function takes up to 5kb unless you’re doing a lot of math or accessing the datamodel

4 Likes

Brilliant update! I’ve been waiting for a way to have user-defined function documentation for such a long time. So many great updates lately!

4 Likes

i’ve never seen anyone use that format for comments

7 Likes

Could we get documentation annotations too on type defined functions?

EDIT: See for work around

8 Likes

Both of those types of comments, --- and --[=[]=] are used for Moonwave doc comments. The majority of open-source libraries in the Roblox Open Source Community use Moonwave for their documentation. So they are used quite often.

8 Likes

Adding onto your @vvv331 's work around.

You can format your types like this:

local ObjectObj = {}
ObjectObj.__index = ObjectObj

--destroys it, if the cosmic bit flip occurs
function ObjectObj:Destroy():nil
    return nil
end

type ObjectType = {
    Destroy: typeof(ObjectObj.Destroy)
}

function createObject():ObjectType
    return setmetatable({}, ObjectObj)
end

local obj = createObject()
obj:Destroy()
8 Likes

Nice update, keep it up
User-defined function documentation is epic

5 Likes

Finally. I have wanted this ever since I used user defined documentation on Visual Studio 2022.

5 Likes

Very nice update… but maybe add hyperlinks to functions descriptions

9 Likes

Good. Nothing to say more than that.

3 Likes

Next: can we have custom classes and properties? so when we call it in a script it will just show up in the intellisense code completer

2 Likes

Luau is derived from Lua which is prototype-based. Classes are a huge feature, and are fundamentally different to the principles of the language. Likely, asking on an unrelated announcement, not even on the Luau GitHub, won’t sway any decisions.

Metatables are the closest we’ll get to “proper” OOP (I don’t think you need some special declaration to call something object-oriented), and are also how Roblox’s own classes are represented for Luau code.

5 Likes
local t = {}

function t.new()
	return setmetatable({
		value = 1
	}, t)
end

type t = typeof(t.new())

function t.print(self: t, n: number)
	pairs("something")	
end

t: --> no print??

at the end of this snippet, you can see it doesn’t show the print method, could this specific case be added considering OOP is used alot in luau? we need a way to access the object entries within it’s methods without having to type the whole thing out.

the approach I showed in the snippet above is how I usually allow autocomplete to work, without it the autocomplete doesn’t work within the object methods.

this is not a niche case.

1 Like

I was about to make this post myself! I personally spend a lot of my time using Java and JavaDocs and these tags are extremely useful as a developer, especially when reading third-party packages (in roblox’s case modules). After this update I’ve gone through some of my own code and started adding function documentation and I’ve found it a bit difficult to explain the purpose of certain parameters without having the documentation look weird.

image

If we could add comments like these per-variable this would be even more of a game-changer!

Like others have suggested, if we could go as far as LuaDocs like @permanent_fixture had mentioned, the possibilities for user-made documentations would be extreme.

Although there are many things which I want in the future, this itself is already a huge update that I’m very grateful for. Much apprecated! :happy3:

7 Likes

1 Like

i was wondering why the tooltip looked a little different, the users-defined function documentation is a absolute game-changer for me! thanks for the great update roblox :coefficients:

1 Like

Its nice to finally have a feature to document functions, this will help me and my studio to drastically improve code readability

2 Likes

Can you fix this issue?

Highlights the first line in the module script in orange.

2 Likes