From 9fc5697cffdeb9fa8e98a24fc6506ec36bf6a2ef Mon Sep 17 00:00:00 2001 From: steve donovan Date: Sun, 17 Nov 2013 10:38:24 +0200 Subject: [PATCH] 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 --- ldoc.lua | 10 ++++++---- ldoc/markup.lua | 7 ++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ldoc.lua b/ldoc.lua index f6b5d5d..ef73107 100644 --- a/ldoc.lua +++ b/ldoc.lua @@ -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 diff --git a/ldoc/markup.lua b/ldoc/markup.lua index 060e707..6a95399 100644 --- a/ldoc/markup.lua +++ b/ldoc/markup.lua @@ -57,7 +57,8 @@ end -- they can appear in the contents list as a ToC. function markup.add_sections(F, txt) local sections, L, first = {}, 1, true - local title_pat + 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