mark global functions and tables when prettifying code

This commit is contained in:
steve donovan 2011-09-19 13:32:30 +02:00
parent 88b9a97cb1
commit 2b54ad1627
2 changed files with 6 additions and 1 deletions

View File

@ -282,6 +282,7 @@ ul ol { margin-top: 0px; }
.string { color: #8888AA; }
.comment { color: #666600; }
.prepro { color: #006666; }
.global { color: #800080; }
]==]

View File

@ -5,6 +5,7 @@
-- `@{example:test-fun}`.
require 'pl'
local lexer = require 'ldoc.lexer'
local globals = require 'builtin.globals'
local tnext = lexer.skipws
local prettify = {}
@ -23,7 +24,7 @@ local function span(t,val)
return ('<span class="%s">%s</span>'):format(t,val)
end
local spans = {keyword=true,number=true,string=true,comment=true}
local spans = {keyword=true,number=true,string=true,comment=true,global=true}
function prettify.lua (fname, code)
local res = List()
@ -40,6 +41,9 @@ function prettify.lua (fname, code)
if not t then return nil,"empty file" end
while t do
val = escape(val)
if globals.functions[val] or globals.tables[val] then
t = 'global'
end
if spans[t] then
if t == 'comment' then -- may contain @{ref}
val = prettify.resolve_inline_references(val,error_reporter)