lovr-docs icon indicating copy to clipboard operation
lovr-docs copied to clipboard

Document table shapes

Open porglezomp opened this issue 5 years ago • 3 comments

In many places, the LÖVR docs mention that functions take or return a table containing some information, but they don't say what's in the table, just table, leaving me confused about how to access the contents. In all these cases it would be very useful to document the shape(s) of the tables.

porglezomp avatar Jan 26 '20 20:01 porglezomp

To make this more concrete, here's a list of pages I saw that don't mention anything at all about their table shapes:

  • lovr.headset.getHands
  • lovr.load
  • Some subtables of lovr.conf
  • lovr.math.linearToGamma and lovr.math.gammaToLinear
  • lovr.physics.newWorld
  • lovr.graphics.newMesh
  • lovr.graphics.newTexture
  • Mesh:setVertices

A lot of the tables that do document their shape do so informally in the description, like this:

A list of Joints attached to the Collider.

Which isn't that great. I think this is because right now lovr-docs is pretty good at rendering the shape of dictionary tables (it adds a nested row for each subfield) but not that good at indicating that something is an array/list.

Maybe for arrays instead of showing the type as table, there could be a new convention for indicating that a table is an array, like {number} or {{number|vec3}} or something. That might be manageable and improve clarity compared to English. Hopefully it doesn't get too complicated if the shape of the table is very flexible though.

Another unrelated but somewhat similar issue I've been thinking of (but maybe can be discussed in a separate issue) is the documentation of number ranges.

Thanks for bringing this up!

bjornbytes avatar Jan 26 '20 21:01 bjornbytes

• The attachments argument on lovr.graphics.newCanvas.

porglezomp avatar Jan 26 '20 23:01 porglezomp

I just learned that you can transfer issues between repos, so I'm gonna try it out.

bjornbytes avatar Jan 27 '20 21:01 bjornbytes