2 -------------------------------------------------------------------------------
4 -- @release $Id: luadoc.lua.in,v 1.1 2008/02/17 06:42:51 jasonsantos Exp $
5 -------------------------------------------------------------------------------
9 -------------------------------------------------------------------------------
10 -- Print version number.
12 local function print_version ()
13 print (string.format("%s\n%s\n%s",
19 -------------------------------------------------------------------------------
20 -- Print usage message.
22 local function print_help ()
23 print ("Usage: "..arg[0]..[[ [options|files]
24 Generate documentation from files. Available options are:
25 -d path output directory path
26 -t path template directory path
27 -h, --help print this help and exit
28 --noindexpage do not generate global index page
29 --nofiles do not generate documentation for files
30 --nomodules do not generate documentation for modules
31 --doclet doclet_module doclet module to generate output
32 --taglet taglet_module taglet module to parse input code
33 -q, --quiet suppress all normal output
34 -v, --version print version information]])
37 local function off_messages (arg, i, options)
41 -------------------------------------------------------------------------------
42 -- Process options. TODO: use getopts.
47 d = function (arg, i, options)
49 if string.sub (dir, -2) ~= "/" then
52 options.output_dir = dir
55 t = function (arg, i, options)
57 if string.sub (dir, -2) ~= "/" then
60 options.template_dir = dir
68 version = print_version,
69 doclet = function (arg, i, options)
70 options.doclet = arg[i+1]
73 taglet = function (arg, i, options)
74 options.taglet = arg[i+1]
79 -------------------------------------------------------------------------------
81 local function process_options (arg)
83 local options = require "luadoc.config"
87 if string.sub (argi, 1, 1) ~= '-' then
88 table.insert (files, argi)
90 local opt = string.sub (argi, 2)
91 if string.sub (opt, 1, 1) == '-' then
92 opt = string.gsub (opt, "%-", "")
95 if OPTIONS[opt] (arg, i, options) then
104 return files, options
107 -------------------------------------------------------------------------------
108 -- Main function. Process command-line parameters and call luadoc processor.
117 local files, options = process_options (arg)
118 return luadoc.main(files, options)