From f2fc6f1604a438da9a340a8326a6e91d6ec24881 Mon Sep 17 00:00:00 2001 From: steve donovan Date: Mon, 20 Jun 2011 19:04:21 +0200 Subject: [PATCH] can now use package field in config.ld. tests/luadoc contains a suitable setup for processing LuaDoc itself correctly --- ldoc.lua | 27 ++++++++++++++++----------- tests/luadoc/config.ld | 4 ++++ tests/simple/problem.lua | 15 +++++++++++++-- 3 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 tests/luadoc/config.ld diff --git a/ldoc.lua b/ldoc.lua index a1febdc..08e4def 100644 --- a/ldoc.lua +++ b/ldoc.lua @@ -373,18 +373,21 @@ end -- * 'NAME' explicitly give the base module package name -- -if args.package == '.' then - args.package = source_dir -elseif args.package == '..' then - args.package = path.splitpath(source_dir) -elseif not args.package:find '[\//]' then - local subdir,dir = path.splitpath(source_dir) - if dir == args.package then - args.package = subdir - elseif path.isdir(path.join(source_dir,args.package)) then +local function setup_package_base() + if ldoc.package then args.package = ldoc.package end + if args.package == '.' then args.package = source_dir - else - quit("args.package is not the name of the source directory") + elseif args.package == '..' then + args.package = path.splitpath(source_dir) + elseif not args.package:find '[\//]' then + local subdir,dir = path.splitpath(source_dir) + if dir == args.package then + args.package = subdir + elseif path.isdir(path.join(source_dir,args.package)) then + args.package = source_dir + else + quit("args.package is not the name of the source directory") + end end end @@ -417,6 +420,7 @@ if path.isdir(args.file) then if #config_files > 0 and not config_dir then config_dir = read_ldoc_config(config_files[1]) end + setup_package_base() for f in files:iter() do local ext = path.extension(f) @@ -441,6 +445,7 @@ elseif path.isfile(args.file) then read_ldoc_config(config) end end + setup_package_base() local ext = path.extension(args.file) local ftype = file_types[ext] if not ftype then quit "unsupported extension" end diff --git a/tests/luadoc/config.ld b/tests/luadoc/config.ld new file mode 100644 index 0000000..1e5cc5d --- /dev/null +++ b/tests/luadoc/config.ld @@ -0,0 +1,4 @@ +project = 'LuaDoc' +title = "LuaDoc with LDoc" +package = 'luadoc' +file = [[c:\users\steve\luadist\share\lua\lmod\luadoc]] diff --git a/tests/simple/problem.lua b/tests/simple/problem.lua index ad43b99..3848539 100644 --- a/tests/simple/problem.lua +++ b/tests/simple/problem.lua @@ -1,5 +1,16 @@ --- this module has a comment. --- But it's not a doc comment! +--- this module has a comment. + +local local_two + +--- a local function +local function local_one () +end + +--- a local function, needing explicit tag. +-- @local here +function local_two () + +end --- A problem function. -- @param p a parameter