@ lookup can now happen on main page, and we now have a LuaRocks-agnostic way of finding builtin references

This commit is contained in:
steve donovan 2012-03-19 19:07:11 +02:00
parent abd89a1ab8
commit 9bf51e3294
2 changed files with 9 additions and 8 deletions

View File

@ -174,7 +174,7 @@ function markup.create (ldoc, format)
global_context = ldoc.package and ldoc.package .. '.'
markup.process_reference = function(name)
local mod = ldoc.single or ldoc.module
local mod = ldoc.single or ldoc.module or ldoc.modules[1]
local ref,err = mod:process_see_reference(name, ldoc.modules)
if ref then return ref end
if global_context then

View File

@ -217,7 +217,7 @@ function M.this_module_name (basename,fname)
return M.name_of(lpath):gsub('%.init$','')
end
function M.find_existing_module (name, searchfn)
function M.find_existing_module (name, dname, searchfn)
local fullpath,lua = searchfn(name)
local mod = true
if not fullpath then -- maybe it's a function reference?
@ -229,7 +229,7 @@ function M.find_existing_module (name, searchfn)
fullpath = nil
end
if not fullpath then
return nil, "module or function '"..name.."' not found on module path"
return nil, "module or function '"..dname.."' not found on module path"
else
mod = fname
end
@ -240,13 +240,14 @@ end
function M.lookup_existing_module_or_function (name, docpath)
-- first look up on the Lua module path
local fullpath, mod = M.find_existing_module(name,path.package_path)
local fullpath, mod = M.find_existing_module(name,name,path.package_path)
-- no go; but see if we can find it on the doc path
if not fullpath then
fullpath, mod = M.find_existing_module(name, function(name)
local fpath = package.searchpath(name,docpath)
return fpath,true -- result must always be 'lua'!
end)
fullpath, mod = M.find_existing_module("ldoc.builtin." .. name,name,path.package_path)
--~ fullpath, mod = M.find_existing_module(name, function(name)
--~ local fpath = package.searchpath(name,docpath)
--~ return fpath,true -- result must always be 'lua'!
--~ end)
end
return fullpath, mod -- `mod` can be the error message
end