diff --git a/ldoc/doc.lua b/ldoc/doc.lua index 55aeb18..ecdb268 100644 --- a/ldoc/doc.lua +++ b/ldoc/doc.lua @@ -1142,6 +1142,13 @@ function Module:process_see_reference (s,modules,istype) end end else -- plain jane name; module in this package, function in this module + if ldoc.global_lookup then + for m in modules:iter() do + fun_ref = m:get_fun_ref(s) + if fun_ref then return reference(s,m,fun_ref) end + end + return nil,"function: "..s.." not found globally" + end mod_ref = modules.by_name[self.package..'.'..s] if ismod(mod_ref) then return reference(s, mod_ref,nil) end fun_ref = self:get_fun_ref(s) diff --git a/ldoc/markup.lua b/ldoc/markup.lua index ec4acf3..c7a75e3 100644 --- a/ldoc/markup.lua +++ b/ldoc/markup.lua @@ -42,7 +42,8 @@ local function resolve_inline_references (ldoc, txt, item, plain) if not label then label = ref.label end - if not plain and label then -- a nastiness with markdown.lua and underscores + local do_escape = not plain and not ldoc.dont_escape_underscore + if label and do_escape then -- a nastiness with markdown.lua and underscores label = label:gsub('_','\\_') end local html = ldoc.href(ref) or '#' @@ -54,7 +55,7 @@ local function resolve_inline_references (ldoc, txt, item, plain) res = res:gsub('`([^`]+)`',function(name) local ref,err = markup.process_reference(name) if ref then - if not plain and name then + if name and do_escape then name = name:gsub('_', '\\_') end return ('%s '):format(ldoc.href(ref),name) @@ -115,9 +116,8 @@ local global_context, local_context -- - insert any section ids which were generated by add_sections above -- - prettify any code blocks -local function process_multiline_markdown(ldoc, txt, F) - local res, L, append = {}, 0, table.insert - local filename = F.filename +local function process_multiline_markdown(ldoc, txt, F, filename, deflang) + local res, L, append = {}, 0, table.insert local err_item = { warning = function (self,msg) io.stderr:write(filename..':'..L..': '..msg,'\n') @@ -133,8 +133,9 @@ local function process_multiline_markdown(ldoc, txt, F) if code ~= '' then local err -- If we omit the following '\n', a '--' (or '//') comment on the - -- last line won't be recognized. + -- last line won't be recognized. code, err = prettify.code(lang,filename,code..'\n',L,false) + code = resolve_inline_references(ldoc, code, err_item) append(res,'
')
          append(res, code)
          append(res,'
') @@ -192,9 +193,9 @@ local function process_multiline_markdown(ldoc, txt, F) while #code > 1 and blank(code[#code]) do -- trim blank lines. table.remove(code) end - pretty_code (code,'lua') + pretty_code (code,deflang) else - local section = F.sections[L] + local section = F and F.sections[L] if section then append(res,(''):format(section)) end @@ -274,8 +275,18 @@ local function markdown_processor(ldoc, formatter) end return plain_processor(txt,item) end - if utils.is_type(item,doc.File) then - txt = process_multiline_markdown(ldoc, txt, item) + local is_file = utils.is_type(item,doc.File) + local is_module = not file and item and doc.project_level(item.type) + if is_file or is_module then + local deflang = 'lua' + if ldoc.parse_extra and ldoc.parse_extra.C then + deflang = 'c' + end + if is_module then + txt = process_multiline_markdown(ldoc, txt, nil, item.file.filename, deflang) + else + txt = process_multiline_markdown(ldoc, txt, item, item.filename, deflang) + end else txt = resolve_inline_references(ldoc, txt, item) end diff --git a/ldoc/tools.lua b/ldoc/tools.lua index 464b148..f876099 100644 --- a/ldoc/tools.lua +++ b/ldoc/tools.lua @@ -109,6 +109,7 @@ function KindMap:add (item,items,description) local group = item[self.fieldname] -- which wd be item's type or section local kname = self.klass.types_by_tag[group] -- the kind name if not self[kname] then + -- print(kname,group,self.fieldname) self[kname] = M.type_iterator (items,self.fieldname,group) self.klass.descriptions[kname] = description end