260 | 260 |
end
|
261 | 261 |
end
|
262 | 262 |
|
263 | |
local function fixup_module_file (file, fullpath)
|
264 | |
if args.module_file then
|
265 | |
for mname, f in pairs(args.module_file) do
|
266 | |
if f == file then
|
267 | |
args.module_file[mname] = fullpath
|
268 | |
args.module_file[fullpath] = true
|
269 | |
return "master for "..mname
|
270 | |
end
|
271 | |
end
|
272 | |
end
|
273 | |
return ''
|
274 | |
end
|
275 | |
|
276 | |
-- partial sort of file list, where anything in module_file is now upfront!
|
277 | |
local function reorder_module_file (files)
|
278 | |
if args.module_file then
|
279 | |
local mf = args.module_file
|
280 | |
table.sort(files,function(x,y) return mf[x] and not mf[y] end)
|
281 | |
end
|
282 | |
end
|
283 | |
|
284 | 263 |
local abspath = tools.abspath
|
285 | 264 |
|
286 | 265 |
-- a special case: 'ldoc .' can get all its parameters from config.ld
|
|
294 | 273 |
lfs.chdir(config_path)
|
295 | 274 |
end
|
296 | 275 |
config_is_read = true
|
297 | |
override 'module_file'
|
298 | 276 |
args.file = ldoc.file or '.'
|
299 | 277 |
if args.file == '.' then
|
300 | 278 |
args.file = lfs.currentdir()
|
301 | 279 |
elseif type(args.file) == 'table' then
|
302 | 280 |
for i,f in ipairs(args.file) do
|
303 | 281 |
args.file[i] = abspath(f)
|
304 | |
fixup_module_file(f,args.file[i])
|
305 | |
end
|
306 | |
reorder_module_file(args.file)
|
|
282 |
end
|
307 | 283 |
else
|
308 | 284 |
args.file = abspath(args.file)
|
309 | 285 |
end
|
|
386 | 362 |
override 'colon'
|
387 | 363 |
override 'merge'
|
388 | 364 |
override 'not_luadoc'
|
|
365 |
override 'module_file'
|
|
366 |
|
|
367 |
-- ldoc.module_file establishes a partial ordering where the
|
|
368 |
-- master module files are processed first.
|
|
369 |
local function reorder_module_file ()
|
|
370 |
if args.module_file then
|
|
371 |
local mf = {}
|
|
372 |
for mname, f in pairs(args.module_file) do
|
|
373 |
local fullpath = abspath(f)
|
|
374 |
mf[fullpath] = true
|
|
375 |
end
|
|
376 |
return function(x,y)
|
|
377 |
return mf[x] and not mf[y]
|
|
378 |
end
|
|
379 |
end
|
|
380 |
end
|
389 | 381 |
|
390 | 382 |
if type(args.file) == 'table' then
|
391 | 383 |
-- this can only be set from config file so we can assume it's already read
|
|
384 |
args.file.sortfn = reorder_module_file()
|
392 | 385 |
process_file_list(args.file,'*.*',process_file, file_list)
|
393 | 386 |
if #file_list == 0 then quit "no source files specified" end
|
394 | 387 |
elseif path.isdir(args.file) then
|
|
405 | 398 |
end
|
406 | 399 |
end
|
407 | 400 |
end
|
|
401 |
-- process files, optionally in order that respects master module files
|
|
402 |
local sortfn = reorder_module_file()
|
|
403 |
if sortfn then files:sort(sortfn) end
|
408 | 404 |
for f in files:iter() do
|
409 | 405 |
process_file(f, file_list)
|
410 | 406 |
end
|
|
407 |
|
411 | 408 |
if #file_list == 0 then
|
412 | 409 |
quit(quote(args.file).." contained no source files")
|
413 | 410 |
end
|