-
Notifications
You must be signed in to change notification settings - Fork 51
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
How to handle function variants #2
Comments
I think your solution's good, since it's most straightforward, even with the possible duplication of a few keys and/or values per variant. |
That could even account for the Notes too, for example |
Am I right in thinking this is how the code works right now? It seems pretty reasonable - though a bit strange having 'functions' inside 'functions' - and it makes sense. |
Maybe it would be a good idea to document the table structure, so people can use the doc without having to dig through the code. |
Yeah, that would be nice indeed. Also I think the variants descriptions would be nice to have |
@leafi I didn't quite get your comment until now. I agree that having a functions table inside of "functions" is a bit misleading. This is how it currently looks: -- Functions
functions = {
{ -- Function 1
name = 'Name of the function',
description = 'The description of what the function does',
functions = {
arguments = { -- (optional)
{ -- Argument 1
type = 'The variable type',
name = 'The variable name',
description = 'The description of the variable.'
},
{ -- Argument 2
type = '...',
name = '...',
description = '...',
},
},
returns = { -- (optional)
{ -- Return statement 1
type = 'The returned variable type',
name = 'The variable name',
description = 'The description of the variable.'
},
{ -- Return statement 2
type = '...',
name = '...',
description = '...'
},
}
},
},
{
-- Function 2
-- ...
},
} This is how it should look IMO: -- Functions
functions = {
{ -- Function 1
name = 'Name of the function',
description = 'The description of what the function does',
variants = {
{
description = 'The description detailing what this variant does',
arguments = { -- (optional)
{ -- Argument 1
type = 'The variable type',
name = 'The variable name',
description = 'The description of the variable.'
},
{ -- Argument 2
type = '...',
name = '...',
description = '...',
},
},
returns = { -- (optional)
{ -- Return statement 1
type = 'The returned variable type',
name = 'The variable name',
description = 'The description of the variable.'
},
{ -- Return statement 2
type = '...',
name = '...',
description = '...'
},
}
},
},
},
{
-- Function 2
-- ...
},
} Needless to say this would require quite a lot of changes 😄 |
Yeah, having 'variants' instead would be nice. Rewriting all the files probably would be best done with a script rather than by hand. ...With some difficulty, I think I've managed to write that script. It runs in-place and overwrites existing Lua files. (So you can't run it twice. Fun!) https://gist.github.com/leafi/9cac45df526be3625e8a It's a bit hairy, so it's fair enough if you don't want to use it... (Edit: Gist updated to check that no modules or types have gained .variants fields.) |
@leafi The script looks good - I didn't have the time yet to try it out myself. If you want to, you can fork and create a pull request and I'll merge it later if the changes are okay. |
@rm-code I'll do that, then. |
Added a bash script for easier development
Some functions have multiple variants like love.graphics.push. These variants sometimes have their descriptions on the wiki. The question is how to handle these in the documentation.
My suggestion would be this:
The text was updated successfully, but these errors were encountered: