From dfdac3f977ba3dc43e18d4b7196dc72677083d3b Mon Sep 17 00:00:00 2001 From: Steve Donovan Date: Tue, 20 Aug 2013 15:26:49 +0200 Subject: [PATCH] fix #84; also no_space_before_args=false to stop ldoc putting space between name and arglist of functions --- ldoc.lua | 1 + ldoc/doc.lua | 2 +- ldoc/html.lua | 10 ++++++++-- tests/styles/four.lua | 6 +++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ldoc.lua b/ldoc.lua index f1e2c70..8817e4d 100644 --- a/ldoc.lua +++ b/ldoc.lua @@ -191,6 +191,7 @@ local ldoc_contents = { 'readme','all','manual_url', 'ignore', 'colon', 'sort', 'module_file', 'boilerplate','merge', 'wrap', 'not_luadoc', 'template_escape', 'no_return_or_parms','no_summary','full_description','backtick_references', 'custom_see_handler', + 'no_space_before_args', } ldoc_contents = tablex.makeset(ldoc_contents) diff --git a/ldoc/doc.lua b/ldoc/doc.lua index 884b8cc..bacad6e 100644 --- a/ldoc/doc.lua +++ b/ldoc/doc.lua @@ -737,7 +737,7 @@ function build_arg_list (names,pmods) end opt = m.optchain or m.opt if opt then - acc(' [') + acc('[') npending=npending+1 end end diff --git a/ldoc/html.lua b/ldoc/html.lua index dcec02e..abd664b 100644 --- a/ldoc/html.lua +++ b/ldoc/html.lua @@ -143,8 +143,14 @@ function html.generate_output(ldoc, args, project) function ldoc.display_name(item) local name = item.display_name or item.name - if item.type == 'function' or item.type == 'lfunction' then return name..' '..item.args --   - else return name end + if item.type == 'function' or item.type == 'lfunction' then + if not ldoc.no_space_before_args then + name = name..' ' + end + return name..item.args + else + return name + end end function ldoc.no_spaces(s) diff --git a/tests/styles/four.lua b/tests/styles/four.lua index 492a8fa..a178726 100644 --- a/tests/styles/four.lua +++ b/tests/styles/four.lua @@ -27,7 +27,6 @@ end function two (one,two,three,four) end - --- third useless function. -- Can always put comments inline, may -- be multiple. @@ -38,6 +37,11 @@ function three ( -- person: -- not less than zero! ) +---- function with single optional arg +-- @param[opt] one +function four (one) +end + --- an implicit table. -- Again, we can use the comments person = {