ldoc.files and ldoc.examples can have field

This commit is contained in:
steve donovan 2011-07-11 09:59:10 +02:00
parent d864e49f47
commit ebc7c4e22f
1 changed files with 25 additions and 7 deletions

View File

@ -426,21 +426,40 @@ local function process_file (f, file_list)
end end
end end
local function process_file_list (list, mask, operation, ...) local process_file_list, files_from_list
function process_file_list (list, mask, operation, ...)
local exclude_list = list.exclude and files_from_list(list.exclude, mask)
if exclude_list then pretty.dump(exclude_list) end
local function process (f,...)
f = path.normcase(f)
f = path.abspath(f)
if exclude_list and exclude_list:index(f) == nil then
operation(f, ...)
end
end
for _,f in ipairs(list) do for _,f in ipairs(list) do
if path.isdir(f) then if path.isdir(f) then
local files = List(dir.getallfiles(f,mask)) local files = List(dir.getallfiles(f,mask))
for f in files:iter() do for f in files:iter() do
operation(f, ...) process(f,...)
end end
elseif path.isfile(f) then elseif path.isfile(f) then
operation(f, ...) process(f,...)
else else
quit("file or directory does not exist: "..quote(f)) quit("file or directory does not exist: "..quote(f))
end end
end end
end end
function files_from_list (list, mask)
local excl = List()
process_file_list (list, mask, function(f)
excl:append(f)
end)
return excl
end
if type(args.file) == 'table' then if type(args.file) == 'table' then
-- this can only be set from config file so we can assume it's already read -- this can only be set from config file so we can assume it's already read
@ -495,11 +514,10 @@ if type(ldoc.examples) == 'table' then
local tags = { local tags = {
name = path.basename(f), name = path.basename(f),
class = 'example', class = 'example',
description = prettify.lua(f)
} }
local item = F:new_item(tags,1) local item = F:new_item(tags,1)
F:finish() F:finish()
item.not_code = true item.body = prettify.lua(f)
file_list:append(F) file_list:append(F)
end end
@ -687,7 +705,7 @@ function ldoc.ref_to_module (mod,module,kind)
end end
end end
end end
print('res',base..name) --print('res',base..name)
return base..name return base..name
end end
@ -733,7 +751,7 @@ local function generate_output()
check_directory(args.dir..kind) check_directory(args.dir..kind)
for m in modules() do for m in modules() do
ldoc.module = m ldoc.module = m
ldoc.body = m.not_code and m.description or nil ldoc.body = m.body
out,err = template.substitute(module_template,{ out,err = template.substitute(module_template,{
module=m, module=m,
ldoc = ldoc ldoc = ldoc