issue #139; improved lookup for class methods; args override now only kicks if the argument does not have its default value

This commit is contained in:
steve donovan 2014-01-05 14:55:20 +02:00
parent f507e36720
commit 86a3fde07e
2 changed files with 32 additions and 17 deletions

View File

@ -134,8 +134,10 @@ local add_language_extension
-- hacky way for doc module to be passed options... -- hacky way for doc module to be passed options...
doc.ldoc = ldoc doc.ldoc = ldoc
local function override (field) -- if the corresponding argument was the default, then any ldoc field overrides
if args[field] == nil and ldoc[field] ~= nil then args[field] = ldoc[field] end local function override (field,defval)
defval = defval or false
if args[field] == defval and ldoc[field] ~= nil then args[field] = ldoc[field] end
end end
-- aliases to existing tags can be defined. E.g. just 'p' for 'param' -- aliases to existing tags can be defined. E.g. just 'p' for 'param'
@ -336,6 +338,8 @@ source_dir = source_dir:gsub('[/\\]%.$','')
-- * 'NAME' explicitly give the base module package name -- * 'NAME' explicitly give the base module package name
-- --
override ('package','.')
local function setup_package_base() local function setup_package_base()
if ldoc.package then args.package = ldoc.package end if ldoc.package then args.package = ldoc.package end
if args.package == '.' then if args.package == '.' then
@ -460,7 +464,7 @@ end
-- create the function that renders text (descriptions and summaries) -- create the function that renders text (descriptions and summaries)
-- (this also will initialize the code prettifier used) -- (this also will initialize the code prettifier used)
override 'format' override ('format','plain')
override 'pretty' override 'pretty'
ldoc.markup = markup.create(ldoc, args.format,args.pretty) ldoc.markup = markup.create(ldoc, args.format,args.pretty)
@ -611,9 +615,9 @@ if args.filter ~= 'none' then
end end
-- can specify format, output, dir and ext in config.ld -- can specify format, output, dir and ext in config.ld
override 'output' override ('output','index')
override 'dir' override ('dir','doc')
override 'ext' override ('ext','html')
override 'one' override 'one'
-- handling styling and templates -- -- handling styling and templates --

View File

@ -219,6 +219,7 @@ function File:finish()
local this_mod local this_mod
local items = self.items local items = self.items
local tagged_inside local tagged_inside
self.args = self.args or {}
for item in items:iter() do for item in items:iter() do
if mod_section_type(this_mod) == 'factory' and item.tags then if mod_section_type(this_mod) == 'factory' and item.tags then
local klass = '@{'..this_mod.section.name..'}' local klass = '@{'..this_mod.section.name..'}'
@ -277,18 +278,21 @@ function File:finish()
this_mod.section = nil this_mod.section = nil
else else
local summary = item.summary:gsub('%.$','') local summary = item.summary:gsub('%.$','')
local lookup_name
if doc.class_tag(item.type) then if doc.class_tag(item.type) then
display_name = 'Class '..item.name display_name = 'Class '..item.name
lookup_name = item.name
item.module = this_mod item.module = this_mod
this_mod.items.by_name[item.name] = item this_mod.items.by_name[item.name] = item
else else
display_name = summary display_name = summary
lookup_name = summary
end end
item.display_name = display_name item.display_name = display_name
this_mod.section = item this_mod.section = item
this_mod.kinds:add_kind(display_name,display_name..' ',nil,item) this_mod.kinds:add_kind(display_name,display_name..' ',nil,item)
this_mod.sections:append(item) this_mod.sections:append(item)
this_mod.sections.by_name[display_name:gsub('%A','_')] = item this_mod.sections.by_name[lookup_name:gsub('%A','_')] = item
end end
else else
local to_be_removed local to_be_removed
@ -1049,22 +1053,23 @@ end
local function reference (s, mod_ref, item_ref) local function reference (s, mod_ref, item_ref)
local name = item_ref and item_ref.name or '' local name = item_ref and item_ref.name or ''
-- this is deeply hacky; classes have 'Class ' prepended. -- this is deeply hacky; classes have 'Class ' prepended.
if item_ref and doc.class_tag(item_ref.type) then --~ if item_ref and doc.class_tag(item_ref.type) then
name = 'Class_'..name --~ name = 'Class_'..name
end --~ end
return {mod = mod_ref, name = name, label=s} return {mod = mod_ref, name = name, label=s}
end end
function Module:lookup_class_item (packmod, s) function Module:lookup_class_item (packmod, s)
local section = "Class_"..packmod local klass = packmod --"Class_"..packmod
if self.sections.by_name[section] then local qs = klass..':'..s
local klass_section = self.sections.by_name[klass]
if not klass_section then return nil end -- no such class
for item in self.items:iter() do for item in self.items:iter() do
--print('item',item.name,item.section) --print('item',qs,item.name)
if item.section == section and s == item.name then if s == item.name or qs == item.name then
return reference(s,self,item) return reference(s,self,item)
end end
end end
end
return nil return nil
end end
@ -1114,6 +1119,12 @@ function Module:process_see_reference (s,modules,istype)
if not mod_ref then if not mod_ref then
local ref = self:lookup_class_item(packmod,s) local ref = self:lookup_class_item(packmod,s)
if ref then return ref end if ref then return ref end
local mod, klass = split_dotted_name(packmod)
mod_ref = modules.by_name[mod]
if mod_ref then
ref = mod_ref:lookup_class_item(klass,name)
if ref then return ref end
end
ref = lua_manual_ref(s) ref = lua_manual_ref(s)
if ref then return ref end if ref then return ref end
return nil,"module not found: "..packmod return nil,"module not found: "..packmod