From cf7b8e3a9a35400e4b7cf71242fa6fe9ffd4365b Mon Sep 17 00:00:00 2001 From: steve donovan Date: Thu, 9 May 2013 13:28:39 +0200 Subject: [PATCH] fixes issue #62: keep LuaDoc compatibility, unless not_luadoc is explicitly set --- ldoc.lua | 4 +++- ldoc/doc.lua | 21 ++++++++++++++++++--- tests/styles/four.lua | 4 ++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ldoc.lua b/ldoc.lua index 688a8a6..594e192 100644 --- a/ldoc.lua +++ b/ldoc.lua @@ -185,7 +185,8 @@ local ldoc_contents = { 'alias','add_language_extension','new_type','add_section', 'tparam_alias', 'file','project','title','package','format','output','dir','ext', 'topics', 'one','style','template','description','examples', 'pretty', 'charset', 'plain', - 'readme','all','manual_url', 'ignore', 'colon','boilerplate','merge', 'wrap', + 'readme','all','manual_url', 'ignore', 'colon', + 'boilerplate','merge', 'wrap', 'not_luadoc', 'no_return_or_parms','no_summary','full_description','backtick_references', 'custom_see_handler', } ldoc_contents = tablex.makeset(ldoc_contents) @@ -361,6 +362,7 @@ setup_package_base() override 'colon' override 'merge' +override 'not_luadoc' if type(args.file) == 'table' then -- this can only be set from config file so we can assume it's already read diff --git a/ldoc/doc.lua b/ldoc/doc.lua index dfedd1e..faa9172 100644 --- a/ldoc/doc.lua +++ b/ldoc/doc.lua @@ -388,14 +388,21 @@ function Item:add_to_description (rest) end end +function Item:trailing_warning (kind,tag,rest) + if type(rest)=='string' and #rest > 0 then + Item.warning(self,kind.." tag: '"..tag..'" has trailing text; use no_luadoc=true\n'..rest) + end +end + function Item:set_tag (tag,value) local ttype = known_tags[tag] + local args = self.file.args if ttype == TAG_MULTI or ttype == TAG_MULTI_LINE then -- value is always a List! if getmetatable(value) ~= List then value = List{value} end - if ttype ~= TAG_MULTI_LINE then + if ttype ~= TAG_MULTI_LINE and args.not_luadoc then local last = value[#value] if type(last) == 'string' and last:match '\n' then local line,rest = last:match('([^\n]+)(.*)') @@ -417,12 +424,20 @@ function Item:set_tag (tag,value) if value == nil then self:error("Tag without value: "..tag) end local id, rest = tools.extract_identifier(value) self.tags[tag] = id - self:add_to_description(rest) + if args.not_luadoc then + self:add_to_description(rest) + else + self:trailing_warning('id',tag,rest) + end elseif ttype == TAG_SINGLE then self.tags[tag] = value elseif ttype == TAG_FLAG then self.tags[tag] = true - self:add_to_description(value) + if args.not_luadoc then + self:add_to_description(value) + else + self:trailing_warning('flag',tag,value) + end else Item.warning(self,"unknown tag: '"..tag.."' "..tostring(ttype)) end diff --git a/tests/styles/four.lua b/tests/styles/four.lua index 02b7896..492a8fa 100644 --- a/tests/styles/four.lua +++ b/tests/styles/four.lua @@ -1,8 +1,8 @@ ------------ -- Yet another module. --- @module four -- Description can continue after simple tags, if you --- like +-- like - but to keep backwards compatibility, say 'not_luadoc=true' +-- @module four -- @author bob, james -- @license MIT -- @copyright InfoReich 2013