Issue #108: sorting modules etc is off by default, switch back on using 'sort_modules=true'. Section lookup in docs was borked, fixed by stripping any extra whitespace before section titles

This commit is contained in:
steve donovan 2013-11-17 10:38:24 +02:00
parent 4666e464cc
commit 9fc5697cff
2 changed files with 10 additions and 7 deletions

View File

@ -198,7 +198,7 @@ local ldoc_contents = {
'readme','all','manual_url', 'ignore', 'colon', 'sort', 'module_file','vars',
'boilerplate','merge', 'wrap', 'not_luadoc', 'template_escape','merge_error_groups',
'no_return_or_parms','no_summary','full_description','backtick_references', 'custom_see_handler',
'no_space_before_args','parse_extra','no_lua_ref',
'no_space_before_args','parse_extra','no_lua_ref','sort_modules',
}
ldoc_contents = tablex.makeset(ldoc_contents)
@ -544,9 +544,11 @@ if not args.all and not ldoc.all then
end
end
table.sort(module_list,function(m1,m2)
return m1.name < m2.name
end)
if ldoc.sort_modules then
table.sort(module_list,function(m1,m2)
return m1.name < m2.name
end)
end
ldoc.single = modcount == 1 and first_module or nil

View File

@ -58,6 +58,7 @@ end
function markup.add_sections(F, txt)
local sections, L, first = {}, 1, true
local title_pat
local lstrip = stringx.lstrip
for line in stringx.lines(txt) do
if first then
local level,header = line:match '^(#+)%s*(.+)'
@ -67,14 +68,14 @@ function markup.add_sections(F, txt)
level = '##'
end
title_pat = '^'..level..'([^#]%s*.+)'
title_pat = stringx.lstrip(title_pat)
title_pat = lstrip(title_pat)
first = false
end
local title = line:match (title_pat)
if title then
-- Markdown does allow this pattern
title = title:gsub('%s*#+$','')
sections[L] = F:add_document_section(title)
sections[L] = F:add_document_section(lstrip(title))
end
L = L + 1
end