@usage code blocks are prettified
This commit is contained in:
parent
9f52eacb05
commit
7ceb7cc00b
|
@ -20,6 +20,7 @@ local stringx = require 'pl.stringx'
|
|||
local template = require 'pl.template'
|
||||
local tools = require 'ldoc.tools'
|
||||
local markup = require 'ldoc.markup'
|
||||
local prettify = require 'ldoc.prettify'
|
||||
local doc = require 'ldoc.doc'
|
||||
local html = {}
|
||||
|
||||
|
@ -59,6 +60,10 @@ function html.generate_output(ldoc, args, project)
|
|||
return (str:gsub("['&<>\"]", escape_table))
|
||||
end
|
||||
|
||||
function ldoc.prettify(str)
|
||||
return prettify.lua('tmp',str,0,true)
|
||||
end
|
||||
|
||||
-- this generates the internal module/function references
|
||||
function ldoc.href(see)
|
||||
if see.href then -- explict reference, e.g. to Lua manual
|
||||
|
|
|
@ -195,7 +195,7 @@ return [==[
|
|||
<h3>Usage:</h3>
|
||||
<ul>
|
||||
# for usage in iter(item.usage) do
|
||||
$(li)<pre class="example">$(ldoc.escape(usage))</pre>$(il)
|
||||
$(li)<pre class="example">$(ldoc.prettify(usage))</pre>$(il)
|
||||
# end -- for
|
||||
</ul>
|
||||
# end -- if usage
|
||||
|
|
|
@ -26,9 +26,11 @@ end
|
|||
|
||||
local spans = {keyword=true,number=true,string=true,comment=true,global=true}
|
||||
|
||||
function prettify.lua (fname, code, initial_lineno)
|
||||
function prettify.lua (fname, code, initial_lineno, no_pre)
|
||||
local res = List()
|
||||
res:append '<pre>\n'
|
||||
if not no_pre then
|
||||
res:append '<pre>\n'
|
||||
end
|
||||
initial_lineno = initial_lineno or 0
|
||||
|
||||
local tok = lexer.lua(code,{},{})
|
||||
|
|
Loading…
Reference in New Issue