I’m working on my first plugin and have run into a small snag.
I have a library that generates an ‘object’ and I’m having a heck of a time modifying the plugin documentation template to properly document it.
To be clear, I’m releasing a module to ‘calculate collision filters based on named colliders’. This snippet demonstrates it in action (excerpt from my plugin example):
-- EXCERPT TO AVOID UBER DUMP local rgcc = require "plugin.rgcc" local group = display.newGroup() -- .. physics setup not shown for brevity local createBall local myCC = rgcc.newCalculator() myCC:addNames( "block", "redBall", "greenBall" ) myCC:collidesWith( "redBall", "block", "greenBall" ) createBall = function( x, y, r, color, type) local tmp = display.newCircle( group, x, y, r ) tmp:setFillColor( unpack( color ) ) physics.addBody( tmp, "dynamic", { radius = r, friction = 0.2, bounce = 0.85, filter = myCC:getCollisionFilter( type ) } ) timer.performWithDelay( 1000, function() createBall(x, y, r, color, type) end ) end createBall( display.contentCenterX - 100, 30, 10, {1,0,0}, "redBall" ) createBall( display.contentCenterX + 100, 30, 10, {0,1,0}, "greenBall" )
If you read the code, you’ll see I have the plugin library ‘rgcc’. This library has one function:
local myCC = rgcc.newCalculator()
When the above function is called, it produces a table object (myCC) with a number of methods attached to it, including:
- addName()
- addNames()
- collidesWith()
- getCategoryBits()
- getMaskBits()
- getCollisionFilter()
- dump()
The Problem
The problem is, that I can figure out how to document the newCalculator() function:
- Duplicate FUNCTION.markdown (from docs template)
- Renamed it to newCalculator.markdown
- Fill it in as per directions.
- Refer to it from Readme.markdown
But I’m stumped on how to link to and document:
- myCC - i.e. The returned object
- addName()
- addNames()
- collidesWith()
- getCategoryBits()
- getMaskBits()
- getCollisionFilter()
- dump()
Partial Solution
I’m considering grabbing markdown code from Readme.markdown and using it in newCalculator.markdown like this:
### Functions ##### [myCC:addName()](addName.markdown) ##### [myCC:addNames()](addNames.markdown) ... ##### [myCC:dump()](dump.markdown)
Then, for each referenced function I’ll copy a FUNCTION.markdown, rename it, and fill it in.
Missing Part of Solution
The only issue is I won’t have a Return value link at the top of newCalculator.markdown. i.e. Although a value is returned, I don’t know how link and document it.
Plan
First, if you’ve read this far you’re awesome. Thanks for bearing with me.
Right now, I plan on following the above solution steps. I’ll then submit and if adjustments are needed for the docs, I’ll work with a contact then.
That said, if anyone has dealt with this already, please share your thoughts and a solution if you have one.
Cheers,
Ed