I am currently in the process of developing a plugin that reads documentation. I am using the JSDoc format for my documentation, so I need to know how I can convert this:
"
This is my function
@param [number?] another number - does something
@param [boolean] boolean - does something
@returns [void] the return value
"
to this:
local docs = {
MyFunction = {
"This is my function",
Params = {
["another number"] = {"number?", "does something"},
["boolean"] = {"boolean", "does something"}
},
Returns = {
{"void", "the return value"}
}
}
}
I really only need to know how to get the bits from the strings and such.
I won’t spoon feed you here, but what you can first do is to separate the string according to the lines. Set MyFunction[1] to the first line of the string. Loop through the rest of the lines, check if the line starts with “@”. If it does, use string.split(" ") and set the key of the sub table to the third split result, and then inside the sub table you can put the second split result (with the brackets removed with string.gsub) and the same goes for the rest. Hope you understand what I’m trying to say.
Probably string.match will work out. basically like hard to explain but If you to String Pattern Reference doc it will show you the magic characters and how to use them.