function markup(str) local function trim(tbl) for i=#tbl,1,-1 do if tbl[i] == ' ' then tbl[i] = nil else return tbl end end end local parse, block, block2, element, code, url, title, def, dt, dd function parse(out, next) local c = next() if not c then return out end if c == ' ' or c == '\t' then return parse(out, next) end out[#out+1] = '

' if c == '[' then return element(out, next) end out[#out+1] = c return block(out, next) end function block(out, next) local c = next() if not c then out[#out+1] = '

' return out end if c == '[' then return element(out, next) end if c == '\n' then return block2(out, next) end out[#out+1] = c return block(out, next) end function block2(out, next) local c = next() if not c then out[#out+1] = '

' return out end if c == '[' then return element(out, next) end if c == '\n' then out[#out+1] = '

' return parse(out, next) end if c ~= ' ' and c ~= '\t' then out[#out+1] = c end return block(out, next) end function element(out, next) local c = assert(next(), 'markup error') if c == '^' then out[#out+1] = '' return code(out, next) end out[#out+1] = '['..c return block(out, next) end function url(out, next) local c = assert(next(), 'markup error') assert(c ~= ']', 'incomplete link definition') if c == ' ' then out[#out+1] = '">' return title(out, next) end out[#out+1] = c return url(out, next) end function title(out, next) local c = assert(next(), 'markup error') if c == ']' then out[#out+1] = '' return block(out, next) end out[#out+1] = c return title(out, next) end function def(out, next) local c = assert(next(), 'markup error') if c == ' ' or c == '\t' or c == '\n' then return def(out, next) end if c == ']' then out[#out+1] = '' return block(out, next) end out[#out+1] = '
' .. c return dt(out, next) end function dt(out, next) local c = assert(next(), 'markup error') if c == ':' then trim(out) out[#out+1] = '
' return dd(out, next) end out[#out+1] = c return dt(out, next) end function dd(out, next) local c = assert(next(), 'markup error') if c == '\n' then out[#out+1] = '
' return def(out, next) end out[#out+1] = c return dd(out, next) end function code(out, next) local c = assert(next(), 'markup error') if c == ']' then out[#out+1] = '' return block(out, next) end out[#out+1] = c return code(out, next) end local function spans(m) local cmd,rest = m:match('^{(.)(.+)}$') if cmd == '#' then return ''..rest..'' end if cmd == '*' then return ''..rest..'' end if cmd == '!' then return ''..rest..'' end return m end return table.concat(parse({}, str:gmatch('.'))):gsub('%b{}', spans):gsub('%b{}', spans) end -- PREPARE DOCUMENTATION MARKUP local DOC = { short = {}, long = {} } function Module(M) for _,field in ipairs{'name', 'title', 'short', 'long'} do assert(M[field], "Module: Required field `"..field.."' is missing") end DOC.short[#DOC.short+1] = ('
%s
%s
'):format(M.title, M.name, M.short) local long = {} local function F(s, ...) long[#long+1] = select('#', ...) > 0 and s:format(...) or s end F('', M.title, M.title) F('
') -- outer block> F('

%s^ top

', M.name) F('
') -- preamble> F('
%s = require "%s"
', M.title:gsub("^(%w+)%W.+", "%1"), M.name) F(markup(M.long)) F('
') --

Module overview

') -- overview> for _,item in ipairs(M) do if item.short then F(item.short) end end F('
') -- ') -- %s
%s
'):format(M.name, M.name, M.title) local long = {} local function F(s, ...) long[#long+1] = select('#', ...) > 0 and s:format(...) or s end F('', M.name, M.name) F('

%s^ top

', M.title) -- section block> F(markup(M.content)) if M.example then if type(M.example) ~= 'table' then M.example = {M.example} end F('
Example:') for i=1,#M.example do F('
')
			F(M.example[i])
			F('
') end F('
') end F('
') --
%s()
%s
'):format(M.name[i], M.name[i], M.short[i]) end short = table.concat(short) local args = {} for _,p in ipairs(M.params) do args[#args+1] = p[2] end args = #args>0 and table.concat(args, ', ') or '' local long = {} local function F(s, ...) long[#long+1] = select('#', ...) > 0 and s:format(...) or s end -- header(s) for i=1,#M.name do F('', M.name[i], M.name[i]) end F('
') for i=1,#M.name do F('

function %s(%s)^ top

', M.name[i], args) -- section block> end -- description F(markup(M.long)) -- parameters F('
Parameters:
') if #M.params == 0 then F('
None
') end for _,p in ipairs(M.params) do F('
%s %s
%s
', p[1], p[2], markup(p[3]):sub(4,-5)) end F('
') -- return values F('
Returns:
') if #M.returns == 0 then F('
Nothing
') end for _,r in ipairs(M.returns) do F('
%s
%s
', r[1], markup(r[2]):sub(4,-5)) end F('
') -- example(s) if type(M.example) ~= 'table' then M.example = {M.example} end F('
Example:') for i=1,#M.example do F('
')
		F(M.example[i])
		F('
') end F('
') -- sketch if M.sketch then F('
Sketch:
', M.sketch[1], M.sketch.width, M.sketch.height) end F('
') --
hump - LÖVE Helper Utilities for More Productivity

Introduction^ top

Helper Utilities for a Multitude of Problems is a set of lightweight helpers for the awesome LÖVE Engine.

It features

  • gamestate.lua: a gamestate system.
  • timer.lua: timed function calling and interpolating functions,
  • vector.lua: a mature vector type,
  • vector-light.lua: lightweight vector math,
  • class.lua: a simple and easy class system,
  • camera.lua: a move-, zoom- and rotatable camera and
  • ringbuffer.lua: a circular container.

hump differs from other libraries in that every component is independent of the remaining ones (apart from camera.lua, which does depends on vector.lua). hump's footprint is very small and thus should fit nicely into your projects.

Documentation^ top

]]) io.write('
'..table.concat(DOC.short):gsub('Ö', 'Ö')..'
') io.write([[
]]) io.write(table.concat(DOC.long):gsub('Ö', 'Ö')) io.write[[

License^ top

Yay, free software:

Copyright (c) 2010 Matthias Richter

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Download^ top

You can view and download the individual modules on github: vrld/hump. You may also download the whole packed sourcecode either in zip or tar formats.

You can clone the project with Git by running:

git clone git://github.com/vrld/hump
Once done, you can check for updates by running
git pull

]]