项目地址: http://luadoc.luaforge.net
当前版本:3.0.1
LuaDoc需要依赖LuaFileSystem和LuaLogging,我们可以直接下载Lua for Windows( http://code.google.com/p/luaforwindows/),这是带有LuaDoc的整合包,我们可以在Lua For Windows目录下看到 luadoc_start.bat文件,打开后如下:
1
|
lua.exe "%LUA_DEV%\lua\luadoc_start.lua" %*
|
这是批处理自动生成文档。
luadoc_start.lua的命令如下:
1
2 3 4 5 6 7 8 9 10 11 12 |
Usage: d:\Program Files\Lua\5.1\lua\luadoc_start.lua [options|files]
Generate documentation from files. Available options are: -d path output directory path -t path template directory path -h, --help print this help and exit --noindexpage do not generate global index page --nofiles do not generate documentation for files --nomodules do not generate documentation for modules --doclet doclet_module doclet module to generate output --taglet taglet_module taglet module to parse input code -q, --quiet suppress all normal output -v, --version print version information |
LuaDoc的注释以连续的三个减号开始,所支持的标签包括如下:
@author <text>
@copyright <text>
@field
@param <word> <text>
@release <text>
@return <text>
@see <text>
@usage <text>
和三个LuaDoc可自动推导的标签,可以手动指定以覆盖所推导的值:
@class <word>
@description
@name <word>
下面测试LuaDoc使用,新建一个Lua文件,测试代码如下:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
--- 测试用表 -- @class table -- @name testTable -- @field testA 测试字段A -- @field testB 测试字段B testTable = { testA = nil, testB = nil, } --- 测试函数 -- @param a 参数a -- @param b 参数b -- @return 返回1 -- @usage testFun(1, 2) -- @see testTable function testFun(a, b) return 1 end |
在Lua工程文件夹下,新建一个批处理,内容如下:
1
|
lua.exe "%LUA_DEV%\lua\luadoc_start.lua" -d "Docs" *
|
自动将Lua源代码生成文档,保存在Docs目录下。若生成过程没有错误的话,在Docs目录下打开
index.html,效果如下图所示:
点击进去,效果如下图所示:
参考资料:
1.luadoc manual
http://keplerproject.github.com/luadoc/manual.html
2.Windows下使用luaDoc给lua生成文档
http://www.cppblog.com/tx7do/archive/2010/07/25/121209.html