Issue #93: can define fields/properties of objects; the 'readonly' modifier is now special. See tests/styles/type.lua
steve donovan
10 years ago
287 | 287 |
-- add the item to the module's item list
|
288 | 288 |
if this_mod then
|
289 | 289 |
-- new-style modules will have qualified names like 'mod.foo'
|
|
290 |
if item.name == nil then
|
|
291 |
self:error("item's name is nil")
|
|
292 |
end
|
290 | 293 |
local mod,fname = split_dotted_name(item.name)
|
291 | 294 |
-- warning for inferred unqualified names in new style modules
|
292 | 295 |
-- (retired until we handle methods like Set:unset() properly)
|
|
420 | 423 |
|
421 | 424 |
function Item:trailing_warning (kind,tag,rest)
|
422 | 425 |
if type(rest)=='string' and #rest > 0 then
|
423 | |
Item.warning(self,kind.." tag: '"..tag..'" has trailing text; use not_luadoc=true if you want description to continue between tags\n'..rest)
|
|
426 |
Item.warning(self,kind.." tag: '"..tag..'" has trailing text ; use not_luadoc=true if you want description to continue between tags\n"'..rest..'"')
|
424 | 427 |
end
|
425 | 428 |
end
|
426 | 429 |
|
|
824 | 827 |
return opt
|
825 | 828 |
end
|
826 | 829 |
|
|
830 |
function Item:readonly(p)
|
|
831 |
local m = self:param_modifiers(p)
|
|
832 |
if not m then return nil end
|
|
833 |
return m.readonly
|
|
834 |
end
|
|
835 |
|
827 | 836 |
function Item:subparam(p)
|
828 | 837 |
local subp = rawget(self.subparams,p)
|
829 | 838 |
if subp then
|
154 | 154 |
$(M(ldoc.descript(item),item))
|
155 | 155 |
|
156 | 156 |
# if show_parms and item.params and #item.params > 0 then
|
157 | |
<h3>$(module.kinds:type_of(item).subnames):</h3>
|
|
157 |
# local subnames = module.kinds:type_of(item).subnames
|
|
158 |
# if subnames then
|
|
159 |
<h3>$(subnames):</h3>
|
|
160 |
# end
|
158 | 161 |
<ul>
|
159 | 162 |
# for parm in iter(item.params) do
|
160 | 163 |
# local param,sublist = item:subparam(parm)
|
|
171 | 174 |
$(M(item.params[p],item))
|
172 | 175 |
# if def then
|
173 | 176 |
(<em>default</em> $(def))
|
|
177 |
# end
|
|
178 |
# if item:readonly(p) then
|
|
179 |
<em>readonly</em>
|
174 | 180 |
# end
|
175 | 181 |
</li>
|
176 | 182 |
# end
|
363 | 363 |
if is_local or tags['local'] then
|
364 | 364 |
tags:add('local',true)
|
365 | 365 |
end
|
|
366 |
-- support for standalone fields/properties of classes/modules
|
|
367 |
if (tags.field or tags.param) and not tags.class then
|
|
368 |
-- the hack is to take a subfield and pull out its name,
|
|
369 |
-- (see Tag:add above) but let the subfield itself go through
|
|
370 |
-- with any modifiers.
|
|
371 |
local fp = tags.field or tags.param
|
|
372 |
if type(fp) == 'table' then fp = fp[1] end
|
|
373 |
fp = tools.extract_identifier(fp)
|
|
374 |
tags:add('name',fp)
|
|
375 |
tags:add('class','field')
|
|
376 |
end
|
366 | 377 |
if tags.name then
|
367 | 378 |
current_item = F:new_item(tags,line)
|
368 | 379 |
current_item.inferred = item_follows ~= nil
|
|
0 |
-----
|
|
1 |
-- module containing a class
|
|
2 |
-- @module type
|
|
3 |
|
|
4 |
----
|
|
5 |
-- Our class.
|
|
6 |
-- @type Bonzo
|
|
7 |
|
|
8 |
----
|
|
9 |
-- make a new Bonzo
|
|
10 |
-- @string s name of Bonzo
|
|
11 |
function Bonzo.new(s)
|
|
12 |
end
|
|
13 |
|
|
14 |
-----
|
|
15 |
-- get a string representation.
|
|
16 |
function Bonzo.__tostring()
|
|
17 |
end
|
|
18 |
|
|
19 |
----
|
|
20 |
-- A subtable with fields.
|
|
21 |
-- @table Details
|
|
22 |
-- @string[readonly] name
|
|
23 |
-- @int[readonly] age
|
|
24 |
|
|
25 |
---
|
|
26 |
-- This is a simple field/property of the class.
|
|
27 |
-- @string[opt="Bilbo",readonly] frodo direct access to text
|