2 -------------------------------------------------------------------------------
4 -- @release $Id: luadoc.lua.in,v 1.1 2008/02/17 06:42:51 jasonsantos Exp $
5 -------------------------------------------------------------------------------
7 --local source = debug.getinfo(1).source or ""
8 --local mypath = source:match("@(.+)/[^/]+")
10 --package.path = package.path .. ";" .. mypath .. "/?.lua;" .. mypath .. "/?/init.lua"
14 -------------------------------------------------------------------------------
15 -- Print version number.
17 local function print_version ()
18 print (string.format("%s\n%s\n%s",
24 -------------------------------------------------------------------------------
25 -- Print usage message.
27 local function print_help ()
28 print ("Usage: "..arg[0]..[[ [options|files]
29 Generate documentation from files. Available options are:
30 -d path output directory path
31 -t path template directory path
32 -h, --help print this help and exit
33 --noindexpage do not generate global index page
34 --nofiles do not generate documentation for files
35 --nomodules do not generate documentation for modules
36 --doclet doclet_module doclet module to generate output
37 --taglet taglet_module taglet module to parse input code
38 -q, --quiet suppress all normal output
39 -v, --version print version information]])
42 local function off_messages (arg, i, options)
46 -------------------------------------------------------------------------------
47 -- Process options. TODO: use getopts.
52 d = function (arg, i, options)
54 if string.sub (dir, -2) ~= "/" then
57 options.output_dir = dir
60 t = function (arg, i, options)
62 if string.sub (dir, -2) ~= "/" then
65 options.template_dir = dir
73 version = print_version,
74 doclet = function (arg, i, options)
75 options.doclet = arg[i+1]
78 taglet = function (arg, i, options)
79 options.taglet = arg[i+1]
84 -------------------------------------------------------------------------------
86 local function process_options (arg)
88 local options = require "luadoc.config"
92 if string.sub (argi, 1, 1) ~= '-' then
93 table.insert (files, argi)
95 local opt = string.sub (argi, 2)
96 if string.sub (opt, 1, 1) == '-' then
97 opt = string.gsub (opt, "%-", "")
100 if OPTIONS[opt] (arg, i, options) then
109 return files, options
112 -------------------------------------------------------------------------------
113 -- Main function. Process command-line parameters and call luadoc processor.
122 local files, options = process_options (arg)
123 return luadoc.main(files, options)