'plain=true' when format is set but you do not want doc comments treated specially. Backticks are now expanded in usage blocks

This commit is contained in:
steve donovan 2013-05-09 12:52:15 +02:00
parent 2fb5d81ab5
commit ac5c5f2c65
6 changed files with 27 additions and 14 deletions

View File

@ -184,7 +184,7 @@ end
local ldoc_contents = { local ldoc_contents = {
'alias','add_language_extension','new_type','add_section', 'tparam_alias', 'alias','add_language_extension','new_type','add_section', 'tparam_alias',
'file','project','title','package','format','output','dir','ext', 'topics', 'file','project','title','package','format','output','dir','ext', 'topics',
'one','style','template','description','examples', 'pretty', 'charset', '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',
'no_return_or_parms','no_summary','full_description','backtick_references', 'custom_see_handler', 'no_return_or_parms','no_summary','full_description','backtick_references', 'custom_see_handler',
} }

View File

@ -24,7 +24,8 @@ return [==[
# local use_li = ldoc.use_li # local use_li = ldoc.use_li
# local display_name = ldoc.display_name # local display_name = ldoc.display_name
# local iter = ldoc.modules.iter # local iter = ldoc.modules.iter
# local M = ldoc.markup # ---local M = ldoc.markup
# local function M(txt,item) return ldoc.markup(txt,item,ldoc.plain) end
# local nowrap = ldoc.wrap and '' or 'nowrap' # local nowrap = ldoc.wrap and '' or 'nowrap'
<!-- Menu --> <!-- Menu -->

View File

@ -17,16 +17,12 @@
-- iden n -- iden n
-- keyword do -- keyword do
-- </pre> -- </pre>
-- See the Guide for further <a href="../../index.html#lexer">discussion</a> <br> --
-- @class module -- Based on pl.lexer from Penlight
-- @name pl.lexer
local strfind = string.find local strfind = string.find
local strsub = string.sub local strsub = string.sub
local append = table.insert local append = table.insert
--[[
module ('pl.lexer',utils._module)
]]
local function assert_arg(idx,val,tp) local function assert_arg(idx,val,tp)
if type(val) ~= tp then if type(val) ~= tp then
@ -70,6 +66,14 @@ local function sdump(tok,options)
return "string",tok return "string",tok
end end
-- strings enclosed in back ticks
local function bdump(tok,options)
if options and options.string then
tok = tok:sub(2,-2)
end
return "backtick",tok
end
-- long Lua strings need extra work to get rid of the quotes -- long Lua strings need extra work to get rid of the quotes
local function sdump_l(tok,options) local function sdump_l(tok,options)
if options and options.string then if options and options.string then
@ -298,6 +302,7 @@ function lexer.lua(s,filter,options)
{STRING3,sdump}, {STRING3,sdump},
{STRING1,sdump}, {STRING1,sdump},
{STRING2,sdump}, {STRING2,sdump},
{'^`[^`]+`',bdump},
{'^%-%-%[(=*)%[.-%]%1%]',cdump}, {'^%-%-%[(=*)%[.-%]%1%]',cdump},
{'^%-%-.-\n',cdump}, {'^%-%-.-\n',cdump},
{'^%[(=*)%[.-%]%1%]',sdump_l}, {'^%[(=*)%[.-%]%1%]',sdump_l},

View File

@ -233,7 +233,6 @@ local function get_formatter(format)
end end
end end
local function text_processor(ldoc) local function text_processor(ldoc)
return function(txt,item) return function(txt,item)
if txt == nil then return '' end if txt == nil then return '' end
@ -243,10 +242,17 @@ local function text_processor(ldoc)
end end
end end
local plain_processor
local function markdown_processor(ldoc, formatter) local function markdown_processor(ldoc, formatter)
return function (txt,item) return function (txt,item,plain)
if txt == nil then return '' end if txt == nil then return '' end
if plain then
if not plain_processor then
plain_processor = text_processor(ldoc)
end
return plain_processor(txt,item)
end
if utils.is_type(item,doc.File) then if utils.is_type(item,doc.File) then
txt = process_multiline_markdown(ldoc, txt, item) txt = process_multiline_markdown(ldoc, txt, item)
else else
@ -258,7 +264,6 @@ local function markdown_processor(ldoc, formatter)
end end
end end
local function get_processor(ldoc, format) local function get_processor(ldoc, format)
if format == 'plain' then return text_processor(ldoc) end if format == 'plain' then return text_processor(ldoc) end

View File

@ -24,7 +24,7 @@ local function span(t,val)
return ('<span class="%s">%s</span>'):format(t,val) return ('<span class="%s">%s</span>'):format(t,val)
end end
local spans = {keyword=true,number=true,string=true,comment=true,global=true} local spans = {keyword=true,number=true,string=true,comment=true,global=true,backtick=true}
function prettify.lua (fname, code, initial_lineno, pre) function prettify.lua (fname, code, initial_lineno, pre)
local res = List() local res = List()
@ -47,7 +47,7 @@ function prettify.lua (fname, code, initial_lineno, pre)
t = 'global' t = 'global'
end end
if spans[t] then if spans[t] then
if t == 'comment' then -- may contain @{ref} if t == 'comment' or t == 'backtick' then -- may contain @{ref} or `..`
val = prettify.resolve_inline_references(val,error_reporter) val = prettify.resolve_inline_references(val,error_reporter)
end end
res:append(span(t,val)) res:append(span(t,val))

View File

@ -2,7 +2,9 @@
A non-doc comment A non-doc comment
multi-line multi-line
probably containing license information! probably containing license information!
Doesn't use module(), but module name is inferred from file name Doesn't use module(), but module name is inferred from file name.
If you have initial licence comments that look like doc comments,
then set `boilerplate=true`
]] ]]
------------ ------------
-- Test module, -- Test module,