lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

I'm releasing LuaHelp, a simple manual page system for the Lua interpreter.
LuaHelp is under public domain and contains lhp (Lua Help Pages) -- I was
thinking about Lua Help Files, but the acronym was already taken ;) -- for all
functions (and constants) in the core Lua libs. It can be found at

http://luahelp.googlecode.com/files/luahelp-0.1-1.tar.gz

I'm attaching a rock spec for it, but should expect this rock to hit the
repositories soon.

Of course, any comments/suggestions/bug reports/patches are welcome. Enjoy!

$ lua -lhelp
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> help()

help (fname)
------------

  Prints the help available for function `fname`. The help description is
  available either from a previous `help.register` command or by reading a Lua
  help page (LHP) file `fname.lhp` stored at some template path in
  `help.path`, similarly to how modules are searched using `package.path`
  (check `help("package.path")`). In either case the help description is
  cached.

  __See also__: `help.register`.

> help"package.path"

package.path
------------

  The path used by `require` to search for a Lua loader.

  At start-up, Lua initializes this variable with the value of the environment
  variable LUA_PATH or with a default path defined in luaconf.h, if the
  environment variable is not defined. Any ";;" in the value of the
  environment variable is replaced by the default path.

  A path is a sequence of _templates_ separated by semicolons. For each
  template, `require` will change each interrogation mark in the template by
  `filename`, which is `modname` with each dot replaced by a "directory
  separator" (such as "/" in Unix); then it will try to load the resulting
  file name. So, for instance, if the Lua path is

         "./?.lua;./?.lc;/usr/local/?/init.lua"

  the search for a Lua loader for module foo will try to load the files
  `./foo.lua`, `./foo.lc`, and `/usr/local/foo/init.lua`, in that order.

> help"help.register"

help.register (fname, desc)
---------------------------

  Registers help description `desc` for function named `fname`, so that
  `help(fname)` prints `desc`. Both arguments should be strings.


Cheers,
Luis

-- 
Computers are useless. They can only give you answers.
                -- Pablo Picasso

-- 
Luis Carvalho (Kozure)
lua -e 'print((("lexcarvalho@NO.gmail.SPAM.com"):gsub("(%u+%.)","")))'
package = "LuaHelp"
version = "0.1-1"

source = {
  url = "http://luahelp.googlecode.com/files/luahelp-0.1-1.tar.gz";,
  md5 = "3f67687cf91f6535aeeebab0f7915b2e"
}

description = {
  summary  = "Help pages for Lua",
  detailed = [[
    LuaHelp provides a simple interface to manual pages, called Lua Help Pages
    (LHP). From the interpreter, just call "help()" for a more detailed
    description.
  ]],
  homepage = "http://code.google.com/p/luahelp";,
  license = "Public domain"
}

dependencies = {
  "lua >= 5.1"
}

local basefiles = {
  "lhp/assert.lhp",
  "lhp/collectgarbage.lhp",
  "lhp/debug.lhp",
  "lhp/dofile.lhp",
  "lhp/error.lhp",
  "lhp/getfenv.lhp",
  "lhp/getmetatable.lhp",
  "lhp/_G.lhp",
  "lhp/help.lhp",
  "lhp/io.lhp",
  "lhp/ipairs.lhp",
  "lhp/length.lhp",
  "lhp/loadfile.lhp",
  "lhp/load.lhp",
  "lhp/loadstring.lhp",
  "lhp/math.lhp",
  "lhp/module.lhp",
  "lhp/next.lhp",
  "lhp/os.lhp",
  "lhp/package.lhp",
  "lhp/pairs.lhp",
  "lhp/patterns.lhp",
  "lhp/pcall.lhp",
  "lhp/print.lhp",
  "lhp/rawequal.lhp",
  "lhp/rawget.lhp",
  "lhp/rawset.lhp",
  "lhp/require.lhp",
  "lhp/select.lhp",
  "lhp/setfenv.lhp",
  "lhp/setmetatable.lhp",
  "lhp/string.lhp",
  "lhp/table.lhp",
  "lhp/tonumber.lhp",
  "lhp/tostring.lhp",
  "lhp/type.lhp",
  "lhp/unpack.lhp",
  "lhp/xpcall.lhp"
}

local libfiles = {
  -- coroutine
  "lhp/coroutine/create.lhp",
  "lhp/coroutine/resume.lhp",
  "lhp/coroutine/running.lhp",
  "lhp/coroutine/status.lhp",
  "lhp/coroutine/wrap.lhp",
  "lhp/coroutine/yield.lhp",
  -- debug
  "lhp/debug/debug.lhp",
  "lhp/debug/getfenv.lhp",
  "lhp/debug/gethook.lhp",
  "lhp/debug/getinfo.lhp",
  "lhp/debug/getlocal.lhp",
  "lhp/debug/getmetatable.lhp",
  "lhp/debug/getregistry.lhp",
  "lhp/debug/getupvalue.lhp",
  "lhp/debug/setfenv.lhp",
  "lhp/debug/sethook.lhp",
  "lhp/debug/setlocal.lhp",
  "lhp/debug/setmetatable.lhp",
  "lhp/debug/setupvalue.lhp",
  "lhp/debug/traceback.lhp",
  -- help
  "lhp/help/register.lhp",
  -- io
  "lhp/file/close.lhp",
  "lhp/file/flush.lhp",
  "lhp/file/lines.lhp",
  "lhp/file/read.lhp",
  "lhp/file/seek.lhp",
  "lhp/file/setvbuf.lhp",
  "lhp/file/write.lhp",
  "lhp/io/close.lhp",
  "lhp/io/flush.lhp",
  "lhp/io/input.lhp",
  "lhp/io/lines.lhp",
  "lhp/io/open.lhp",
  "lhp/io/output.lhp",
  "lhp/io/popen.lhp",
  "lhp/io/read.lhp",
  "lhp/io/tmpfile.lhp",
  "lhp/io/type.lhp",
  "lhp/io/write.lhp",
  -- math
  "lhp/math/abs.lhp",
  "lhp/math/acos.lhp",
  "lhp/math/asin.lhp",
  "lhp/math/atan2.lhp",
  "lhp/math/atan.lhp",
  "lhp/math/ceil.lhp",
  "lhp/math/cosh.lhp",
  "lhp/math/cos.lhp",
  "lhp/math/deg.lhp",
  "lhp/math/exp.lhp",
  "lhp/math/floor.lhp",
  "lhp/math/fmod.lhp",
  "lhp/math/frexp.lhp",
  "lhp/math/huge.lhp",
  "lhp/math/ldexp.lhp",
  "lhp/math/log10.lhp",
  "lhp/math/log.lhp",
  "lhp/math/max.lhp",
  "lhp/math/min.lhp",
  "lhp/math/modf.lhp",
  "lhp/math/pi.lhp",
  "lhp/math/pow.lhp",
  "lhp/math/rad.lhp",
  "lhp/math/random.lhp",
  "lhp/math/randomseed.lhp",
  "lhp/math/sinh.lhp",
  "lhp/math/sin.lhp",
  "lhp/math/sqrt.lhp",
  "lhp/math/tanh.lhp",
  "lhp/math/tan.lhp",
  -- os
  "lhp/os/clock.lhp",
  "lhp/os/date.lhp",
  "lhp/os/difftime.lhp",
  "lhp/os/execute.lhp",
  "lhp/os/exit.lhp",
  "lhp/os/getenv.lhp",
  "lhp/os/remove.lhp",
  "lhp/os/rename.lhp",
  "lhp/os/setlocale.lhp",
  "lhp/os/time.lhp",
  "lhp/os/tmpname.lhp",
  -- package
  "lhp/package/cpath.lhp",
  "lhp/package/loaded.lhp",
  "lhp/package/loadlib.lhp",
  "lhp/package/path.lhp",
  "lhp/package/preload.lhp",
  "lhp/package/seeall.lhp",
  -- string
  "lhp/string/byte.lhp",
  "lhp/string/char.lhp",
  "lhp/string/dump.lhp",
  "lhp/string/find.lhp",
  "lhp/string/format.lhp",
  "lhp/string/gmatch.lhp",
  "lhp/string/gsub.lhp",
  "lhp/string/len.lhp",
  "lhp/string/lower.lhp",
  "lhp/string/match.lhp",
  "lhp/string/rep.lhp",
  "lhp/string/reverse.lhp",
  "lhp/string/sub.lhp",
  "lhp/string/upper.lhp",
  -- table
  "lhp/table/concat.lhp",
  "lhp/table/foreachi.lhp",
  "lhp/table/foreach.lhp",
  "lhp/table/insert.lhp",
  "lhp/table/maxn.lhp",
  "lhp/table/remove.lhp",
  "lhp/table/sort.lhp"
}

local lhp = {}
for i = 1, #basefiles do
  local f = basefiles[i]
  local t = {f:match("^(lhp)/([%w_]+)%.lhp$")}
  lhp[t[1] .. "." .. t[2]] = f
end
for i = 1, #libfiles do
  local f = libfiles[i]
  local t = {f:match("^(lhp)/(%w+)/([%w_]+)%.lhp$")}
  lhp[t[1] .. "." .. t[2] .. "." .. t[3]] = f
end

build = {
  type = "builtin",
  modules = {
    help = "help.c"
  },
  install = { lua = lhp }
}