Skip to main content



      Home
Home » Archived » Lua Development Tools » Documenting a Function That Returns an Array
Documenting a Function That Returns an Array [message #1037137] Tue, 09 April 2013 03:54 Go to next message
Eclipse UserFriend
Hey all,

I'm trying to document my API for auto-completion and all.
I have a function which returns an array (table without defined keys) where each item is a table with a few fields.

I already know how to create the table with its fields, but how do I define the array type which the function returns?

Thanks!
Re: Documenting a Function That Returns an Array [message #1037984 is a reply to message #1037137] Wed, 10 April 2013 04:51 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I think you are talking about a regular Lua table, so you can use #table as listed in documentation[1].

Regards

[1] http://wiki.eclipse.org/Koneki/LDT/User_Area/Documentation_Language#Primitive_references
Re: Documenting a Function That Returns an Array [message #1037995 is a reply to message #1037984] Wed, 10 April 2013 05:06 Go to previous messageGo to next message
Eclipse UserFriend
[Copy, sorry]

[Updated on: Wed, 10 April 2013 05:07] by Moderator

Re: Documenting a Function That Returns an Array [message #1037996 is a reply to message #1037984] Wed, 10 April 2013 05:07 Go to previous messageGo to next message
Eclipse UserFriend
Perhaps I'm missing something, so I'll give a better example of what I'm after.

Suppose I have the following code:
function get_users()
  local user1 = {
    name = "foo",
    age = 20,
  }
  local user2 = {
    name = "bar",
    age = 20,
  }
  local users = {}
  table.insert(users, user1)
  table.insert(users, user2)

  return users
end

users = get_users()

Now, I want to be able to have auto completion for the keys of each value in the users table.
For example:
users[1].<auto complete here (name or age)>

or
for _, user in pairs(users) do
  print(user.<auto complete here (name or age)>)
end

I know how to document a function that returns a single user (a table with name/age keys), but, how would I go about writing the documentation for the get_users() function?

Thanks again for any help!

[Updated on: Thu, 11 April 2013 07:51] by Moderator

Re: Documenting a Function That Returns an Array [message #1038031 is a reply to message #1037996] Wed, 10 April 2013 06:07 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

So far it is not implemented. We did not address this problem yet, but it might be useful.
You can file a bug[1] (in this case an enhancement). This way we won't forget it when there will be room in our backlog.

Regards

[1] https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Koneki&component=LuaTools
Re: Documenting a Function That Returns an Array [message #1038840 is a reply to message #1038031] Thu, 11 April 2013 08:06 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for confirming that for me. I've opened B405458.
Assuming I might be able to implement this myself, could you give me some pointers as to where to start?

I'm knowledgeable in both Java and Lua, but have never written plugins for Eclipse.
Re: Documenting a Function That Returns an Array [message #1039812 is a reply to message #1038840] Fri, 12 April 2013 12:18 Go to previous message
Eclipse UserFriend
We should first make a decision about the syntax.
I propose to start the discussion on bugzilla.
Previous Topic:Problem using Mihini EE with LDT 0.9 under Win 7
Next Topic:LDT with luabind
Goto Forum:
  


Current Time: Wed May 21 05:05:48 EDT 2025

Powered by FUDForum. Page generated in 0.07398 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top