Issue #93: can define fields/properties of objects; the 'readonly' modifier is now special. See tests/styles/type.lua
This commit is contained in:
parent
7e2e6e975c
commit
955802e07b
11
ldoc/doc.lua
11
ldoc/doc.lua
|
@ -288,6 +288,9 @@ function File:finish()
|
||||||
-- add the item to the module's item list
|
-- add the item to the module's item list
|
||||||
if this_mod then
|
if this_mod then
|
||||||
-- new-style modules will have qualified names like 'mod.foo'
|
-- new-style modules will have qualified names like 'mod.foo'
|
||||||
|
if item.name == nil then
|
||||||
|
self:error("item's name is nil")
|
||||||
|
end
|
||||||
local mod,fname = split_dotted_name(item.name)
|
local mod,fname = split_dotted_name(item.name)
|
||||||
-- warning for inferred unqualified names in new style modules
|
-- warning for inferred unqualified names in new style modules
|
||||||
-- (retired until we handle methods like Set:unset() properly)
|
-- (retired until we handle methods like Set:unset() properly)
|
||||||
|
@ -421,7 +424,7 @@ end
|
||||||
|
|
||||||
function Item:trailing_warning (kind,tag,rest)
|
function Item:trailing_warning (kind,tag,rest)
|
||||||
if type(rest)=='string' and #rest > 0 then
|
if type(rest)=='string' and #rest > 0 then
|
||||||
Item.warning(self,kind.." tag: '"..tag..'" has trailing text; use not_luadoc=true if you want description to continue between tags\n'..rest)
|
Item.warning(self,kind.." tag: '"..tag..'" has trailing text ; use not_luadoc=true if you want description to continue between tags\n"'..rest..'"')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -825,6 +828,12 @@ function Item:default_of_param(p)
|
||||||
return opt
|
return opt
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Item:readonly(p)
|
||||||
|
local m = self:param_modifiers(p)
|
||||||
|
if not m then return nil end
|
||||||
|
return m.readonly
|
||||||
|
end
|
||||||
|
|
||||||
function Item:subparam(p)
|
function Item:subparam(p)
|
||||||
local subp = rawget(self.subparams,p)
|
local subp = rawget(self.subparams,p)
|
||||||
if subp then
|
if subp then
|
||||||
|
|
|
@ -155,7 +155,10 @@ return [==[
|
||||||
$(M(ldoc.descript(item),item))
|
$(M(ldoc.descript(item),item))
|
||||||
|
|
||||||
# if show_parms and item.params and #item.params > 0 then
|
# if show_parms and item.params and #item.params > 0 then
|
||||||
<h3>$(module.kinds:type_of(item).subnames):</h3>
|
# local subnames = module.kinds:type_of(item).subnames
|
||||||
|
# if subnames then
|
||||||
|
<h3>$(subnames):</h3>
|
||||||
|
# end
|
||||||
<ul>
|
<ul>
|
||||||
# for parm in iter(item.params) do
|
# for parm in iter(item.params) do
|
||||||
# local param,sublist = item:subparam(parm)
|
# local param,sublist = item:subparam(parm)
|
||||||
|
@ -172,6 +175,9 @@ return [==[
|
||||||
$(M(item.params[p],item))
|
$(M(item.params[p],item))
|
||||||
# if def then
|
# if def then
|
||||||
(<em>default</em> $(def))
|
(<em>default</em> $(def))
|
||||||
|
# end
|
||||||
|
# if item:readonly(p) then
|
||||||
|
<em>readonly</em>
|
||||||
# end
|
# end
|
||||||
</li>
|
</li>
|
||||||
# end
|
# end
|
||||||
|
|
|
@ -364,6 +364,17 @@ local function parse_file(fname, lang, package, args)
|
||||||
if is_local or tags['local'] then
|
if is_local or tags['local'] then
|
||||||
tags:add('local',true)
|
tags:add('local',true)
|
||||||
end
|
end
|
||||||
|
-- support for standalone fields/properties of classes/modules
|
||||||
|
if (tags.field or tags.param) and not tags.class then
|
||||||
|
-- the hack is to take a subfield and pull out its name,
|
||||||
|
-- (see Tag:add above) but let the subfield itself go through
|
||||||
|
-- with any modifiers.
|
||||||
|
local fp = tags.field or tags.param
|
||||||
|
if type(fp) == 'table' then fp = fp[1] end
|
||||||
|
fp = tools.extract_identifier(fp)
|
||||||
|
tags:add('name',fp)
|
||||||
|
tags:add('class','field')
|
||||||
|
end
|
||||||
if tags.name then
|
if tags.name then
|
||||||
current_item = F:new_item(tags,line)
|
current_item = F:new_item(tags,line)
|
||||||
current_item.inferred = item_follows ~= nil
|
current_item.inferred = item_follows ~= nil
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
-----
|
||||||
|
-- module containing a class
|
||||||
|
-- @module type
|
||||||
|
|
||||||
|
----
|
||||||
|
-- Our class.
|
||||||
|
-- @type Bonzo
|
||||||
|
|
||||||
|
----
|
||||||
|
-- make a new Bonzo
|
||||||
|
-- @string s name of Bonzo
|
||||||
|
function Bonzo.new(s)
|
||||||
|
end
|
||||||
|
|
||||||
|
-----
|
||||||
|
-- get a string representation.
|
||||||
|
function Bonzo.__tostring()
|
||||||
|
end
|
||||||
|
|
||||||
|
----
|
||||||
|
-- A subtable with fields.
|
||||||
|
-- @table Details
|
||||||
|
-- @string[readonly] name
|
||||||
|
-- @int[readonly] age
|
||||||
|
|
||||||
|
---
|
||||||
|
-- This is a simple field/property of the class.
|
||||||
|
-- @string[opt="Bilbo",readonly] frodo direct access to text
|
Loading…
Reference in New Issue