From 2b54ad1627f77cc5e197fbcc4a8b09d345d77089 Mon Sep 17 00:00:00 2001 From: steve donovan Date: Mon, 19 Sep 2011 13:32:30 +0200 Subject: [PATCH] mark global functions and tables when prettifying code --- html/ldoc_css.lua | 1 + ldoc/prettify.lua | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/html/ldoc_css.lua b/html/ldoc_css.lua index fe1f4a1..2f6b612 100644 --- a/html/ldoc_css.lua +++ b/html/ldoc_css.lua @@ -282,6 +282,7 @@ ul ol { margin-top: 0px; } .string { color: #8888AA; } .comment { color: #666600; } .prepro { color: #006666; } +.global { color: #800080; } ]==] diff --git a/ldoc/prettify.lua b/ldoc/prettify.lua index c061dd8..950b0e4 100644 --- a/ldoc/prettify.lua +++ b/ldoc/prettify.lua @@ -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 ('%s'):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)