New Script Editor Hover Tips and User-Defined Function Documentation

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

6 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!

6 Likes

i’ve never seen anyone use that format for comments

9 Likes

Could we get documentation annotations too on type defined functions?

EDIT: See for work around

10 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.

10 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()
11 Likes

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

6 Likes

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

7 Likes

Very nice update… but maybe add hyperlinks to functions descriptions

11 Likes

Good. Nothing to say more than that.

5 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

3 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.

7 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.

2 Likes

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:

8 Likes

2 Likes

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:

2 Likes

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

3 Likes

Can you fix this issue?

Highlights the first line in the module script in orange.

3 Likes

One of the best roblox studio updates this year!

I have a feature request it would be very neat to be able to actually have code examples in the mini documentation.

It would also be nice to add links so people can go to your documentation site with more information on it.

Like this:

8 Likes

YES!!!

I wish this to be a feature as well, the only problem i see is if there will be moderation for links in the documentation.
Which could be a problem, but still should be added!!!

Thanks ROBLOX for this awesome update!!!

2 Likes